2 def link_to_page(page, page_param)
3 return link_to(page, page_param => page)
6 def printable_name(object, version=false)
7 if object.id.is_a?(Array)
12 name = t 'printable_name.with_id', :id => id.to_s
14 name = t 'printable_name.with_version', :id => name, :version => object.version.to_s
17 # don't look at object tags if redacted, so as to avoid giving
18 # away redacted version tag information.
19 unless object.redacted?
20 if object.tags.include? "name:#{I18n.locale}"
21 name = t 'printable_name.with_name', :name => object.tags["name:#{I18n.locale}"].to_s, :id => name
22 elsif object.tags.include? 'name'
23 name = t 'printable_name.with_name', :name => object.tags['name'].to_s, :id => name
30 def link_class(type, object)
34 type + " " + h(icon_tags(object).join(' ')) + (object.visible == false ? ' deleted' : '')
38 def link_title(object)
42 h(icon_tags(object).map { |k,v| k + '=' + v }.to_sentence)
47 if url = wiki_link("key", key)
48 link_to h(key), url, :title => t('browse.tag_details.wiki_link.key', :key => key)
54 def format_value(key, value)
55 if wp = wikipedia_link(key, value)
56 link_to h(wp[:title]), wp[:url], :title => t('browse.tag_details.wikipedia_link', :page => wp[:title])
57 elsif url = wiki_link("tag", "#{key}=#{value}")
58 link_to h(value), url, :title => t('browse.tag_details.wiki_link.tag', :key => key, :value => value)
67 "aeroway", "amenity", "barrier", "building", "highway", "historic", "landuse",
68 "leisure", "man_made", "natural", "railway", "shop", "tourism", "waterway"
72 object.tags.find_all { |k,v| ICON_TAGS.include? k }
75 def wiki_link(type, lookup)
76 locale = I18n.locale.to_s
78 # update-wiki-pages does s/ /_/g on keys before saving them, we
79 # have to replace spaces with underscore so we'll link
80 # e.g. `source=Isle of Man Government aerial imagery (2001)' to
82 lookup_us = lookup.tr(" ", "_")
84 if page = WIKI_PAGES[locale][type][lookup_us] rescue nil
85 url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
86 elsif page = WIKI_PAGES["en"][type][lookup_us] rescue nil
87 url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
93 def wikipedia_link(key, value)
94 # Some k/v's are wikipedia=http://en.wikipedia.org/wiki/Full%20URL
95 return nil if value =~ /^https?:\/\//
98 # This regex should match Wikipedia language codes, everything
99 # from de to zh-classical
100 if value =~ /^([a-z-]{2,12}):(.+)$/
101 # Value is <lang>:<title> so split it up
105 # Value is <title> so default to English Wikipedia
108 elsif key =~ /^wikipedia:(\S+)$/
109 # Language is in the key, so assume value is a simple title
112 # Not a wikipedia key!
117 :url => "http://#{lang}.wikipedia.org/wiki/#{value}?uselang=#{I18n.locale}",