From d6afe1e4d14ad4e642ea3454545740a3294afab7 Mon Sep 17 00:00:00 2001 From: Anton Khorev Date: Mon, 16 Dec 2024 18:49:10 +0300 Subject: [PATCH] Use offline flash partial on edit page --- app/controllers/site_controller.rb | 8 ++++++++ app/views/site/_not_public_flash.erb | 3 +++ app/views/site/edit.html.erb | 14 +------------- config/locales/en.yml | 3 ++- 4 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 app/views/site/_not_public_flash.erb diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 58f0a11c9..13a97a664 100644 --- a/app/controllers/site_controller.rb +++ b/app/controllers/site_controller.rb @@ -107,6 +107,14 @@ class SiteController < ApplicationController rescue ActiveRecord::RecordNotFound # don't try and derive a location from a missing/deleted object end + + if api_status != "online" + flash.now[:warning] = { :partial => "layouts/offline_flash" } + elsif current_user && !current_user.data_public? + flash.now[:warning] = { :partial => "not_public_flash" } + else + @enable_editor = true + end end def copyright diff --git a/app/views/site/_not_public_flash.erb b/app/views/site/_not_public_flash.erb new file mode 100644 index 000000000..bcd010f35 --- /dev/null +++ b/app/views/site/_not_public_flash.erb @@ -0,0 +1,3 @@ +

<%= t ".not_public" %>

+

<%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %>

+

<%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %>

diff --git a/app/views/site/edit.html.erb b/app/views/site/edit.html.erb index 1eb733822..6d463df78 100644 --- a/app/views/site/edit.html.erb +++ b/app/views/site/edit.html.erb @@ -1,17 +1,5 @@ <% content_for :content do %> - <% if Settings.status == "database_offline" or Settings.status == "api_offline" %> -
-

<%= t "layouts.osm_offline" %>

-
- <% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %> -
-

<%= t "layouts.osm_read_only" %>

-
- <% elsif !current_user.data_public? %> -

<%= t ".not_public" %>

-

<%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %>

-

<%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %>

- <% else %> + <% if @enable_editor %> <%= render :partial => preferred_editor %> <% end %> <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 0e7946c0f..53b4217a1 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2217,13 +2217,14 @@ en: license_url: "https://openstreetmap.org/copyright" project_url: "https://openstreetmap.org" remote_failed: "Editing failed - make sure JOSM or Merkaartor is loaded and the remote control option is enabled" - edit: + not_public_flash: not_public: "You have not set your edits to be public." not_public_description_html: "You can no longer edit the map unless you do so. You can set your edits as public from your %{user_page}." user_page_link: user page anon_edits_html: "(%{link})" anon_edits_link: "https://wiki.openstreetmap.org/wiki/Disabling_anonymous_edits" anon_edits_link_text: "Find out why this is the case." + edit: id_not_configured: "iD has not been configured" export: title: "Export" -- 2.39.5