]> git.openstreetmap.org Git - rails.git/blobdiff - app/helpers/browse_tags_helper.rb
Use the mail_to method to construct a mailto link for browse tag values
[rails.git] / app / helpers / browse_tags_helper.rb
index 1466649146ea3fba36a59f874442c68b778a433f..0784d03caefabca670e501f9ee0160373fcc0869 100644 (file)
@@ -22,7 +22,7 @@ module BrowseTagsHelper
     elsif url = wiki_link("tag", "#{key}=#{value}")
       link_to h(value), url, :title => t("browse.tag_details.wiki_link.tag", :key => key, :value => value)
     elsif email = email_link(key, value)
-      link_to(h(email[:email]), email[:url], :title => t("browse.tag_details.email_link", :email => email[:email]))
+      mail_to(email, :title => t("browse.tag_details.email_link", :email => email))
     elsif phones = telephone_links(key, value)
       # similarly, telephone_links() returns an array of phone numbers
       phones = phones.map do |p|
@@ -47,11 +47,10 @@ module BrowseTagsHelper
     # the correct page.
     lookup_us = lookup.tr(" ", "_")
 
-    if page = WIKI_PAGES.dig(locale, type, lookup_us)
-      url = "https://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
-    elsif page = WIKI_PAGES.dig("en", type, lookup_us)
-      url = "https://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
-    end
+    page = WIKI_PAGES.dig(locale, type, lookup_us) ||
+           WIKI_PAGES.dig("en", type, lookup_us)
+
+    url = "https://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}" if page
 
     url
   end
@@ -85,7 +84,7 @@ module BrowseTagsHelper
       # Must break it up to correctly build the url
       value = Regexp.last_match(1)
       section = "##{Regexp.last_match(2)}"
-      encoded_section = "##{CGI.escape(Regexp.last_match(2).gsub(/ +/, '_')).tr('%', '.')}"
+      encoded_section = "##{CGI.escape(Regexp.last_match(2).gsub(/ +/, '_'))}"
     else
       section = ""
       encoded_section = ""
@@ -137,10 +136,7 @@ module BrowseTagsHelper
     # remove any leading and trailing whitespace
     email = value.strip
 
-    if email.match?(URI::MailTo::EMAIL_REGEXP)
-      # add 'mailto:'' prefix
-      return { :email => email, :url => "mailto:#{email}" }
-    end
+    return email if email.match?(URI::MailTo::EMAIL_REGEXP)
 
     nil
   end