-
Notifications
You must be signed in to change notification settings - Fork 11
/
etymology.yaml
74 lines (67 loc) · 3.26 KB
/
etymology.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name:
en: Etymology
query: |
(
nwr["name:etymology"];
nwr["name:etymology:wikidata"];
)
feature:
description: |
{% set value = null %}
{% for tag in ['highway', 'railway', 'amenity', 'leisure', 'shop', 'man_made', 'landuse', 'natural', 'waterway', 'place', 'route', 'aeroway', 'aerialway', 'craft', 'office', 'military', 'building', 'barrier','geological','historic', 'power', 'tourism', 'boundary'] %}
{% if not value and tags[tag] %}
{% set value = attribute(tags, tag) %}
{% if value in ['yes'] %}
{{ keyTrans(tag) }}
{% else %}
{{ tagTransList(tag, value) }}
{% endif %}
{% endif %}
{% endfor %}
details: |
{% if not attribute(tags, "name:etymology") and attribute(tags, 'name:etymology:wikidata') %}
{% for i, wd in attribute(tags, 'name:etymology:wikidata')|split(';') %}
{%- if i != 0 %},{% endif %}
{% if wd %}
{% set wikidata = wd|wikidataEntity %}
{{ wikidata ? (wikidata.labels[user.data_lang]|default(wikidata.labels[user.ui_lang])|default(wikidata.labels.en)).value : wd }}
{% endif %}
{% endfor %}
{% else %}
{{ attribute(tags, "name:etymology")|enumerate }}
{% endif %}
body: |
<ul>
{% if attribute(tags, "name:etymology") or attribute(tags, 'name:etymology:wikidata') %}
<li class='hasSymbol'>
<i class="fa fa-book" aria-hidden="true"></i>
<span class='key'>{{ keyTrans('name:etymology') }}:</span>
<span class='value'>
{% set etymWikidata = attribute(tags, 'name:etymology:wikidata')|split(';') %}
{% set etymName = attribute(tags, 'name:etymology')|split(';') %}
{% set etymDesc = attribute(tags, 'name:etymology:description')|split(';') %}
{% set result = [] %}
{% for i in 0..max(etymName|length - 1, etymWikidata|length - 1) %}
{% set wikidata = etymWikidata[i]|wikidataEntity %}
{% set label = wikidata ? (wikidata.labels[user.data_lang]|default(wikidata.labels[user.ui_lang])|default(wikidata.labels.en)).value : etymName[i]|default(etymWikidata[i]) %}
{% set desc = wikidata ? (wikidata.descriptions[user.data_lang]|default(wikidata.descriptions[user.ui_lang])|default(wikidata.descriptions.en)).value|default(etymDesc) : etymDesc %}
{% set url = attribute(tags, 'name:etymology:website')
|default(attribute(tags, 'name:etymology:url'))
|default(wikidata.sitelinks[user.data_lang ~ 'wiki'].url)
|default(wikidata.sitelinks[user.ui_lang ~ 'wiki'].url)
|default(etymWikidata[i] ? 'https://wikidata.org/wiki/' ~ etymWikidata[i]|url_encode : null)
%}
{% set result = result|merge([ url ? '<a target="_blank" href="' ~ url ~ '">' ~ (etymName[i]|default(label))|e ~ '</a>' ~ (desc ? ' (' ~ desc|e ~ ')' : '') : etymName[i]|e ~ (desc ? ' (' ~ desc|e ~ ')' : '') ]) %}
{% endfor %}
{{ result|enumerate|raw }}
</span>
</li>
{% endif %}
{% if attribute(tags, 'name:start_date') %}
<li class='hasSymbol'>
<i class="fa fa-book" aria-hidden="true"></i>
<span class='key'>{{ keyTrans('name:start_date') }}:</span>
<span class='value'>{{ attribute(tags, 'name:start_date')|osmFormatDate({ format: 'short' }) }}</span>
</li>
{% endif %}
</ul>