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
5 printable_element_name object
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_element_name(object)
17 id = if object.id.is_a?(Array)
24 # don't look at object tags if redacted, so as to avoid giving
25 # away redacted version tag information.
26 unless object.redacted?
27 available_locales = Locale.list(name_locales(object))
29 locale = available_locales.preferred(preferred_languages, :default => nil)
31 if object.tags.include? "name:#{locale}"
32 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name:#{locale}"].to_s), :id => tag.bdi(name)
33 elsif object.tags.include? "name"
34 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["name"].to_s), :id => tag.bdi(name)
35 elsif object.tags.include? "ref"
36 name = t "printable_name.with_name_html", :name => tag.bdi(object.tags["ref"].to_s), :id => tag.bdi(name)
43 def printable_element_version(object)
44 t "printable_name.version", :version => object.version
47 def element_strikethrough(object, &block)
48 if object.redacted? || !object.visible?
55 def element_class(type, object)
57 classes += icon_tags(object).flatten.map { |t| h(t) } unless object.redacted?
61 def element_title(object)
65 h(icon_tags(object).map { |k, v| "#{k}=#{v}" }.to_sentence)
69 def link_follow(object)
70 "nofollow" if object.tags.empty?
73 def type_and_paginated_count(type, pages)
74 if pages.page_count == 1
75 t "browse.changeset.#{type}",
76 :count => pages.item_count
78 t "browse.changeset.#{type}_paginated",
79 :x => pages.current_page.first_item,
80 :y => pages.current_page.last_item,
81 :count => pages.item_count
87 ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
90 object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
93 def name_locales(object)
94 object.tags.keys.map { |k| Regexp.last_match(1) if k =~ /^name:(.*)$/ }.flatten