fix(place): preserve extratags.wikipedia format when has_kiwix_wiki enabled

When has_kiwix_wiki is enabled, skip rewriting extratags.wikipedia to
a Kiwix content URL. The wiki_url field already provides the correct
local Kiwix viewer link for the WikiSummarySection.

This preserves the original OSM format (e.g. "en:Title") in
extratags.wikipedia so the frontend LINKS section can properly build
wikipedia.org URLs.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-04-29 18:53:03 +00:00
commit bb7d0169e0

View file

@ -290,6 +290,11 @@ def _enrich_wiki_links(result):
""" """
Rewrite wiki-related extratags to local Kiwix URLs where available. Rewrite wiki-related extratags to local Kiwix URLs where available.
Falls back to public URLs. Only runs when has_wiki_rewriting is enabled. Falls back to public URLs. Only runs when has_wiki_rewriting is enabled.
Note: When has_kiwix_wiki is enabled, we skip rewriting 'wikipedia' since
the wiki_index enrichment provides a proper wiki_url field. This keeps
extratags.wikipedia in the original OSM format for frontend link builders.
Returns the (possibly enriched) result dict. Returns the (possibly enriched) result dict.
""" """
try: try:
@ -298,6 +303,8 @@ def _enrich_wiki_links(result):
features = deploy_config.get('features', {}) features = deploy_config.get('features', {})
if not features.get('has_wiki_rewriting', False): if not features.get('has_wiki_rewriting', False):
return result return result
# When has_kiwix_wiki is enabled, skip wikipedia rewriting (wiki_url handles it)
has_kiwix_wiki = features.get('has_kiwix_wiki', False)
except Exception: except Exception:
return result return result
@ -313,6 +320,9 @@ def _enrich_wiki_links(result):
rewrites = {} rewrites = {}
for tag in _WIKI_TAGS: for tag in _WIKI_TAGS:
# Skip wikipedia when has_kiwix_wiki is enabled (wiki_url provides the local link)
if tag == 'wikipedia' and has_kiwix_wiki:
continue
value = extratags.get(tag) value = extratags.get(tag)
if not value: if not value:
continue continue