Add instrument to the mix
authorDan Scott <dscott@laurentian.ca>
Mon, 18 Sep 2017 01:40:56 +0000 (21:40 -0400)
committerDan Scott <dscott@laurentian.ca>
Mon, 18 Sep 2017 02:08:56 +0000 (22:08 -0400)
Might as well grab the first instrument as well.

Signed-off-by: Dan Scott <dscott@laurentian.ca>
Open-ILS/web/js/ui/default/opac/wikidata_music_card.js

index a87e60d..aba84ea 100644 (file)
@@ -82,7 +82,7 @@
 
   function findPerformer(icon_node, entity_name) {
     var url = 'https://query.wikidata.org/sparql';
-    var query = 'SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ?birthPlace ?birthPlaceLabel ' +
+    var query = 'SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ?instrumentLabel ?birthPlace ?birthPlaceLabel ' +
         '?website ?musicbrainz ?songKick ?twitter ?facebook ' +
         'WHERE { ' +
         '?item rdfs:label|skos:altLabel|wdt:P1449 "' + entity_name + '"@en . ' +
@@ -93,6 +93,7 @@
         '{ ?item wdt:P106/wdt:P279* wd:Q639669 . } ' +
         'OPTIONAL { ?item wdt:P3478 ?songKick } . ' +
         'OPTIONAL { ?item wdt:P19 ?birthPlace } . ' +
+        'OPTIONAL { ?item wdt:P1303 ?instrument } . ' +
         'OPTIONAL { ?item wdt:P856 ?website } . ' +
         'OPTIONAL { ?item wdt:P434 ?musicbrainz } . ' +
         'OPTIONAL { ?item wdt:P2002 ?twitter } . ' +
           }
           valueLink.innerText = labelText;
           valueDiv.appendChild(valueLink);
+        } else if (label !== null) {
+          var valueText = document.createElement('span');
+          valueText.innerText = labelText;
+          valueDiv.appendChild(valueText);
         }
         musician.appendChild(valueDiv);
       }
     }
 
+    addWDValue('instrumentLabel', 'Instrument: ', 'instrumentLabel', false);
     addWDValue('birthPlace', 'Birth place: ', 'birthPlaceLabel', true);
     addWDValue('website', 'Web site: ', null, true);
     addWDValue('musicbrainz', null, 'Discography (Musicbrainz)', true, function(value) { return 'https://musicbrainz.org/artist/' + value });