2 def printable_name(object, version: false)
3 id = if object.id.is_a?(Array)
8 name = t "printable_name.with_id", :id => id.to_s
9 name = t "printable_name.with_version", :id => name, :version => object.version.to_s if version
11 # don't look at object tags if redacted, so as to avoid giving
12 # away redacted version tag information.
13 unless object.redacted?
14 available_locales = Locale.list(name_locales(object))
16 locale = available_locales.preferred(preferred_languages, :default => nil)
18 if object.tags.include? "name:#{locale}"
19 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name:#{locale}"].to_s), :id => tag.bdi(name)
20 elsif object.tags.include? "name"
21 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name"].to_s), :id => tag.bdi(name)
22 elsif object.tags.include? "ref"
23 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["ref"].to_s), :id => tag.bdi(name)
30 def link_class(type, object)
36 classes += icon_tags(object).flatten.map { |t| h(t) }
37 classes << "deleted" unless object.visible?
43 def link_title(object)
47 h(icon_tags(object).map { |k, v| "#{k}=#{v}" }.to_sentence)
51 def link_follow(object)
52 "nofollow" if object.tags.empty?
55 def type_and_paginated_count(type, pages)
56 if pages.page_count == 1
57 t "browse.changeset.#{type}",
58 :count => pages.item_count
60 t "browse.changeset.#{type}_paginated",
61 :x => pages.current_page.first_item,
62 :y => pages.current_page.last_item,
63 :count => pages.item_count
69 ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
72 object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
75 def name_locales(object)
76 object.tags.keys.map { |k| Regexp.last_match(1) if k =~ /^name:(.*)$/ }.flatten