summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xproposals.py14
-rw-r--r--requirements.txt1
-rw-r--r--script.js6
3 files changed, 20 insertions, 1 deletions
diff --git a/proposals.py b/proposals.py
index 3ecc962..dc770b4 100755
--- a/proposals.py
+++ b/proposals.py
@@ -5,6 +5,7 @@ import sys
import pywikiapi
import mwparserfromhell
+import requests
OSMWIKI_ENDPOINT = 'https://wiki.openstreetmap.org/w/api.php'
@@ -12,6 +13,11 @@ osmwiki = pywikiapi.Site(OSMWIKI_ENDPOINT)
# https://wiki.openstreetmap.org/w/index.php?title=Template:Proposal_page&action=edit
+res = requests.get(
+ 'https://wiki.openstreetmap.org/w/api.php?action=expandtemplates&prop=wikitext&format=json&text={%7B%23invoke:languages/table%7Cjson}}'
+)
+langs = json.loads(res.json()['expandtemplates']['wikitext'])
+
def get_template_val(tpl, name):
param = tpl.get(name, None)
@@ -110,9 +116,17 @@ for page in osmwiki.query_pages(
definition = get_template_val(tpl, 'definition')
users = get_template_val(tpl, 'users') or get_template_val(tpl, 'user')
+ parts = page_title.split(':', maxsplit=1)
+ parts[0] = parts[0].lower()
+
+ lang = None
+ if parts[0] in langs:
+ lang = parts[0]
+
proposals.append(
dict(
page_title=page_title,
+ lang=lang,
name=name,
status=status,
definition=definition,
diff --git a/requirements.txt b/requirements.txt
index cca1bd1..d58a4d3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,2 +1,3 @@
mwparserfromhell==0.6.4
pywikiapi==4.3.0
+requests==2.25.1
diff --git a/script.js b/script.js
index 664985c..1301379 100644
--- a/script.js
+++ b/script.js
@@ -63,7 +63,11 @@ function display(proposals) {
const link = newEl('a', proposal.name || proposal.page_title);
link.href = 'https://wiki.openstreetmap.org/wiki/' + proposal.page_title.replaceAll(' ', '_');
- row.appendChild(newEl('td', link));
+
+ const nameCell = newEl('td', link);
+ if (proposal.lang)
+ nameCell.appendChild(document.createTextNode(` (${proposal.lang})`));
+ row.appendChild(nameCell);
row.appendChild(newEl('td', proposal.authors));
tbody.appendChild(row);