From 4806913e18c9e860ea834e87e73eb5b083dd2efd Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 17 Jun 2010 13:33:01 +0000 Subject: [PATCH] browse_helper: Correctly link to wiki pages whose keys or values contain spaces The update-wiki-pages script normalizes " " to "_" (since MediaWiki does it by design), but I didn't normalize it back in the browse_helper. Consequently objects with tags like "source=Isle of Man Government aerial imagery (2001)" were never linked to the wiki correctly. --- app/helpers/browse_helper.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 090d1e9c3..a41b39a3d 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -56,9 +56,15 @@ private def wiki_link(type, lookup) locale = I18n.locale.to_s - if page = WIKI_PAGES[locale][type][lookup] rescue nil + # update-wiki-pages does s/ /_/g on keys before saving them, we + # have to replace spaces with underscore so we'll link + # e.g. `source=Isle of Man Government aerial imagery (2001)' to + # the correct page. + lookup_us = lookup.tr(" ", "_") + + if page = WIKI_PAGES[locale][type][lookup_us] rescue nil url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}" - elsif page = WIKI_PAGES["en"][type][lookup] rescue nil + elsif page = WIKI_PAGES["en"][type][lookup_us] rescue nil url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}" end -- 2.39.5