Add node version pages
This commit is contained in:
parent
e71355c5bb
commit
85c284aaa6
11 changed files with 79 additions and 6 deletions
|
@ -6,6 +6,7 @@ class Ability
|
||||||
def initialize(user)
|
def initialize(user)
|
||||||
can [:relation, :relation_history, :way, :way_history, :node, :node_history,
|
can [:relation, :relation_history, :way, :way_history, :node, :node_history,
|
||||||
:changeset, :query], :browse
|
:changeset, :query], :browse
|
||||||
|
can [:show], OldNode
|
||||||
can [:show, :new], Note
|
can [:show, :new], Note
|
||||||
can :search, :direction
|
can :search, :direction
|
||||||
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
|
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
|
||||||
|
|
|
@ -355,6 +355,16 @@ $(document).ready(function () {
|
||||||
return page;
|
return page;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OSM.OldBrowse = function () {
|
||||||
|
var page = {};
|
||||||
|
|
||||||
|
page.pushstate = page.popstate = function (path) {
|
||||||
|
OSM.loadSidebarContent(path);
|
||||||
|
};
|
||||||
|
|
||||||
|
return page;
|
||||||
|
};
|
||||||
|
|
||||||
var history = OSM.History(map);
|
var history = OSM.History(map);
|
||||||
|
|
||||||
OSM.router = OSM.Router(map, {
|
OSM.router = OSM.Router(map, {
|
||||||
|
@ -369,6 +379,7 @@ $(document).ready(function () {
|
||||||
"/user/:display_name/history": history,
|
"/user/:display_name/history": history,
|
||||||
"/note/:id": OSM.Note(map),
|
"/note/:id": OSM.Note(map),
|
||||||
"/node/:id(/history)": OSM.Browse(map, "node"),
|
"/node/:id(/history)": OSM.Browse(map, "node"),
|
||||||
|
"/node/:id/history/:version": OSM.OldBrowse(),
|
||||||
"/way/:id(/history)": OSM.Browse(map, "way"),
|
"/way/:id(/history)": OSM.Browse(map, "way"),
|
||||||
"/relation/:id(/history)": OSM.Browse(map, "relation"),
|
"/relation/:id(/history)": OSM.Browse(map, "relation"),
|
||||||
"/changeset/:id": OSM.Changeset(map),
|
"/changeset/:id": OSM.Changeset(map),
|
||||||
|
|
19
app/controllers/old_nodes_controller.rb
Normal file
19
app/controllers/old_nodes_controller.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class OldNodesController < ApplicationController
|
||||||
|
layout :map_layout
|
||||||
|
|
||||||
|
before_action :authorize_web
|
||||||
|
before_action :set_locale
|
||||||
|
before_action -> { check_database_readable(:need_api => true) }
|
||||||
|
before_action :require_oauth
|
||||||
|
|
||||||
|
authorize_resource
|
||||||
|
|
||||||
|
around_action :web_timeout
|
||||||
|
|
||||||
|
def show
|
||||||
|
@type = "node"
|
||||||
|
@feature = OldNode.preload(:old_tags, :changeset => [:changeset_tags, :user]).find([params[:id], params[:version]])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render :action => "not_found", :status => :not_found
|
||||||
|
end
|
||||||
|
end
|
|
@ -19,7 +19,7 @@
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= t "browse.in_changeset" %>
|
<%= t "browse.in_changeset" %>
|
||||||
#<%= link_to common_details.changeset_id, :action => :changeset, :id => common_details.changeset_id %>
|
#<%= link_to common_details.changeset_id, changeset_path(common_details.changeset) %>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<% if @type == "node" and common_details.visible? %>
|
<% if @type == "node" and common_details.visible? %>
|
||||||
|
@ -33,4 +33,4 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<%= render :partial => "tag_details", :object => common_details.tags %>
|
<%= render :partial => "browse/tag_details", :object => common_details.tags %>
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="browse-section browse-node">
|
<div class="browse-section browse-node">
|
||||||
<%= render :partial => "common_details", :object => node %>
|
<%= render :partial => "browse/common_details", :object => node %>
|
||||||
|
|
||||||
<% unless node.ways.empty? and node.containing_relation_members.empty? %>
|
<% unless node.ways.empty? and node.containing_relation_members.empty? %>
|
||||||
<h4><%= t "browse.part_of" %></h4>
|
<h4><%= t "browse.part_of" %></h4>
|
||||||
|
@ -17,7 +17,7 @@
|
||||||
<summary><%= t "browse.part_of_ways", :count => node.ways.uniq.count %></summary>
|
<summary><%= t "browse.part_of_ways", :count => node.ways.uniq.count %></summary>
|
||||||
<ul class="list-unstyled">
|
<ul class="list-unstyled">
|
||||||
<% node.ways.uniq.each do |way| %>
|
<% node.ways.uniq.each do |way| %>
|
||||||
<li><%= link_to printable_name(way), { :action => "way", :id => way.id.to_s }, { :class => link_class("way", way), :title => link_title(way) } %></li>
|
<li><%= link_to printable_name(way), way_path(way), { :class => link_class("way", way), :title => link_title(way) } %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<details <%= "open" if node.containing_relation_members.count < 10 %>>
|
<details <%= "open" if node.containing_relation_members.count < 10 %>>
|
||||||
<summary><%= t "browse.part_of_relations", :count => node.containing_relation_members.uniq.count %></summary>
|
<summary><%= t "browse.part_of_relations", :count => node.containing_relation_members.uniq.count %></summary>
|
||||||
<ul class="list-unstyled">
|
<ul class="list-unstyled">
|
||||||
<%= render :partial => "containing_relation", :collection => node.containing_relation_members.uniq %>
|
<%= render :partial => "browse/containing_relation", :collection => node.containing_relation_members.uniq %>
|
||||||
</ul>
|
</ul>
|
||||||
</details>
|
</details>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<h4><%= t ".tags" %></h4>
|
<h4><%= t ".tags" %></h4>
|
||||||
<div class='mb-3 border border-grey rounded overflow-hidden'>
|
<div class='mb-3 border border-grey rounded overflow-hidden'>
|
||||||
<table class='mb-0 browse-tag-list table align-middle text-break'>
|
<table class='mb-0 browse-tag-list table align-middle text-break'>
|
||||||
<%= render :partial => "tag", :collection => tag_details.sort %>
|
<%= render :partial => "browse/tag", :collection => tag_details.sort %>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
7
app/views/old_nodes/not_found.html.erb
Normal file
7
app/views/old_nodes/not_found.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<% set_title(t("browse.not_found.title")) %>
|
||||||
|
|
||||||
|
<%= render "sidebar_header", :title => t("browse.not_found.title") %>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p><%= t ".sorry", :id => params[:id], :version => params[:version] %></p>
|
||||||
|
</div>
|
5
app/views/old_nodes/show.html.erb
Normal file
5
app/views/old_nodes/show.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
<% set_title t("browse.node.title_html", :name => printable_name(@feature)) %>
|
||||||
|
|
||||||
|
<%= render "sidebar_header", :title => t("browse.node.title_html", :name => printable_name(@feature)) %>
|
||||||
|
|
||||||
|
<%= render :partial => "browse/node", :object => @feature %>
|
|
@ -428,6 +428,9 @@ en:
|
||||||
introduction: "Click on the map to find nearby features."
|
introduction: "Click on the map to find nearby features."
|
||||||
nearby: "Nearby features"
|
nearby: "Nearby features"
|
||||||
enclosing: "Enclosing features"
|
enclosing: "Enclosing features"
|
||||||
|
old_nodes:
|
||||||
|
not_found:
|
||||||
|
sorry: "Sorry, node #%{id} version %{version} could not be found."
|
||||||
changesets:
|
changesets:
|
||||||
changeset_paging_nav:
|
changeset_paging_nav:
|
||||||
showing_page: "Page %{page}"
|
showing_page: "Page %{page}"
|
||||||
|
|
|
@ -113,6 +113,7 @@ OpenStreetMap::Application.routes.draw do
|
||||||
get "/way/:id/history" => "browse#way_history", :id => /\d+/, :as => :way_history
|
get "/way/:id/history" => "browse#way_history", :id => /\d+/, :as => :way_history
|
||||||
get "/node/:id" => "browse#node", :id => /\d+/, :as => :node
|
get "/node/:id" => "browse#node", :id => /\d+/, :as => :node
|
||||||
get "/node/:id/history" => "browse#node_history", :id => /\d+/, :as => :node_history
|
get "/node/:id/history" => "browse#node_history", :id => /\d+/, :as => :node_history
|
||||||
|
resources :old_nodes, :path => "/node/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
|
||||||
get "/relation/:id" => "browse#relation", :id => /\d+/, :as => :relation
|
get "/relation/:id" => "browse#relation", :id => /\d+/, :as => :relation
|
||||||
get "/relation/:id/history" => "browse#relation_history", :id => /\d+/, :as => :relation_history
|
get "/relation/:id/history" => "browse#relation_history", :id => /\d+/, :as => :relation_history
|
||||||
get "/changeset/:id" => "browse#changeset", :as => :changeset, :id => /\d+/
|
get "/changeset/:id" => "browse#changeset", :as => :changeset, :id => /\d+/
|
||||||
|
|
26
test/controllers/old_nodes_controller_test.rb
Normal file
26
test/controllers/old_nodes_controller_test.rb
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class OldNodesControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
def test_routes
|
||||||
|
assert_routing(
|
||||||
|
{ :path => "/node/1/history/2", :method => :get },
|
||||||
|
{ :controller => "old_nodes", :action => "show", :id => "1", :version => "2" }
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_visible
|
||||||
|
node = create(:node, :with_history)
|
||||||
|
get old_node_path(node, 1)
|
||||||
|
assert_response :success
|
||||||
|
assert_template "old_nodes/show"
|
||||||
|
assert_template :layout => "map"
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_not_found
|
||||||
|
get old_node_path(0, 0)
|
||||||
|
assert_response :not_found
|
||||||
|
assert_template "old_nodes/not_found"
|
||||||
|
assert_template :layout => "map"
|
||||||
|
assert_select "#sidebar_content", /node #0 version 0 could not be found/
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue