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
85 def sidebar_classic_pagination(pages, page_param)
86 max_width_for_default_padding = 35
89 pagination_items(pages, {}).each do |body|
90 width += 2 # padding width
93 link_classes = ["page-link", { "px-1" => width > max_width_for_default_padding }]
95 tag.ul :class => "pagination pagination-sm mb-1 ms-auto" do
96 pagination_items(pages, {}).each do |body, n|
97 linked = !(n.is_a? String)
99 link_to body, url_for(page_param => n), :class => link_classes
101 tag.span body, :class => link_classes
103 concat tag.li link, :class => ["page-item", { n => !linked }]
110 ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
112 def icon_tags(object)
113 object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
116 def name_locales(object)
117 object.tags.keys.map { |k| Regexp.last_match(1) if k =~ /^name:(.*)$/ }.flatten