Commit dfb7690c authored by Dan Scott's avatar Dan Scott

Group and display instruments

For multi-instrumentalists like Joni Mitchell, this offers a better
representation of their diverse skills. A side effect of the GROUP_CONCAT()
is that a value is now always returned for the instruments variable, even
if the performer has no associated instruments; avoid displaying it if it is
nothing more than whitespace.
Signed-off-by: 's avatarDan Scott <dscott@laurentian.ca>
parent 32ab24bb
......@@ -84,7 +84,9 @@
function findPerformer(icon_node, entity_name) {
var url = 'https://query.wikidata.org/sparql';
var query = 'SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ?instrumentLabel ?birthPlace ?birthPlaceLabel ' +
var query = 'SELECT DISTINCT ?item ?itemLabel ?itemDescription ?image ' +
'(GROUP_CONCAT(DISTINCT ?instrumentLabel;separator="; ") AS ?instruments) ' +
'?birthPlace ?birthPlaceLabel ' +
'?website ?musicbrainz ?songKick ?twitter ?facebook ?wplink ' +
'WHERE { ' +
'?item rdfs:label|skos:altLabel|wdt:P1449 "' + entity_name + '"@en . ' +
......@@ -106,8 +108,15 @@
'?wplink schema:inLanguage "en" . ' +
'?wplink schema:isPartOf <https://en.wikipedia.org/> . ' +
'} ' +
'SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } ' +
'SERVICE wikibase:label { ' +
' bd:serviceParam wikibase:language "en". ' +
' ?instrument rdfs:label ?instrumentLabel. ' +
' ?item rdfs:label ?itemLabel. ' +
' ?item schema:description ?itemDescription. ' +
' ?birthPlace rdfs:label ?birthPlaceLabel ' +
'} ' +
'} ' +
'GROUP BY ?item ?itemLabel ?itemDescription ?image ?birthPlace ?birthPlaceLabel ?website ?musicbrainz ?songKick ?twitter ?facebook ?wplink'
'LIMIT 10';
var q = '?query=' + encodeURIComponent(query);
......@@ -214,7 +223,7 @@
function addWDValue(property, propertyLabel, label, isLink, linkFormatter) {
var value = '';
if (r.hasOwnProperty(property)) {
if (r.hasOwnProperty(property) && r[property].value.trim()) {
value = r[property].value;
var valueDiv = document.createElement('div');
var labelText = value;
......@@ -253,7 +262,7 @@
}
}
addWDValue('instrumentLabel', 'Instrument: ', 'instrumentLabel', false);
addWDValue('instruments', 'Instruments: ', 'instruments', 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 });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment