2 def element_single_current_link(type, object, url)
3 link_to url, { :class => element_class(type, object), :title => element_title(object), :rel => (link_follow(object) if type == "node") } do
4 element_strikethrough object do
10 def element_list_item(type, object, &block)
11 tag.li :class => element_class(type, object), :title => element_title(object) do
12 element_strikethrough object, &block
16 def printable_name(object, version: false)
17 id = if object.id.is_a?(Array)
22 name = t "printable_name.with_id", :id => id.to_s
23 name = t "printable_name.with_version", :id => name, :version => object.version.to_s if version
25 # don't look at object tags if redacted, so as to avoid giving
26 # away redacted version tag information.
27 unless object.redacted?
28 available_locales = Locale.list(name_locales(object))
30 locale = available_locales.preferred(preferred_languages, :default => nil)
32 if object.tags.include? "name:#{locale}"
33 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name:#{locale}"].to_s), :id => tag.bdi(name)
34 elsif object.tags.include? "name"
35 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name"].to_s), :id => tag.bdi(name)
36 elsif object.tags.include? "ref"
37 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["ref"].to_s), :id => tag.bdi(name)
44 def element_strikethrough(object, &block)
45 if object.redacted? || !object.visible?
52 def element_class(type, object)
54 classes += icon_tags(object).flatten.map { |t| h(t) } unless object.redacted?
58 def element_title(object)
62 h(icon_tags(object).map { |k, v| "#{k}=#{v}" }.to_sentence)
66 def link_follow(object)
67 "nofollow" if object.tags.empty?
70 def type_and_paginated_count(type, pages)
71 if pages.page_count == 1
72 t "browse.changeset.#{type}",
73 :count => pages.item_count
75 t "browse.changeset.#{type}_paginated",
76 :x => pages.current_page.first_item,
77 :y => pages.current_page.last_item,
78 :count => pages.item_count
84 ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
87 object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
90 def name_locales(object)
91 object.tags.keys.map { |k| Regexp.last_match(1) if k =~ /^name:(.*)$/ }.flatten