Fixup some string escaping issues in the data browser

This commit is contained in:
Tom Hughes 2011-09-30 14:30:59 +01:00
parent 3f9fdb122c
commit 607d23f6d6
8 changed files with 20 additions and 15 deletions

View file

@ -4,7 +4,12 @@ module BrowseHelper
end end
def printable_name(object, version=false) def printable_name(object, version=false)
name = t 'printable_name.with_id', :id => object.id.to_s if object.id.is_a?(Array)
id = object.id[0]
else
id = object.id
end
name = t 'printable_name.with_id', :id => id.to_s
if version if version
name = t 'printable_name.with_version', :id => name, :version => object.version.to_s name = t 'printable_name.with_version', :id => name, :version => object.version.to_s
end end

View file

@ -53,7 +53,7 @@
<td> <td>
<table cellpadding="0"> <table cellpadding="0">
<% @nodes.each do |node| %> <% @nodes.each do |node| %>
<tr><td><%= link_to h(printable_name(node, true)), { :action => "node", :id => node.id.to_s }, :class => link_class('node', node), :title => link_title(node) %></td></tr> <tr><td><%= link_to h(printable_name(node, true)), { :action => "node", :id => node.node_id.to_s }, :class => link_class('node', node), :title => link_title(node) %></td></tr>
<% end %> <% end %>
</table> </table>
</td> </td>
@ -67,7 +67,7 @@
<td> <td>
<table cellpadding="0"> <table cellpadding="0">
<% @ways.each do |way| %> <% @ways.each do |way| %>
<tr><td><%= link_to h(printable_name(way, true)), { :action => "way", :id => way.id.to_s }, :class => link_class('way', way), :title => link_title(way) %></td></tr> <tr><td><%= link_to h(printable_name(way, true)), { :action => "way", :id => way.way_id.to_s }, :class => link_class('way', way), :title => link_title(way) %></td></tr>
<% end %> <% end %>
<%= <%=
#render :partial => "containing_relation", :collection => changeset_details.containing_relation_members #render :partial => "containing_relation", :collection => changeset_details.containing_relation_members
@ -84,7 +84,7 @@
<td> <td>
<table cellpadding="0"> <table cellpadding="0">
<% @relations.each do |relation| %> <% @relations.each do |relation| %>
<tr><td><%= link_to h(printable_name(relation, true)), { :action => "relation", :id => relation.id.to_s }, :class => link_class('relation', relation), :title => link_title(relation) %></td></tr> <tr><td><%= link_to h(printable_name(relation, true)), { :action => "relation", :id => relation.relation_id.to_s }, :class => link_class('relation', relation), :title => link_title(relation) %></td></tr>
<% end %> <% end %>
</table> </table>
</td> </td>

View file

@ -3,9 +3,9 @@
linked_name = link_to h(printable_name(containing_relation.relation)), :action => "relation", :id => containing_relation.relation.id.to_s linked_name = link_to h(printable_name(containing_relation.relation)), :action => "relation", :id => containing_relation.relation.id.to_s
if containing_relation.member_role.blank? if containing_relation.member_role.blank?
t 'browse.containing_relation.entry', :relation_name => linked_name raw t 'browse.containing_relation.entry', :relation_name => linked_name
else else
t 'browse.containing_relation.entry_role', :relation_name => linked_name, :relation_role => h(containing_relation.member_role) raw t 'browse.containing_relation.entry_role', :relation_name => linked_name, :relation_role => h(containing_relation.member_role)
end end
%></td> %></td>
</tr> </tr>

View file

@ -4,7 +4,7 @@
<tr> <tr>
<th><%= t 'browse.node_details.coordinates' %></th> <th><%= t 'browse.node_details.coordinates' %></th>
<td><div class="geo"><%= link_to ("<span class='latitude'>#{number_with_delimiter(node_details.lat)}</span>, <span class='longitude'>#{number_with_delimiter(node_details.lon)}</span>"), {:controller => 'site', :action => 'index', :lat => h(node_details.lat), :lon => h(node_details.lon), :zoom => "18"} %></div></td> <td><div class="geo"><%= link_to(content_tag(:span, number_with_delimiter(node_details.lat), :class => "latitude") + ", " + content_tag(:span, number_with_delimiter(node_details.lon), :class => "longitude"), {:controller => 'site', :action => 'index', :lat => h(node_details.lat), :lon => h(node_details.lon), :zoom => "18"}) %></div></td>
</tr> </tr>
<% unless node_details.ways.empty? and node_details.containing_relation_members.empty? %> <% unless node_details.ways.empty? and node_details.containing_relation_members.empty? %>

View file

@ -6,9 +6,9 @@
<tr> <tr>
<td class="<%= member_class %>"><%= <td class="<%= member_class %>"><%=
if relation_member.member_role.blank? if relation_member.member_role.blank?
t'browse.relation_member.entry', :type => type_str, :name => linked_name raw t'browse.relation_member.entry', :type => type_str, :name => linked_name
else else
t'browse.relation_member.entry_role', :type => type_str, :name => linked_name, :role => h(relation_member.member_role) raw t'browse.relation_member.entry_role', :type => type_str, :name => linked_name, :role => h(relation_member.member_role)
end end
%></td> %></td>
</tr> </tr>

View file

@ -12,7 +12,7 @@
<%= 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 h(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 == way_details.id } %> <% related_ways = wn.node.ways.reject { |w| w.id == way_details.id } %>
<% if related_ways.size > 0 then %> <% if related_ways.size > 0 then %>
(<%= t 'browse.way_details.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_details.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 %>)
<% end %> <% end %>
</td></tr> </td></tr>
<% end %> <% end %>

View file

@ -10,7 +10,7 @@
<%= render :partial => "map", :object => @node %> <%= render :partial => "map", :object => @node %>
<%= render :partial => "node_details", :object => @node %> <%= render :partial => "node_details", :object => @node %>
<hr /> <hr />
<%= t'browse.node.download', :download_xml_link => link_to(t('browse.node.download_xml'), :controller => "old_node", :action => "version", :version => @node.version), <%= raw t'browse.node.download', :download_xml_link => link_to(t('browse.node.download_xml'), :controller => "old_node", :action => "version", :version => @node.version),
:view_history_link => link_to(t('browse.node.view_history'), :action => "node_history"), :view_history_link => link_to(t('browse.node.view_history'), :action => "node_history"),
:edit_link => link_to(t('browse.node.edit'), :controller => "site", :action => "edit", :lat => @node.lat, :lon => @node.lon, :zoom => 18, :node => @node.id) :edit_link => link_to(t('browse.node.edit'), :controller => "site", :action => "edit", :lat => @node.lat, :lon => @node.lon, :zoom => 18, :node => @node.id)
%> %>

View file

@ -10,5 +10,5 @@
<%= render :partial => "map", :object => @relation %> <%= render :partial => "map", :object => @relation %>
<%= render :partial => "relation_details", :object => @relation %> <%= render :partial => "relation_details", :object => @relation %>
<hr /> <hr />
<%= t'browse.relation.download', :download_xml_link => link_to(t('browse.relation.download_xml'), :controller => "relation", :action => "read"), <%= raw t'browse.relation.download', :download_xml_link => link_to(t('browse.relation.download_xml'), :controller => "relation", :action => "read"),
:view_history_link => link_to(t('browse.relation.view_history'), :action => "relation_history") %> :view_history_link => link_to(t('browse.relation.view_history'), :action => "relation_history") %>