Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add date and url settings for offline message #5403

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,7 @@ def map_layout

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
Expand Down
14 changes: 9 additions & 5 deletions app/controllers/site_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ def edit
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
Expand All @@ -129,11 +137,7 @@ def communities
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

Expand Down
26 changes: 26 additions & 0 deletions app/views/layouts/_offline_flash.erb
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 3 additions & 0 deletions app/views/site/_not_public_flash.erb
Original file line number Diff line number Diff line change
@@ -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>
14 changes: 1 addition & 13 deletions app/views/site/edit.html.erb
Original file line number Diff line number Diff line change
@@ -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 %>
10 changes: 7 additions & 3 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1598,15 +1598,18 @@ 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
copyright: Copyright
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}"
Expand Down Expand Up @@ -2217,13 +2220,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"
Expand Down
4 changes: 4 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading