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
67 def sidebar_classic_pagination(pages, page_param)
68 max_width_for_default_padding = 35
71 pagination_items(pages, {}).each do |body|
72 width += 2 # padding width
75 link_classes = ["page-link", { "px-1" => width > max_width_for_default_padding }]
77 tag.ul :class => "pagination pagination-sm mb-1 ms-auto" do
78 pagination_items(pages, {}).each do |body, n|
79 linked = !(n.is_a? String)
81 link_to body, url_for(page_param => n), :class => link_classes
83 tag.span body, :class => link_classes
85 concat tag.li link, :class => ["page-item", { n => !linked }]
92 ICON_TAGS = %w[aeroway amenity barrier building highway historic landuse leisure man_made natural railway shop tourism waterway].freeze
95 object.tags.find_all { |k, _v| ICON_TAGS.include? k }.sort
98 def name_locales(object)
99 object.tags.keys.map { |k| Regexp.last_match(1) if k =~ /^name:(.*)$/ }.flatten