2 def link_to_page(page, page_param)
3 return link_to(page, page_param => page)
6 def printable_name(object, version=false)
7 name = t 'printable_name.with_id', :id => object.id.to_s
9 name = t 'printable_name.with_version', :id => name, :version => object.version.to_s
11 if object.tags.include? "name:#{I18n.locale}"
12 name = t 'printable_name.with_name', :name => object.tags["name:#{I18n.locale}"].to_s, :id => name
13 elsif object.tags.include? 'name'
14 name = t 'printable_name.with_name', :name => object.tags['name'].to_s, :id => name
19 def css_class(type, object)
20 css = type + " " + h(object.tags.find_all { |k,v| k == "aeroway" || k == "amenity" || k == "barrier" || k == "building" || k == "highway" || k == "landuse" || k == "leisure" || k == "man_made" || k == "natural" || k == "railway" || k == "shop" || k == "tourism" || k == "waterway" }.join(' '))
24 def link_title(object)
25 title = h(object.tags.map { |k,v| k + '=' + v }.to_sentence)
30 if url = wiki_link("key", key)
31 link_to h(key), url, :title => t('browse.tag_details.wiki_link.key', :key => key)
37 def format_value(key, value)
38 if wp = wikipedia_link(key, value)
39 link_to h(wp[:title]), wp[:url], :title => t('browse.tag_details.wikipedia_link', :page => wp[:title])
40 elsif url = wiki_link("tag", "#{key}=#{value}")
41 link_to h(value), url, :title => t('browse.tag_details.wiki_link.tag', :key => key, :value => value)
49 def wiki_link(type, lookup)
50 locale = I18n.locale.to_s
52 if page = WIKI_PAGES[locale][type][lookup] rescue nil
53 url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
54 elsif page = WIKI_PAGES["en"][type][lookup] rescue nil
55 url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
61 def wikipedia_link(key, value)
62 # Some k/v's are wikipedia=http://en.wikipedia.org/wiki/Full%20URL
63 return nil if value =~ /^http:\/\//
66 # This regex should match Wikipedia language codes, everything
67 # from de to zh-classical
68 if value =~ /^([a-z-]{2,12}):(.+)$/
69 # Value is <lang>:<title> so split it up
73 # Value is <title> so default to English Wikipedia
76 elsif key =~ /^wikipedia:(\S+)$/
77 # Language is in the key, so assume value is a simple title
80 # Not a wikipedia key!
85 :url => "http://#{lang}.wikipedia.org/wiki/#{value}?uselang=#{I18n.locale}",