From c23d925fce9b044a8c3dae385ce17c6cf7d48dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20B=C3=B6sch-Plepelits?= Date: Tue, 3 Jan 2023 17:33:57 +0100 Subject: [PATCH] culture-media: use categories instead of text --- culture-media.yaml | 83 ++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 47 deletions(-) diff --git a/culture-media.yaml b/culture-media.yaml index c66e3c6..6550a7d 100644 --- a/culture-media.yaml +++ b/culture-media.yaml @@ -9,34 +9,32 @@ query: ) feature: pre: | - {% set color = 'red' %} - {% set str = 'No image, wikimedia_commons or wikidata' %} + {% set cat = 'no' %} + {% set str = null %} {% if tags.wikidata %} - {% set color = 'blue' %} - {% set str = 'has wikidata tag' %} + {% set cat = 'wikidata' %} {% set wikidata = tags.wikidata|wikidataEntity %} {% if wikidata and wikidata.claims.P18|length == 0 %} - {% set color = '#007fff' %} - {% set str = 'has wikidata tag, but wikidata object does not have an image' %} + {% set cat = 'wikidata_no_image' %} {% endif %} {% if wikidata.claims.P31[0].mainsnak.datavalue.value.id in ['Q5'] %} - {% set color = 'magenta' %} - {% set str = "wikidata points to a human, should most likely be 'subject:wikidata'" %} + {% set cat = 'wikidata_human' %} {% endif %} {% elseif tags.wikipedia %} - {% set color = '#af00ff' %} - {% set str = 'wikipedia tag found without corresponding wikidata tag' %} + {% set cat = 'wikipedia_no_wikidata' %} {% elseif tags.wikimedia_commons or tags.image %} - {% set color = 'cyan' %} + {% set cat = 'has_image' %} {% set str = tags.wikimedia_commons ? 'has wikimedia_commons tag' : 'has image tag' %} {% endif %} + {% set def = const.categories[cat] %} + exclude: | {% if filter.category == 'wikidata_no_image' %} {{ (not wikidata) or (wikidata.claims.P18|length != 0) }} @@ -47,11 +45,11 @@ feature: {% endif %} body: | - {{ str }} + {{ str|default(def.text) }} style: color: | - {{ color }} + {{ def.color }} description: | {% if tags.historic and tags.historic != 'yes' %} @@ -68,8 +66,8 @@ feature: {% elseif tags.heritage %} {{ keyTrans('heritage') }} {% endif %} - markerSymbol: "{{ markerPointer({ fillColor: color })|raw }}" - listMarkerSymbol: "{{ markerCircle({ fillColor: color })|raw }}" + markerSymbol: "{{ markerPointer({ fillColor: def.color })|raw }}" + listMarkerSymbol: "{{ markerCircle({ fillColor: def.color })|raw }}" markerSign: | {% set icon = '' %} @@ -110,42 +108,14 @@ filter: info: | + {% for k, def in const.categories %} - - - - - - - - - - - - - - - - - - - - - + + {% endfor %}
- {{ markerCircle({ fillColor: 'red' })|raw }} - No image, wikimedia_commons or wikidata
- {{ markerCircle({ fillColor: 'magenta' })|raw }} - wikidata tag points to a human, should most likely be 'subject:wikidata'
- {{ markerCircle({ fillColor: '#af00ff' })|raw }} - wikipedia tag found without corresponding wikidata tag
- {{ markerCircle({ fillColor: 'cyan' })|raw }} - image or wikimedia_commons tag but no wikidata
- {{ markerCircle({ fillColor: '#007fff' })|raw }} + {{ markerCircle({ fillColor: def.color })|raw }} has wikidata tag, but wikidata object does not have an image
- {{ markerCircle({ fillColor: 'blue' })|raw }} - has wikidata tag{{ def.text }}
This category lists artwork, memorials, historic and heritage protected objects. These should have an image or wikimedia_commons tag, or (even better) a wikidata tag pointing to the object's entry.
@@ -178,3 +148,22 @@ const: other: query: 'nwr[historic][historic!~"^(memorial|monument|wayside_cross|wayside_shrine|building)$"]' trans: 'other' + categories: + 'no': + color: red + text: No image, wikimedia_commons or wikidata + wikidata_human: + color: magenta + text: wikidata tag points to a human, should most likely be 'subject:wikidata' + wikipedia_no_wikidata: + color: '#af00ff' + text: wikipedia tag found without corresponding wikidata tag + has_image: + color: cyan + text: image or wikimedia_commons tag but no wikidata + wikidata_no_image: + color: '#007fff' + text: has wikidata tag, but wikidata object does not have an image + wikidata: + color: blue + text: has wikidata tag