def initialize(user)
can [:relation, :relation_history, :way, :way_history, :node, :node_history,
:changeset, :query], :browse
+ can [:show], OldNode
can [:show, :new], Note
can :search, :direction
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
return page;
};
+ OSM.OldBrowse = function () {
+ var page = {};
+
+ page.pushstate = page.popstate = function (path) {
+ OSM.loadSidebarContent(path);
+ };
+
+ return page;
+ };
+
var history = OSM.History(map);
OSM.router = OSM.Router(map, {
"/user/:display_name/history": history,
"/note/:id": OSM.Note(map),
"/node/:id(/history)": OSM.Browse(map, "node"),
+ "/node/:id/history/:version": OSM.OldBrowse(),
"/way/:id(/history)": OSM.Browse(map, "way"),
"/relation/:id(/history)": OSM.Browse(map, "relation"),
"/changeset/:id": OSM.Changeset(map),
--- /dev/null
+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
</li>
<li>
<%= 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>
<% if @type == "node" and common_details.visible? %>
<% end %>
</ul>
-<%= render :partial => "tag_details", :object => common_details.tags %>
+<%= render :partial => "browse/tag_details", :object => common_details.tags %>
</div>
<% else %>
<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? %>
<h4><%= t "browse.part_of" %></h4>
<summary><%= t "browse.part_of_ways", :count => node.ways.uniq.count %></summary>
<ul class="list-unstyled">
<% 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 %>
</ul>
</details>
<details <%= "open" if node.containing_relation_members.count < 10 %>>
<summary><%= t "browse.part_of_relations", :count => node.containing_relation_members.uniq.count %></summary>
<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>
</details>
<% end %>
<h4><%= t ".tags" %></h4>
<div class='mb-3 border border-grey rounded overflow-hidden'>
<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>
</div>
<% end %>
--- /dev/null
+<% 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>
--- /dev/null
+<% 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 %>
introduction: "Click on the map to find nearby features."
nearby: "Nearby features"
enclosing: "Enclosing features"
+ old_nodes:
+ not_found:
+ sorry: "Sorry, node #%{id} version %{version} could not be found."
changesets:
changeset_paging_nav:
showing_page: "Page %{page}"
get "/way/:id/history" => "browse#way_history", :id => /\d+/, :as => :way_history
get "/node/:id" => "browse#node", :id => /\d+/, :as => :node
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/history" => "browse#relation_history", :id => /\d+/, :as => :relation_history
get "/changeset/:id" => "browse#changeset", :as => :changeset, :id => /\d+/
--- /dev/null
+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