can [:relation, :relation_history, :way, :way_history, :node, :node_history,
:changeset, :query], :browse
can [:show], OldNode
+ can [:show], OldWay
can [:show, :new], Note
can :search, :direction
can [:index, :permalink, :edit, :help, :fixthemap, :offline, :export, :about, :communities, :preview, :copyright, :key, :id], :site
"/node/:id(/history)": OSM.Browse(map, "node"),
"/node/:id/history/:version": OSM.OldBrowse(),
"/way/:id(/history)": OSM.Browse(map, "way"),
+ "/way/:id/history/:version": OSM.OldBrowse(),
"/relation/:id(/history)": OSM.Browse(map, "relation"),
"/changeset/:id": OSM.Changeset(map),
"/query": OSM.Query(map)
--- /dev/null
+class OldWaysController < 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 = "way"
+ @feature = OldWay.preload(:old_tags, :changeset => [:changeset_tags, :user], :old_nodes => { :node => [:node_tags, :ways] }).find([params[:id], params[:version]])
+ rescue ActiveRecord::RecordNotFound
+ render :action => "not_found", :status => :not_found
+ end
+end
</div>
<% else %>
<div class="browse-section browse-way">
- <%= render :partial => "common_details", :object => way %>
+ <%= render :partial => "browse/common_details", :object => way %>
<% unless way.containing_relation_members.empty? %>
<h4><%= t "browse.part_of" %></h4>
<ul class="list-unstyled">
<% way.way_nodes.each do |wn| %>
<li>
- <%= 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), :rel => link_follow(wn.node) } %>
+ <%= link_to printable_name(wn.node), node_path(wn.node), { :class => link_class("node", wn.node), :title => link_title(wn.node), :rel => link_follow(wn.node) } %>
<% related_ways = wn.node.ways.reject { |w| w.id == wn.way_id } %>
<% if related_ways.size > 0 then %>
- (<%= t ".also_part_of_html", :count => related_ways.size, :related_ways => to_sentence(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) }) }) %>)
+ (<%= t ".also_part_of_html", :count => related_ways.size, :related_ways => to_sentence(related_ways.map { |w| link_to(printable_name(w), way_path(w), { :class => link_class("way", w), :title => link_title(w) }) }) %>)
<% end %>
</li>
<% 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.way.title_html", :name => printable_name(@feature)) %>
+
+<%= render "sidebar_header", :title => t("browse.way.title_html", :name => printable_name(@feature)) %>
+
+<%= render :partial => "browse/way", :object => @feature %>
old_nodes:
not_found:
sorry: "Sorry, node #%{id} version %{version} could not be found."
+ old_ways:
+ not_found:
+ sorry: "Sorry, way #%{id} version %{version} could not be found."
changesets:
changeset_paging_nav:
showing_page: "Page %{page}"
# Data browsing
get "/way/:id" => "browse#way", :id => /\d+/, :as => :way
get "/way/:id/history" => "browse#way_history", :id => /\d+/, :as => :way_history
+ resources :old_ways, :path => "/way/:id/history", :id => /\d+/, :version => /\d+/, :param => :version, :only => :show
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
--- /dev/null
+require "test_helper"
+
+class OldWaysControllerTest < ActionDispatch::IntegrationTest
+ def test_routes
+ assert_routing(
+ { :path => "/way/1/history/2", :method => :get },
+ { :controller => "old_ways", :action => "show", :id => "1", :version => "2" }
+ )
+ end
+
+ def test_visible
+ way = create(:way, :with_history)
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ end
+
+ def test_visible_with_shared_nodes
+ node = create(:node, :with_history)
+ way = create(:way, :with_history)
+ create(:way_node, :way => way, :node => node)
+ create(:old_way_node, :old_way => way.old_ways.first, :node => node)
+ sharing_way = create(:way, :with_history)
+ create(:way_node, :way => sharing_way, :node => node)
+ create(:old_way_node, :old_way => sharing_way.old_ways.first, :node => node)
+ get old_way_path(way, 1)
+ assert_response :success
+ assert_template "old_ways/show"
+ assert_template :layout => "map"
+ end
+
+ def test_not_found
+ get old_way_path(0, 0)
+ assert_response :not_found
+ assert_template "old_ways/not_found"
+ assert_template :layout => "map"
+ assert_select "#sidebar_content", /way #0 version 0 could not be found/
+ end
+end