Widget: DCTList: Difference between revisions
From LINKS Community Center
Eschmidt (talk | contribs) No edit summary |
Eschmidt (talk | contribs) No edit summary |
||
Line 170: | Line 170: | ||
'|?-Subproperty_of=' + FUNC_KEY + | '|?-Subproperty_of=' + FUNC_KEY + | ||
'|?Has_description=' + DESC_KEY; | '|?Has_description=' + DESC_KEY; | ||
const functionsQueryResponse = await fetch(getQueryUrl(functionsQuery)).then(response => response.json()); | const functionsQueryResponse = await fetch(getQueryUrl(functionsQuery)).then(response => response.json()); | ||
Object.keys( | Object.keys(functionsQueryResponse.query.results).forEach(key => { | ||
const functionCategory = | const functionCategory = functionsQueryResponse.query.results[key]; | ||
functionsData.set( | functionsData.set( | ||
removePrefix(functionCategory.fulltext), | removePrefix(functionCategory.fulltext), | ||
Line 185: | Line 183: | ||
}); | }); | ||
// TODO: Remove properties that are not relevant for the filter | // TODO: Remove properties that are not relevant for the filter? (e.g. 'Supported content types') | ||
const allFunctions = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat(); | const allFunctions = Array.from(functionsData.values(), entry => entry[FUNC_KEY]).flat(); | ||
const DATASRC_PROP = 'Data Sources'; | |||
const IMG_PROP = 'Image'; | |||
const dctQuery = '[[Category:Disaster Community Technology]]' + | const dctQuery = '[[Category:Disaster Community Technology]]' + | ||
'[[Is Archived::No]]' + | '[[Is Archived::No]]' + | ||
'|limit=500' + | '|limit=500' + | ||
'|? | '|?' + IMG_PROP + | ||
'|? | '|?' + DATASRC_PROP + | ||
'|?' + allFunctions.join('|?'); | '|?' + allFunctions.join('|?'); | ||
const dctResponse = await fetch(getQueryUrl(dctQuery)).then(response => response.json()); | const dctResponse = await fetch(getQueryUrl(dctQuery)).then(response => response.json()); | ||
const dctList = Object.keys(dctResponse.query.results).map( | const dctList = Object.keys(dctResponse.query.results).map(dctName => { | ||
const dctResult = dctResponse.query.results[ | const dctResult = dctResponse.query.results[dctName]; | ||
/** @type {DCT} */ | /** @type {DCT} */ | ||
const dct = {}; | const dct = {}; | ||
dct.name = | dct.name = dctName; | ||
dct.url = dctResult.fullurl; | dct.url = dctResult.fullurl; | ||
dct.dataSources = dctResult.printouts[ | dct.dataSources = dctResult.printouts[DATASRC_PROP].map(source => source.fulltext).sort(); | ||
dct.logo = dctResult.printouts[ | dct.logo = dctResult.printouts[IMG_PROP][0] ? getFilePath(dctResult.printouts[IMG_PROP][0].fulltext) : undefined; | ||
dct.functions = []; | dct.functions = []; | ||
functionsData.forEach((value, key) => { | functionsData.forEach((value, key) => { | ||
if (value[FUNC_KEY].some( | if (value[FUNC_KEY].some( |
Revision as of 09:32, 31 August 2022
Development verstion of the DCT List.
Not ready for production!