From: Tom Hughes Date: Sun, 18 May 2014 16:16:36 +0000 (+0100) Subject: Isolate object names from the database with a tag X-Git-Tag: live~5016 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/5da273027f53cf4413aa385ea41ffacee5acf039 Isolate object names from the database with a tag Fixes #743 --- diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index b192a63d5..7562535c1 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -14,13 +14,13 @@ module BrowseHelper # away redacted version tag information. unless object.redacted? if object.tags.include? "name:#{I18n.locale}" - name = t 'printable_name.with_name', :name => object.tags["name:#{I18n.locale}"].to_s, :id => name + name = t 'printable_name.with_name_html', :name => content_tag(:bdi, object.tags["name:#{I18n.locale}"].to_s ), :id => name elsif object.tags.include? 'name' - name = t 'printable_name.with_name', :name => object.tags['name'].to_s, :id => name + name = t 'printable_name.with_name_html', :name => content_tag(:bdi, object.tags['name'].to_s ), :id => name end end - return name + name end def link_class(type, object) diff --git a/app/views/browse/_node.html.erb b/app/views/browse/_node.html.erb index 581c49b09..873360bb2 100644 --- a/app/views/browse/_node.html.erb +++ b/app/views/browse/_node.html.erb @@ -14,7 +14,7 @@

<%= t 'browse.part_of' %>

    <% node.ways.uniq.each do |way| %> -
  • <%= link_to h(printable_name(way)), { :action => "way", :id => way.id.to_s }, :class => link_class('way', way), :title => link_title(way) %>
  • +
  • <%= link_to printable_name(way), { :action => "way", :id => way.id.to_s }, :class => link_class('way', way), :title => link_title(way) %>
  • <% end %> <%= render :partial => "containing_relation", :collection => node.containing_relation_members.uniq %>
diff --git a/app/views/browse/_relation_member.html.erb b/app/views/browse/_relation_member.html.erb index 2673df3c3..0d17de349 100644 --- a/app/views/browse/_relation_member.html.erb +++ b/app/views/browse/_relation_member.html.erb @@ -1,6 +1,6 @@ <% member_class = link_class(relation_member.member_type.downcase, relation_member.member) - linked_name = link_to h(printable_name(relation_member.member)), { :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, :title => link_title(relation_member.member) + linked_name = link_to printable_name(relation_member.member), { :action => relation_member.member_type.downcase, :id => relation_member.member_id.to_s }, :title => link_title(relation_member.member) type_str = t'browse.relation_member.type.' + relation_member.member_type.downcase %>
  • <%= @@ -9,4 +9,4 @@ else raw t'browse.relation_member.entry_role', :type => type_str, :name => linked_name, :role => h(relation_member.member_role) end - %>
  • \ No newline at end of file + %> diff --git a/app/views/browse/_way.html.erb b/app/views/browse/_way.html.erb index aff405dde..b1dffb9ef 100644 --- a/app/views/browse/_way.html.erb +++ b/app/views/browse/_way.html.erb @@ -15,10 +15,10 @@
      <% way.way_nodes.each do |wn| %>
    • - <%= link_to h(printable_name(wn.node)), { :action => "node", :id => wn.node_id.to_s }, :class => link_class('node', wn.node), :title => link_title(wn.node) %> + <%= link_to printable_name(wn.node), { :action => "node", :id => wn.node_id.to_s }, :class => link_class('node', wn.node), :title => link_title(wn.node) %> <% related_ways = wn.node.ways.reject { |w| w.id == wn.way_id } %> <% if related_ways.size > 0 then %> - (<%= raw t 'browse.way.also_part_of', :count => related_ways.size, :related_ways => related_ways.map { |w| link_to(h(printable_name(w)), { :action => "way", :id => w.id.to_s }, :class => link_class('way', w), :title => link_title(w) ) }.to_sentence %>) + (<%= raw t 'browse.way.also_part_of', :count => related_ways.size, :related_ways => related_ways.map { |w| link_to(printable_name(w), { :action => "way", :id => w.id.to_s }, :class => link_class('way', w), :title => link_title(w) ) }.to_sentence %>) <% end %>
    • <% end %> diff --git a/app/views/browse/changeset.html.erb b/app/views/browse/changeset.html.erb index 31799f0e9..84d85df3c 100644 --- a/app/views/browse/changeset.html.erb +++ b/app/views/browse/changeset.html.erb @@ -18,7 +18,7 @@
        <% @ways.each do |way| %> -
      • <%= link_to h(printable_name(way, true)), { :action => "way", :id => way.way_id.to_s }, :class => link_class('way', way), :title => link_title(way) %>
      • +
      • <%= link_to printable_name(way, true), { :action => "way", :id => way.way_id.to_s }, :class => link_class('way', way), :title => link_title(way) %>
      • <% end %>
      <% end %> @@ -30,7 +30,7 @@
        <% @relations.each do |relation| %> -
      • <%= link_to h(printable_name(relation, true)), { :action => "relation", :id => relation.relation_id.to_s }, :class => link_class('relation', relation), :title => link_title(relation) %>
      • +
      • <%= link_to printable_name(relation, true), { :action => "relation", :id => relation.relation_id.to_s }, :class => link_class('relation', relation), :title => link_title(relation) %>
      • <% end %>
      <% end %> @@ -42,7 +42,7 @@
        <% @nodes.each do |node| %> -
      • <%= link_to h(printable_name(node, true)), { :action => "node", :id => node.node_id.to_s }, :class => link_class('node', node), :title => link_title(node) %>
      • +
      • <%= link_to printable_name(node, true), { :action => "node", :id => node.node_id.to_s }, :class => link_class('node', node), :title => link_title(node) %>
      • <% end %>
      <% end %> diff --git a/app/views/browse/feature.html.erb b/app/views/browse/feature.html.erb index 1e0f118d8..38657f4d1 100644 --- a/app/views/browse/feature.html.erb +++ b/app/views/browse/feature.html.erb @@ -2,7 +2,7 @@

      - <%= t("browse.#{@type}.title", :name => printable_name(@feature)) %> + <%= raw t("browse.#{@type}.title", :name => printable_name(@feature)) %>

      <%= render :partial => @type, :object => @feature %> diff --git a/app/views/browse/history.html.erb b/app/views/browse/history.html.erb index fa483bfb0..5f5dd4db3 100644 --- a/app/views/browse/history.html.erb +++ b/app/views/browse/history.html.erb @@ -2,7 +2,7 @@

      - <%= t("browse.#{@type}.history_title", :name => printable_name(@feature)) %> + <%= raw t("browse.#{@type}.history_title", :name => printable_name(@feature)) %>

      <%= render :partial => @type, :collection => @feature.send("old_#{@type}s").reverse %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 94537c1fb..9e117e3de 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -79,7 +79,7 @@ en: printable_name: with_id: "%{id}" with_version: "%{id}, v%{version}" - with_name: "%{name} (%{id})" + with_name_html: "%{name} (%{id})" editor: default: "Default (currently %{name})" potlatch: diff --git a/test/helpers/browse_helper_test.rb b/test/helpers/browse_helper_test.rb index a48ac4df8..0abcd6df1 100644 --- a/test/helpers/browse_helper_test.rb +++ b/test/helpers/browse_helper_test.rb @@ -14,28 +14,28 @@ class BrowseHelperTest < ActionView::TestCase def test_printable_name assert_equal "17", printable_name(current_nodes(:redacted_node)) - assert_equal "Test Node (18)", printable_name(current_nodes(:node_with_name)) - assert_equal "Test Node (18)", printable_name(nodes(:node_with_name_current_version)) + assert_equal "Test Node (18)", printable_name(current_nodes(:node_with_name)) + assert_equal "Test Node (18)", printable_name(nodes(:node_with_name_current_version)) assert_equal "18", printable_name(nodes(:node_with_name_redacted_version)) - assert_equal "Test Node (18, v2)", printable_name(nodes(:node_with_name_current_version), true) + assert_equal "Test Node (18, v2)", printable_name(nodes(:node_with_name_current_version), true) assert_equal "18, v1", printable_name(nodes(:node_with_name_redacted_version), true) I18n.locale = "ru" assert_equal "17", printable_name(current_nodes(:redacted_node)) - assert_equal "проверки узла (18)", printable_name(current_nodes(:node_with_name)) - assert_equal "проверки узла (18)", printable_name(nodes(:node_with_name_current_version)) + assert_equal "проверки узла (18)", printable_name(current_nodes(:node_with_name)) + assert_equal "проверки узла (18)", printable_name(nodes(:node_with_name_current_version)) assert_equal "18", printable_name(nodes(:node_with_name_redacted_version)) - assert_equal "проверки узла (18, v2)", printable_name(nodes(:node_with_name_current_version), true) + assert_equal "проверки узла (18, v2)", printable_name(nodes(:node_with_name_current_version), true) assert_equal "18, v1", printable_name(nodes(:node_with_name_redacted_version), true) I18n.locale = "de" assert_equal "17", printable_name(current_nodes(:redacted_node)) - assert_equal "Test Node (18)", printable_name(current_nodes(:node_with_name)) - assert_equal "Test Node (18)", printable_name(nodes(:node_with_name_current_version)) + assert_equal "Test Node (18)", printable_name(current_nodes(:node_with_name)) + assert_equal "Test Node (18)", printable_name(nodes(:node_with_name_current_version)) assert_equal "18", printable_name(nodes(:node_with_name_redacted_version)) - assert_equal "Test Node (18, v2)", printable_name(nodes(:node_with_name_current_version), true) + assert_equal "Test Node (18, v2)", printable_name(nodes(:node_with_name_current_version), true) assert_equal "18, v1", printable_name(nodes(:node_with_name_redacted_version), true) end