Improve userinformation panel with contribution statistics

This commit is contained in:
Pieter Vander Vennet 2023-01-14 04:19:10 +01:00
parent 8603c409fc
commit 9fafd7d456
2 changed files with 79 additions and 9 deletions

View file

@ -7,6 +7,13 @@
"source": {
"osmTags": "id~*"
},
"calculatedTags": [
"_mastodon_candidate_md=feat.properties._description.match(/\\[[^\\]]*\\]\\((.*(mastodon|en.osm.town).*)\\).*/)?.at(1)",
"_d=feat.properties._description?.replace(/&lt;/g,'<')?.replace(/&gt;/g,'>') ?? ''",
"_mastodon_candidate_a=(feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName(\"a\")).filter(a => a.href.match(/mastodon|en.osm.town/) !== null)[0]?.href }) (feat) ",
"_mastodon_link=(feat => {const e = document.createElement('div');e.innerHTML = feat.properties._d;return Array.from(e.getElementsByTagName(\"a\")).filter(a => a.getAttribute(\"rel\")?.indexOf('me') >= 0)[0]?.href})(feat) ",
"_mastodon_candidate=feat.properties._mastodon_candidate_md ?? feat.properties._mastodon_candidate_a"
],
"tagRenderings": [
{
"id": "picture-license",
@ -43,13 +50,43 @@
]
},
{
"id": "translation-thanks",
"condition": "_is_translator=true",
"id": "verified-mastodon",
"mappings": [
{
"if": "_is_translator=true",
"if": "_mastodon_link~*",
"then": {
"en": "You have contributed to translating MapComplete! That's awesome!"
"en": "A link to your Mastodon-profile has been been found: <a href='{_mastodon_link}' target='_blank'>{_mastodon_link}</a>"
},
"icon": "mastodon"
},
{
"if": "_mastodon_candidate~*",
"then": {
"en": "We found a link to what looks to be a mastodon account, but it is unverified. <a href='https://www.openstreetmap.org/profile/edit' target='_blank'>Edit your profile description</a> and place the following there: <span class='code'>&lta href=\"{_mastodon_candidate}\" rel=\"me\"&gtMastodon&lt/a&gt"
},
"icon": "invalid"
}
]
},
{
"id": "translation-thanks",
"mappings": [
{
"if": "_translation_contributions>0",
"then": {
"en": "You have contributed to translating MapComplete with {_translation_contributions} commits! That's awesome!"
},
"icon": "party"
}
]
},
{
"id": "contributor-thanks",
"mappings": [
{
"if": "_code_contributions>0",
"then": {
"en": "You have contributed code to MapComplete with {_code_contributions} commits! That's awesome!"
},
"icon": "party"
}
@ -62,4 +99,4 @@
}
],
"mapRendering": null
}
}