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 . ' +
'?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);
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;
}
}
- 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 });