diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 176fd8c2e..a7235241c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -259,12 +259,7 @@ class ApplicationController < ActionController::Base request.content_security_policy = policy - case Settings.status - when "database_offline", "api_offline" - flash.now[:warning] = t("layouts.osm_offline") - when "database_readonly", "api_readonly" - flash.now[:warning] = t("layouts.osm_read_only") - end + flash.now[:warning] = { :partial => "layouts/offline_flash" } unless api_status == "online" request.xhr? ? "xhr" : "map" end diff --git a/app/controllers/site_controller.rb b/app/controllers/site_controller.rb index 9adbaa195..5110be019 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 @@ -129,11 +137,7 @@ class SiteController < ApplicationController def export; end def offline - flash.now[:warning] = if Settings.status == "database_offline" - t("layouts.osm_offline") - else - t("layouts.osm_read_only") - end + flash.now[:warning] = { :partial => "layouts/offline_flash" } render :html => nil, :layout => true end diff --git a/app/views/layouts/_offline_flash.erb b/app/views/layouts/_offline_flash.erb new file mode 100644 index 000000000..364788dcf --- /dev/null +++ b/app/views/layouts/_offline_flash.erb @@ -0,0 +1,26 @@ +
+ <%= t(".osm_offline") %> +
+ <% elsif %w[database_readonly api_readonly].include? Settings.status %> ++ <%= t(".osm_read_only") %> +
+ <% end %> + + <% if Settings.status_expected_restore_date %> + <% expected_restore_time = Time.parse(Settings.status_expected_restore_date).utc %> + <% if expected_restore_time > Time.now.utc %> ++ <%= t ".expected_restore_html", :time => friendly_date(expected_restore_time) %> +
+ <% end %> + <% end %> + + <% if Settings.status_announcement_url %> ++ <%= link_to t(".announcement"), Settings.status_announcement_url %> +
+ <% end %> +<%= 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" %>
-<%= t "layouts.osm_read_only" %>
-<%= 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 7b2be6a0c..cb7e24ee0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1624,8 +1624,6 @@ en: partners_corpmembers: "OSMF corporate members" partners_partners: "partners" tou: "Terms of Use" - osm_offline: "The OpenStreetMap database is currently offline while essential database maintenance work is carried out." - osm_read_only: "The OpenStreetMap database is currently in read-only mode while essential database maintenance work is carried out." nothing_to_preview: "Nothing to preview." help: Help about: About @@ -1633,6 +1631,11 @@ en: communities: Communities learn_more: "Learn More" more: More + offline_flash: + osm_offline: "The OpenStreetMap database is currently offline while essential maintenance work is carried out." + osm_read_only: "The OpenStreetMap database is currently in read-only mode while essential maintenance work is carried out." + expected_restore_html: "Services are expected to be restored in %{time}." + announcement: "You can read the announcement here." user_mailer: diary_comment_notification: description: "OpenStreetMap Diary Entry #%{id}" @@ -2249,13 +2252,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" diff --git a/config/settings.yml b/config/settings.yml index c79199145..2e0346f00 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -23,6 +23,10 @@ api_version: "0.6" # database_offline - database offline with site in emergency mode # gpx_offline - gpx storage offline status: "online" +# Expected services restoration date added to offline flash messages +#status_expected_restore_date: "2024-12-18 12:00:00Z" +# Application status announcement url added to offline flash messages +#status_announcement_url: "https://en.osm.town/@osm_tech" # The maximum area you're allowed to request, in square degrees max_request_area: 0.25 # Number of GPS trace/trackpoints returned per-page