]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/5403'
authorTom Hughes <tom@compton.nu>
Mon, 10 Feb 2025 18:54:14 +0000 (18:54 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 10 Feb 2025 18:54:14 +0000 (18:54 +0000)
app/controllers/application_controller.rb
app/controllers/site_controller.rb
app/views/layouts/_offline_flash.erb [new file with mode: 0644]
app/views/site/_not_public_flash.erb [new file with mode: 0644]
app/views/site/edit.html.erb
config/locales/en.yml
config/settings.yml

index 176fd8c2e060213d8264c1ccd1dd8cddca281df6..a7235241c14f95f46661073c7fe01e7165d6d246 100644 (file)
@@ -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
index 9adbaa1953fd9fe774bf9bb90eb130da53aed90e..5110be0197ab21face71e30427ac5b29c04b7092 100644 (file)
@@ -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 (file)
index 0000000..364788d
--- /dev/null
@@ -0,0 +1,26 @@
+<div class="d-flex flex-column gap-2">
+  <% if %w[database_offline api_offline].include? Settings.status %>
+    <p class="mb-0">
+      <%= t(".osm_offline") %>
+    </p>
+  <% elsif %w[database_readonly api_readonly].include? Settings.status %>
+    <p class="mb-0">
+      <%= t(".osm_read_only") %>
+    </p>
+  <% 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 %>
+      <p class="mb-0">
+        <%= t ".expected_restore_html", :time => friendly_date(expected_restore_time) %>
+      </p>
+    <% end %>
+  <% end %>
+
+  <% if Settings.status_announcement_url %>
+    <p class="mb-0">
+      <%= link_to t(".announcement"), Settings.status_announcement_url %>
+    </p>
+  <% end %>
+</div>
diff --git a/app/views/site/_not_public_flash.erb b/app/views/site/_not_public_flash.erb
new file mode 100644 (file)
index 0000000..bcd010f
--- /dev/null
@@ -0,0 +1,3 @@
+<p><%= t ".not_public" %></p>
+<p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
+<p><%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %></p>
index 1eb73382279b638866d08af61e302681e5cff858..6d463df7848dbd52138ebad1c12640d2671d61af 100644 (file)
@@ -1,17 +1,5 @@
 <% content_for :content do %>
-  <% if Settings.status == "database_offline" or Settings.status == "api_offline" %>
-    <div class="alert alert-warning text-center">
-        <p class="my-2"><%= t "layouts.osm_offline" %></p>
-    </div>
-  <% elsif Settings.status == "database_readonly" or Settings.status == "api_readonly" %>
-    <div class="alert alert-warning text-center">
-        <p class="my-2"><%= t "layouts.osm_read_only" %></p>
-    </div>
-  <% elsif !current_user.data_public? %>
-    <p><%= t ".not_public" %></p>
-    <p><%= t ".not_public_description_html", :user_page => (link_to t(".user_page_link"), edit_account_path(:anchor => "public")) %></p>
-    <p><%= t ".anon_edits_html", :link => link_to(t(".anon_edits_link_text"), t(".anon_edits_link")) %></p>
-  <% else %>
+  <% if @enable_editor %>
     <%= render :partial => preferred_editor %>
   <% end %>
 <% end %>
index 7b2be6a0cb63180d6a2a1376550d2688d2d7fc40..cb7e24ee0d580b302a79be9aeeaa4271763e8f31 100644 (file)
@@ -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"
index c79199145163359dd3a7efbc6dcb6e539c4037e1..2e0346f0031c891d226deeddaa284adb2801cc31 100644 (file)
@@ -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