From: Anton Khorev Date: Mon, 15 Jan 2024 15:20:23 +0000 (+0300) Subject: Add way version pages X-Git-Tag: live~280^2~12 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/2f222c49dd60ea505f2c1631efa02fbd9f0f5667 Add way version pages --- diff --git a/app/abilities/ability.rb b/app/abilities/ability.rb index b601e66f0..643465c54 100644 --- a/app/abilities/ability.rb +++ b/app/abilities/ability.rb @@ -7,6 +7,7 @@ class Ability 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 diff --git a/app/assets/javascripts/index.js b/app/assets/javascripts/index.js index 621054caf..bb471490a 100644 --- a/app/assets/javascripts/index.js +++ b/app/assets/javascripts/index.js @@ -381,6 +381,7 @@ $(document).ready(function () { "/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) diff --git a/app/controllers/old_ways_controller.rb b/app/controllers/old_ways_controller.rb new file mode 100644 index 000000000..d18121e6f --- /dev/null +++ b/app/controllers/old_ways_controller.rb @@ -0,0 +1,19 @@ +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 diff --git a/app/views/browse/_way.html.erb b/app/views/browse/_way.html.erb index 4fdcd035e..26403f3fd 100644 --- a/app/views/browse/_way.html.erb +++ b/app/views/browse/_way.html.erb @@ -8,7 +8,7 @@ <% else %>
- <%= render :partial => "common_details", :object => way %> + <%= render :partial => "browse/common_details", :object => way %> <% unless way.containing_relation_members.empty? %>

<%= t "browse.part_of" %>

@@ -27,10 +27,10 @@