Turn wikimedia_commons values into links
This turns the value of the 'wikimedia_commons' tag into a link to the respective page on commons.wikimedia.org (if it is a 'File:' or 'Category:' item) by enhancing the browse tags helper. See [1] for the tag description. [1] http://wiki.openstreetmap.org/wiki/Key:wikimedia_commons
This commit is contained in:
parent
1bf2a540d0
commit
c3300d8c93
3 changed files with 44 additions and 0 deletions
|
@ -17,6 +17,8 @@ module BrowseTagsHelper
|
|||
link_to(w[:title], w[:url], :title => t("browse.tag_details.wikidata_link", :page => w[:title].strip))
|
||||
end
|
||||
safe_join(wdt, ";")
|
||||
elsif wmc = wikimedia_commons_link(key, value)
|
||||
link_to h(wmc[:title]), wmc[:url], :title => t("browse.tag_details.wikimedia_commons_link", :page => wmc[: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 phones = telephone_links(key, value)
|
||||
|
@ -111,6 +113,16 @@ module BrowseTagsHelper
|
|||
nil
|
||||
end
|
||||
|
||||
def wikimedia_commons_link(key, value)
|
||||
if key == "wikimedia_commons" && value =~ /^(?:file|category):/i
|
||||
return {
|
||||
:url => "//commons.wikimedia.org/wiki/#{value}?uselang=#{I18n.locale}",
|
||||
:title => value
|
||||
}
|
||||
end
|
||||
nil
|
||||
end
|
||||
|
||||
def telephone_links(_key, value)
|
||||
# Does it look like a global phone number? eg "+1 (234) 567-8901 "
|
||||
# or a list of alternate numbers separated by ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue