From: Anton Khorev Date: Mon, 6 Jan 2025 17:15:08 +0000 (+0300) Subject: Make browse not found pages consistent X-Git-Tag: live~29^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/68e55078ecfea0424507ed96e0dac38502768612 Make browse not found pages consistent --- diff --git a/app/controllers/old_nodes_controller.rb b/app/controllers/old_nodes_controller.rb index 288322eea..3b187e4ab 100644 --- a/app/controllers/old_nodes_controller.rb +++ b/app/controllers/old_nodes_controller.rb @@ -10,6 +10,6 @@ class OldNodesController < OldElementsController @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 + render "browse/not_found", :status => :not_found end end diff --git a/app/controllers/old_relations_controller.rb b/app/controllers/old_relations_controller.rb index 8c73eba24..ec256d6af 100644 --- a/app/controllers/old_relations_controller.rb +++ b/app/controllers/old_relations_controller.rb @@ -10,6 +10,6 @@ class OldRelationsController < OldElementsController @type = "relation" @feature = OldRelation.preload(:old_tags, :changeset => [:changeset_tags, :user], :old_members => :member).find([params[:id], params[:version]]) rescue ActiveRecord::RecordNotFound - render :action => "not_found", :status => :not_found + render "browse/not_found", :status => :not_found end end diff --git a/app/controllers/old_ways_controller.rb b/app/controllers/old_ways_controller.rb index e7b0fed6e..1b3ebd747 100644 --- a/app/controllers/old_ways_controller.rb +++ b/app/controllers/old_ways_controller.rb @@ -10,6 +10,6 @@ class OldWaysController < OldElementsController @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 + render "browse/not_found", :status => :not_found end end diff --git a/app/views/browse/not_found.html.erb b/app/views/browse/not_found.html.erb index 36ee4c883..47b299e03 100644 --- a/app/views/browse/not_found.html.erb +++ b/app/views/browse/not_found.html.erb @@ -2,6 +2,4 @@ <%= render "sidebar_header", :title => t(".title") %> -
-

<%= t ".sorry", :type => t(".type.#{@type}"), :id => params[:id] %> -

+<%= render "not_found_message" %> diff --git a/app/views/changesets/_not_found_message.html.erb b/app/views/changesets/_not_found_message.html.erb new file mode 100644 index 000000000..9297f3b9a --- /dev/null +++ b/app/views/changesets/_not_found_message.html.erb @@ -0,0 +1,3 @@ +
+

<%= t ".sorry", :id => params[:id] %>

+
diff --git a/app/views/nodes/_not_found_message.html.erb b/app/views/nodes/_not_found_message.html.erb new file mode 100644 index 000000000..9297f3b9a --- /dev/null +++ b/app/views/nodes/_not_found_message.html.erb @@ -0,0 +1,3 @@ +
+

<%= t ".sorry", :id => params[:id] %>

+
diff --git a/app/views/notes/_not_found_message.html.erb b/app/views/notes/_not_found_message.html.erb new file mode 100644 index 000000000..9297f3b9a --- /dev/null +++ b/app/views/notes/_not_found_message.html.erb @@ -0,0 +1,3 @@ +
+

<%= t ".sorry", :id => params[:id] %>

+
diff --git a/app/views/old_nodes/_not_found_message.html.erb b/app/views/old_nodes/_not_found_message.html.erb new file mode 100644 index 000000000..402905a78 --- /dev/null +++ b/app/views/old_nodes/_not_found_message.html.erb @@ -0,0 +1,7 @@ +
+ <% if params[:version] %> +

<%= t ".sorry", :id => params[:id], :version => params[:version] %>

+ <% else %> +

<%= t "nodes.not_found_message.sorry", :id => params[:id] %>

+ <% end %> +
diff --git a/app/views/old_nodes/not_found.html.erb b/app/views/old_nodes/not_found.html.erb deleted file mode 100644 index 1ee5d9d3f..000000000 --- a/app/views/old_nodes/not_found.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% set_title(t("browse.not_found.title")) %> - -<%= render "sidebar_header", :title => t("browse.not_found.title") %> - -
-

<%= t ".sorry", :id => params[:id], :version => params[:version] %>

-
diff --git a/app/views/old_relations/_not_found_message.html.erb b/app/views/old_relations/_not_found_message.html.erb new file mode 100644 index 000000000..a4598eb8f --- /dev/null +++ b/app/views/old_relations/_not_found_message.html.erb @@ -0,0 +1,7 @@ +
+ <% if params[:version] %> +

<%= t ".sorry", :id => params[:id], :version => params[:version] %>

+ <% else %> +

<%= t "relations.not_found_message.sorry", :id => params[:id] %>

+ <% end %> +
diff --git a/app/views/old_relations/not_found.html.erb b/app/views/old_relations/not_found.html.erb deleted file mode 100644 index 1ee5d9d3f..000000000 --- a/app/views/old_relations/not_found.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% set_title(t("browse.not_found.title")) %> - -<%= render "sidebar_header", :title => t("browse.not_found.title") %> - -
-

<%= t ".sorry", :id => params[:id], :version => params[:version] %>

-
diff --git a/app/views/old_ways/_not_found_message.html.erb b/app/views/old_ways/_not_found_message.html.erb new file mode 100644 index 000000000..09c97aca0 --- /dev/null +++ b/app/views/old_ways/_not_found_message.html.erb @@ -0,0 +1,7 @@ +
+ <% if params[:version] %> +

<%= t ".sorry", :id => params[:id], :version => params[:version] %>

+ <% else %> +

<%= t "ways.not_found_message.sorry", :id => params[:id] %>

+ <% end %> +
diff --git a/app/views/old_ways/not_found.html.erb b/app/views/old_ways/not_found.html.erb deleted file mode 100644 index 1ee5d9d3f..000000000 --- a/app/views/old_ways/not_found.html.erb +++ /dev/null @@ -1,7 +0,0 @@ -<% set_title(t("browse.not_found.title")) %> - -<%= render "sidebar_header", :title => t("browse.not_found.title") %> - -
-

<%= t ".sorry", :id => params[:id], :version => params[:version] %>

-
diff --git a/app/views/relations/_not_found_message.html.erb b/app/views/relations/_not_found_message.html.erb new file mode 100644 index 000000000..9297f3b9a --- /dev/null +++ b/app/views/relations/_not_found_message.html.erb @@ -0,0 +1,3 @@ +
+

<%= t ".sorry", :id => params[:id] %>

+
diff --git a/app/views/ways/_not_found_message.html.erb b/app/views/ways/_not_found_message.html.erb new file mode 100644 index 000000000..9297f3b9a --- /dev/null +++ b/app/views/ways/_not_found_message.html.erb @@ -0,0 +1,3 @@ +
+

<%= t ".sorry", :id => params[:id] %>

+
diff --git a/config/locales/en.yml b/config/locales/en.yml index b60549894..fcaf6ddfe 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -354,13 +354,6 @@ en: entry_role_html: "%{relation_name} (as %{relation_role})" not_found: title: Not Found - sorry: "Sorry, %{type} #%{id} could not be found." - type: - node: node - way: way - relation: relation - changeset: changeset - note: note timeout: title: Timeout Error sorry: "Sorry, the data for the %{type} with the id %{id} took too long to retrieve." @@ -409,26 +402,32 @@ en: view_redacted_data: "View Redacted Data" view_redaction_message: "View Redaction Message" nodes: + not_found_message: + sorry: "Sorry, node #%{id} could not be found." timeout: sorry: "Sorry, the data for the node with the id %{id} took too long to retrieve." old_nodes: - not_found: + not_found_message: sorry: "Sorry, node #%{id} version %{version} could not be found." timeout: sorry: "Sorry, the history of the node with the id %{id} took too long to retrieve." ways: + not_found_message: + sorry: "Sorry, way #%{id} could not be found." timeout: sorry: "Sorry, the data for the way with the id %{id} took too long to retrieve." old_ways: - not_found: + not_found_message: sorry: "Sorry, way #%{id} version %{version} could not be found." timeout: sorry: "Sorry, the history of the way with the id %{id} took too long to retrieve." relations: + not_found_message: + sorry: "Sorry, relation #%{id} could not be found." timeout: sorry: "Sorry, the data for the relation with the id %{id} took too long to retrieve." old_relations: - not_found: + not_found_message: sorry: "Sorry, relation #%{id} version %{version} could not be found." timeout: sorry: "Sorry, the history of the relation with the id %{id} took too long to retrieve." @@ -504,6 +503,8 @@ en: ways_paginated: "Ways (%{x}-%{y} of %{count})" relations: "Relations (%{count})" relations_paginated: "Relations (%{x}-%{y} of %{count})" + not_found_message: + sorry: "Sorry, changeset #%{id} could not be found." timeout: sorry: "Sorry, the list of changesets you requested took too long to retrieve." dashboards: @@ -3096,6 +3097,8 @@ en: showing_page: "Page %{page}" next: "Next" previous: "Previous" + not_found_message: + sorry: "Sorry, note #%{id} could not be found." javascripts: close: Close share: diff --git a/test/controllers/old_nodes_controller_test.rb b/test/controllers/old_nodes_controller_test.rb index dea546316..8e3a14ab6 100644 --- a/test/controllers/old_nodes_controller_test.rb +++ b/test/controllers/old_nodes_controller_test.rb @@ -213,7 +213,7 @@ class OldNodesControllerTest < ActionDispatch::IntegrationTest def test_not_found get old_node_path(0, 0) assert_response :not_found - assert_template "old_nodes/not_found" + assert_template "browse/not_found" assert_template :layout => "map" assert_select "#sidebar_content", /node #0 version 0 could not be found/ end diff --git a/test/controllers/old_relations_controller_test.rb b/test/controllers/old_relations_controller_test.rb index 395c89c2c..3ede1842b 100644 --- a/test/controllers/old_relations_controller_test.rb +++ b/test/controllers/old_relations_controller_test.rb @@ -172,7 +172,7 @@ class OldRelationsControllerTest < ActionDispatch::IntegrationTest def test_not_found get old_relation_path(0, 0) assert_response :not_found - assert_template "old_relations/not_found" + assert_template "browse/not_found" assert_template :layout => "map" assert_select "#sidebar_content", /relation #0 version 0 could not be found/ end diff --git a/test/controllers/old_ways_controller_test.rb b/test/controllers/old_ways_controller_test.rb index 57be1943f..c7b383202 100644 --- a/test/controllers/old_ways_controller_test.rb +++ b/test/controllers/old_ways_controller_test.rb @@ -177,7 +177,7 @@ class OldWaysControllerTest < ActionDispatch::IntegrationTest def test_not_found get old_way_path(0, 0) assert_response :not_found - assert_template "old_ways/not_found" + assert_template "browse/not_found" assert_template :layout => "map" assert_select "#sidebar_content", /way #0 version 0 could not be found/ end