Refactor browse templates
This commit is contained in:
parent
e670da54cb
commit
9dd230d0bc
15 changed files with 79 additions and 177 deletions
|
@ -8,67 +8,58 @@ class BrowseController < ApplicationController
|
|||
|
||||
def relation
|
||||
@type = "relation"
|
||||
@relation = Relation.find(params[:id])
|
||||
@next = Relation.visible.where("id > ?", @relation.id).order(:id => :asc).first
|
||||
@prev = Relation.visible.where("id < ?", @relation.id).order(:id => :desc).first
|
||||
@feature = Relation.find(params[:id])
|
||||
render 'feature'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
|
||||
def relation_history
|
||||
@type = "relation"
|
||||
@relation = Relation.find(params[:id])
|
||||
@feature = Relation.find(params[:id])
|
||||
render 'history'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
|
||||
def way
|
||||
@type = "way"
|
||||
@way = Way.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id])
|
||||
@next = Way.visible.where("id > ?", @way.id).order(:id => :asc).first
|
||||
@prev = Way.visible.where("id < ?", @way.id).order(:id => :desc).first
|
||||
@feature = Way.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id])
|
||||
render 'feature'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
|
||||
def way_history
|
||||
@type = "way"
|
||||
@way = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id])
|
||||
@feature = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id])
|
||||
render 'feature'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
def node
|
||||
@type = "node"
|
||||
@node = Node.find(params[:id])
|
||||
@next = Node.visible.where("id > ?", @node.id).order(:id => :asc).first
|
||||
@prev = Node.visible.where("id < ?", @node.id).order(:id => :desc).first
|
||||
@feature = Node.find(params[:id])
|
||||
render 'feature'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
|
||||
def node_history
|
||||
@type = "node"
|
||||
@node = Node.find(params[:id])
|
||||
@feature = Node.find(params[:id])
|
||||
render 'history'
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
||||
|
||||
def changeset
|
||||
@type = "changeset"
|
||||
|
||||
@changeset = Changeset.find(params[:id])
|
||||
@node_pages, @nodes = paginate(:old_nodes, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'node_page')
|
||||
@way_pages, @ways = paginate(:old_ways, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'way_page')
|
||||
@relation_pages, @relations = paginate(:old_relations, :conditions => {:changeset_id => @changeset.id}, :per_page => 10, :parameter => 'relation_page')
|
||||
|
||||
@next = Changeset.where("id > ?", @changeset.id).order(:id => :asc).first
|
||||
@prev = Changeset.where("id < ?", @changeset.id).order(:id => :desc).first
|
||||
|
||||
if @changeset.user.data_public?
|
||||
@next_by_user = @changeset.user.changesets.where("id > ?", @changeset.id).order(:id => :asc).first
|
||||
@prev_by_user = @changeset.user.changesets.where("id < ?", @changeset.id).order(:id => :desc).first
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
@ -76,8 +67,6 @@ class BrowseController < ApplicationController
|
|||
def note
|
||||
@type = "note"
|
||||
@note = Note.find(params[:id])
|
||||
@next = Note.visible.where("id > ?", @note.id).order(:id => :asc).first
|
||||
@prev = Note.visible.where("id < ?", @note.id).order(:id => :desc).first
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
module TitleHelper
|
||||
def set_title(title = false)
|
||||
if title
|
||||
title = t('layouts.project_name.title') + ' | ' + title
|
||||
title = t('layouts.project_name.title') + ' | ' + title
|
||||
else
|
||||
title = t('layouts.project_name.title')
|
||||
title = t('layouts.project_name.title')
|
||||
end
|
||||
response.headers["X-Page-Title"] = title
|
||||
@title = title
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
<div class='browse-section'>
|
||||
<% if node_details.redacted? %>
|
||||
<% if node.redacted? %>
|
||||
<%= t 'browse.redacted.message_html',
|
||||
:type => t('browse.redacted.type.node'),
|
||||
:version => node_details.version,
|
||||
:version => node.version,
|
||||
:redaction_link => link_to(t('browse.redacted.redaction',
|
||||
:id => node_details.redaction.id), node_details.redaction) %>
|
||||
:id => node.redaction.id), node.redaction) %>
|
||||
<% else %>
|
||||
<%= render :partial => "common_details", :object => node_details %>
|
||||
<%= render :partial => "common_details", :object => node %>
|
||||
|
||||
<% unless node_details.ways.empty? and node_details.containing_relation_members.empty? %>
|
||||
<% unless node.ways.empty? and node.containing_relation_members.empty? %>
|
||||
<h4><%= t 'browse.part_of' %></h4>
|
||||
<ul>
|
||||
<% node_details.ways.each do |way| %>
|
||||
<% node.ways.each do |way| %>
|
||||
<li><%= link_to h(printable_name(way)), { :action => "way", :id => way.id.to_s }, :class => link_class('way', way), :title => link_title(way) %></li>
|
||||
<% end %>
|
||||
<%= render :partial => "containing_relation", :collection => node_details.containing_relation_members %>
|
||||
<%= render :partial => "containing_relation", :collection => node.containing_relation_members %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -1,21 +1,21 @@
|
|||
<div class='browse-section'>
|
||||
<% if relation_details.redacted? %>
|
||||
<% if relation.redacted? %>
|
||||
<%= t 'browse.redacted.message_html',
|
||||
:type => t('browse.redacted.type.relation'),
|
||||
:version => relation_details.version,
|
||||
:version => relation.version,
|
||||
:redaction_link => link_to(t('browse.redacted.redaction',
|
||||
:id => relation_details.redaction.id), relation_details.redaction) %><
|
||||
:id => relation.redaction.id), relation.redaction) %><
|
||||
<% else %>
|
||||
<%= render :partial => "common_details", :object => relation_details %>
|
||||
<%= render :partial => "common_details", :object => relation %>
|
||||
|
||||
<% unless relation_details.relation_members.empty? %>
|
||||
<% unless relation.relation_members.empty? %>
|
||||
<h4><%= t'browse.relation.members' %></h4>
|
||||
<ul><%= render :partial => "relation_member", :collection => relation_details.relation_members %></ul>
|
||||
<ul><%= render :partial => "relation_member", :collection => relation.relation_members %></ul>
|
||||
<% end %>
|
||||
|
||||
<% unless relation_details.containing_relation_members.empty? %>
|
||||
<% unless relation.containing_relation_members.empty? %>
|
||||
<h4><%= t'browse.part_of' %></h4>
|
||||
<ul><%= render :partial => "containing_relation", :collection => relation_details.containing_relation_members %></ul>
|
||||
<ul><%= render :partial => "containing_relation", :collection => relation.containing_relation_members %></ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
|
@ -1,17 +1,17 @@
|
|||
<div class='browse-section'>
|
||||
<% if way_details.redacted? %>
|
||||
<% if way.redacted? %>
|
||||
<%= t 'browse.redacted.message_html',
|
||||
:type => t('browse.redacted.type.way'),
|
||||
:version => way_details.version,
|
||||
:version => way.version,
|
||||
:redaction_link => link_to(t('browse.redacted.redaction',
|
||||
:id => way_details.redaction.id), way_details.redaction) %>
|
||||
:id => way.redaction.id), way.redaction) %>
|
||||
<% else %>
|
||||
<%= render :partial => "common_details", :object => way_details %>
|
||||
<%= render :partial => "common_details", :object => way %>
|
||||
|
||||
<% unless way_details.way_nodes.empty? %>
|
||||
<% unless way.way_nodes.empty? %>
|
||||
<h4><%= t'browse.way.nodes' %></h4>
|
||||
<ul>
|
||||
<% way_details.way_nodes.each do |wn| %>
|
||||
<% way.way_nodes.each do |wn| %>
|
||||
<li>
|
||||
<%= 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 == wn.way_id } %>
|
||||
|
@ -23,10 +23,10 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
|
||||
<% unless way_details.containing_relation_members.empty? %>
|
||||
<% unless way.containing_relation_members.empty? %>
|
||||
<h4><%= t'browse.part_of' %></h4>
|
||||
<ul>
|
||||
<%= render :partial => "containing_relation", :collection => way_details.containing_relation_members %>
|
||||
<%= render :partial => "containing_relation", :collection => way.containing_relation_members %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -1,8 +1,8 @@
|
|||
<% set_title("#{t('browse.changeset.title')} | #{@changeset.id}") %>
|
||||
<% set_title(t('browse.changeset.title', :id => @changeset.id)) %>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t 'browse.changeset.changeset', :id => @changeset.id %>
|
||||
<%= t('browse.changeset.title', :id => @changeset.id) %>
|
||||
</h2>
|
||||
|
||||
<div class="browse-section">
|
||||
|
|
14
app/views/browse/feature.html.erb
Normal file
14
app/views/browse/feature.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<% set_title(t("browse.#{@type}.title", :name => printable_name(@feature))) %>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t("browse.#{@type}.title", :name => printable_name(@feature)) %>
|
||||
</h2>
|
||||
|
||||
<%= render :partial => @type, :object => @feature %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => @type, :action => "read") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_history'), :action => "#{@type}_history") %>
|
||||
</div>
|
14
app/views/browse/history.html.erb
Normal file
14
app/views/browse/history.html.erb
Normal file
|
@ -0,0 +1,14 @@
|
|||
<% set_title(t("browse.#{@type}.history_title", :name => printable_name(@feature))) %>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t("browse.#{@type}.history_title", :name => printable_name(@feature)) %>
|
||||
</h2>
|
||||
|
||||
<%= render :partial => @type, :collection => @feature.send("old_#{@type}s").reverse %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => "old_#{@type}", :action => "history") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_details'), :action => @type) %>
|
||||
</div>
|
|
@ -1,17 +0,0 @@
|
|||
<%
|
||||
@name = printable_name @node
|
||||
set_title(t('browse.node.node') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t'browse.node.node_title', :node_name => @name %>
|
||||
</h2>
|
||||
|
||||
<%= render :partial => "node_details", :object => @node %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => "node", :action => "read") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_history'), :action => "node_history") %>
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
<%
|
||||
@name = printable_name @node
|
||||
set_title(t('browse.node.node_history') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= raw t'browse.node.node_history_title', :node_name => link_to(h(@name), :action => "node", :id => @node.id) %>
|
||||
</h2>
|
||||
|
||||
<% @node.old_nodes.reverse.each do |node| %>
|
||||
<%= render :partial => "node_details", :object => node %>
|
||||
<% end %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => "old_node", :action => "history") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_details'), :action => "node") %>
|
||||
</div>
|
|
@ -1,17 +0,0 @@
|
|||
<%
|
||||
@name = printable_name @relation
|
||||
set_title(t('browse.relation.relation') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t'browse.relation.relation_title', :relation_name => @name %>
|
||||
</h2>
|
||||
|
||||
<%= render :partial => "relation_details", :object => @relation %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => "relation", :action => "read") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_history'), :action => "relation_history") %>
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
<%
|
||||
@name = printable_name @relation
|
||||
set_title(t('browse.relation.relation_history') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= raw t'browse.relation.relation_history_title', :relation_name => link_to(h(@name), :action => "relation", :id => @relation.id) %>
|
||||
</h2>
|
||||
|
||||
<% @relation.old_relations.reverse.each do |relation| %>
|
||||
<%= render :partial => "relation_details", :object => relation %>
|
||||
<% end %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => "old_relation", :action => "history") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_details'), :action => "relation") %>
|
||||
</div>
|
|
@ -1,17 +0,0 @@
|
|||
<%
|
||||
@name = printable_name @way
|
||||
set_title(t('browse.way.way') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= t'browse.way.way_title', :way_name => @name %>
|
||||
</h2>
|
||||
|
||||
<%= render :partial => "way_details", :object => @way %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => "way", :action => "read") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_history'), :action => "way_history") %>
|
||||
</div>
|
|
@ -1,19 +0,0 @@
|
|||
<%
|
||||
@name = printable_name @way
|
||||
set_title(t('browse.way.way_history') + ' | ' + @name)
|
||||
%>
|
||||
|
||||
<h2>
|
||||
<a class="geolink" href="<%= root_path %>"><span class="icon close"></span></a>
|
||||
<%= raw t'browse.way.way_history_title', :way_name => link_to(h(@name), :action => "way", :id => @way.id) %>
|
||||
</h2>
|
||||
|
||||
<% @way.old_ways.reverse.each do |way| %>
|
||||
<%= render :partial => "way_details", :object => way %>
|
||||
<% end %>
|
||||
|
||||
<div class='secondary-actions'>
|
||||
<%= link_to(t('browse.download_xml'), :controller => "old_way", :action => "history") %>
|
||||
·
|
||||
<%= link_to(t('browse.view_details'), :action => "way") %>
|
||||
</div>
|
|
@ -109,8 +109,7 @@ en:
|
|||
view_history: "View history"
|
||||
view_details: "View details"
|
||||
changeset:
|
||||
title: "Changeset"
|
||||
changeset: "Changeset %{id}"
|
||||
title: "Changeset %{id}"
|
||||
belongs_to: "Author"
|
||||
node: "Nodes (%{count})"
|
||||
node_paginated: "Nodes (%{x}-%{y} of %{count})"
|
||||
|
@ -124,24 +123,18 @@ en:
|
|||
title: "Changeset %{id}"
|
||||
title_comment: "Changeset %{id} - %{comment}"
|
||||
node:
|
||||
node: "Node"
|
||||
node_title: "Node: %{node_name}"
|
||||
node_history: "Node History"
|
||||
node_history_title: "Node History: %{node_name}"
|
||||
title: "Node: %{name}"
|
||||
history_title: "Node History: %{name}"
|
||||
way:
|
||||
way: "Way"
|
||||
way_title: "Way: %{way_name}"
|
||||
way_history: "Way History"
|
||||
way_history_title: "Way History: %{way_name}"
|
||||
title: "Way: %{name}"
|
||||
history_title: "Way History: %{name}"
|
||||
nodes: "Nodes"
|
||||
also_part_of:
|
||||
one: "part of way %{related_ways}"
|
||||
other: "part of ways %{related_ways}"
|
||||
relation:
|
||||
relation: "Relation"
|
||||
relation_title: "Relation: %{relation_name}"
|
||||
relation_history: "Relation History"
|
||||
relation_history_title: "Relation History: %{relation_name}"
|
||||
title: "Relation: %{name}"
|
||||
history_title: "Relation History: %{name}"
|
||||
members: "Members"
|
||||
relation_member:
|
||||
entry: "%{type} %{name}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue