Add node version pages

This commit is contained in:
Anton Khorev 2024-01-14 02:05:36 +03:00
parent e71355c5bb
commit 85c284aaa6
11 changed files with 79 additions and 6 deletions

View file

@ -6,6 +6,7 @@ class Ability
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

View file

@ -355,6 +355,16 @@ $(document).ready(function () {
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, {
@ -369,6 +379,7 @@ $(document).ready(function () {
"/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),

View 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

View file

@ -19,7 +19,7 @@
</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? %>
@ -33,4 +33,4 @@
<% end %>
</ul>
<%= render :partial => "tag_details", :object => common_details.tags %>
<%= render :partial => "browse/tag_details", :object => common_details.tags %>

View file

@ -8,7 +8,7 @@
</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>
@ -17,7 +17,7 @@
<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>
@ -26,7 +26,7 @@
<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 %>

View file

@ -2,7 +2,7 @@
<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 %>

View 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>

View 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 %>