+ h(icon_tags(object).map { |k,v| k + '=' + v }.to_sentence)
+ end
+ end
+
+ def format_key(key)
+ if url = wiki_link("key", key)
+ link_to h(key), url, :title => t('browse.tag_details.wiki_link.key', :key => key)
+ else
+ h(key)
+ end
+ end
+
+ def format_value(key, value)
+ if wp = wikipedia_link(key, value)
+ link_to h(wp[:title]), wp[:url], :title => t('browse.tag_details.wikipedia_link', :page => wp[:title])
+ elsif wdt = wikidata_link(key, value)
+ link_to h(wdt[:title]), wdt[:url], :title => t('browse.tag_details.wikidata_link', :page => wdt[:title])
+ 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 url = telephone_link(key, value)
+ link_to h(value), url, :title => t('browse.tag_details.telephone_link', :phone_number => value)
+ else
+ linkify h(value)
+ end
+ end
+
+ def type_and_paginated_count(type, pages)
+ if pages.page_count == 1
+ t "browse.changeset.#{type}",
+ :count => pages.item_count
+ else
+ t "browse.changeset.#{type}_paginated",
+ :x => pages.current_page.first_item,
+ :y => pages.current_page.last_item,
+ :count => pages.item_count
+ end
+ end
+
+private
+
+ ICON_TAGS = [
+ "aeroway", "amenity", "barrier", "building", "highway", "historic", "landuse",
+ "leisure", "man_made", "natural", "railway", "shop", "tourism", "waterway"
+ ]
+
+ def icon_tags(object)
+ object.tags.find_all { |k,v| ICON_TAGS.include? k }.sort
+ end
+
+ def wiki_link(type, lookup)
+ locale = I18n.locale.to_s
+
+ # 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_us] rescue nil
+ url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"