Merge branch 'add-error-page' into 'master'

Introduce support for custom nginx error pages

See merge request framasoft/mobilizon!598
This commit is contained in:
Thomas Citharel 2020-10-09 15:06:43 +02:00
commit 2adf688092
31 changed files with 476 additions and 63 deletions

2
.gitignore vendored
View File

@ -23,6 +23,8 @@ priv/static/*
!priv/static/.gitkeep !priv/static/.gitkeep
priv/data/* priv/data/*
!priv/data/.gitkeep !priv/data/.gitkeep
priv/errors/*
!priv/errors/.gitkeep
.vscode/ .vscode/
cover/ cover/
site/ site/

View File

@ -8,10 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Special operations ### Special operations
We added `application/ld+json` as acceptable MIME type for ActivityPub requests, so you'll need to recompile the `mime` library we use before recompiling Mobilizon: * We added `application/ld+json` as acceptable MIME type for ActivityPub requests, so you'll need to recompile the `mime` library we use before recompiling Mobilizon:
``` ```
MIX_ENV=prod mix deps.clean mime --build MIX_ENV=prod mix deps.clean mime --build
``` ```
* The [nginx configuration](https://framagit.org/framasoft/mobilizon/-/blob/master/support/nginx/mobilizon.conf) has been changed with improvements and support for custom error pages.
### Added ### Added

View File

@ -19,6 +19,7 @@ config :mobilizon, :instance,
registrations_open: false, registrations_open: false,
registration_email_allowlist: [], registration_email_allowlist: [],
languages: [], languages: [],
default_language: "en",
demo: false, demo: false,
repository: Mix.Project.config()[:source_url], repository: Mix.Project.config()[:source_url],
allow_relay: true, allow_relay: true,

View File

@ -16,6 +16,7 @@ defmodule Mobilizon do
alias Mobilizon.{Config, Storage, Web} alias Mobilizon.{Config, Storage, Web}
alias Mobilizon.Federation.ActivityPub alias Mobilizon.Federation.ActivityPub
alias Mobilizon.Service.ErrorPage
alias Mobilizon.Service.Export.{Feed, ICalendar} alias Mobilizon.Service.Export.{Feed, ICalendar}
@name Mix.Project.config()[:name] @name Mix.Project.config()[:name]
@ -104,7 +105,7 @@ defmodule Mobilizon do
defp fallback_options(fallback), do: [fallback: fallback(default: fallback)] defp fallback_options(fallback), do: [fallback: fallback(default: fallback)]
defp task_children(:test), do: [] defp task_children(:test), do: []
defp task_children(_), do: [relay_actor(), anonymous_actor()] defp task_children(_), do: [relay_actor(), anonymous_actor(), render_error_page()]
defp relay_actor do defp relay_actor do
%{ %{
@ -121,4 +122,12 @@ defmodule Mobilizon do
restart: :temporary restart: :temporary
} }
end end
defp render_error_page do
%{
id: :render_error_page_init,
start: {Task, :start_link, [&ErrorPage.init/0]},
restart: :temporary
}
end
end end

17
lib/service/error_page.ex Normal file
View File

@ -0,0 +1,17 @@
defmodule Mobilizon.Service.ErrorPage do
@moduledoc """
Render an error page
"""
def init do
render_error_page()
end
defp render_error_page do
content =
Phoenix.View.render_to_string(Mobilizon.Web.ErrorView, "500.html", conn: %Plug.Conn{})
path = Path.join(Application.app_dir(:mobilizon, "priv/errors"), "error.html")
File.write(path, content)
end
end

View File

@ -37,8 +37,8 @@ defmodule Mobilizon.Web.Gettext do
locale in locales -> locale locale in locales -> locale
# Either the first part matches, "fr_CA" => "fr" # Either the first part matches, "fr_CA" => "fr"
split_locale(locale) in locales -> split_locale(locale) split_locale(locale) in locales -> split_locale(locale)
# Otherwise default to english # Otherwise set to default
true -> "en" true -> Keyword.get(Mobilizon.Config.instance_config(), :default_language, "en") || "en"
end end
end end

View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="<%= Gettext.get_locale() %>">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><%= gettext "This page is not correct" %></title>
<style>
body.error {
font-family: BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, Segoe UI, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial, sans-serif;
background: #efeef4;
position: absolute;
text-align: center;
color: #3c376e;
width: 100%;
height: 100%;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
}
body.error .dialog h1 {
font-size: 20px;
line-height: 28px;
font-weight: 400;
}
body.error .dialog img {
display: block;
max-width: 470px;
width: 100%;
height: auto;
margin: -120px auto auto;
}
</style>
</head>
<body class="error">
<main role="main" class="dialog">
<div class="error_illustration">
<img src="/static/img/mobilizon_logo.png" />
<!-- <img src="/static/img/error.png" alt="" width="500" /> -->
</div>
<div class="error__message">
<h1><%= gettext "We're sorry, but something went wrong on our end." %></h1>
<p><%= gettext "The Mobilizon server seems to be temporarily down." %></p>
</div>
</main>
</body>
</html>

View File

@ -39,7 +39,11 @@ defmodule Mobilizon.Web.ErrorView do
end end
def render("500.html", _assigns) do def render("500.html", _assigns) do
"Internal server error" Mobilizon.Config.instance_config()
|> Keyword.get(:default_language, "en")
|> Gettext.put_locale()
render("500_page.html", %{})
end end
# In case no render clause matches or no # In case no render clause matches or no

0
priv/errors/.gitkeep Normal file
View File

View File

@ -1395,12 +1395,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "الفعالية" msgstr "الفعالية"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1371,12 +1371,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1391,12 +1391,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Activitat" msgstr "Activitat"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1371,12 +1371,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1399,12 +1399,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Veranstaltung" msgstr "Veranstaltung"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1359,3 +1359,18 @@ msgstr ""
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1403,12 +1403,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Event" msgstr "Event"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1699,12 +1699,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "Envió una solicitud para asistir a %{title}." msgstr "Envió una solicitud para asistir a %{title}."
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Evento" msgstr "Evento"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "Ha habido cambios para% {title}, así que pensamos en avisarle." msgstr "Ha habido cambios para% {title}, así que pensamos en avisarle."
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1649,12 +1649,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "Lähetit pyynnön osallistua tapahtumaan %{title}." msgstr "Lähetit pyynnön osallistua tapahtumaan %{title}."
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Tapahtuma" msgstr "Tapahtuma"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "%{title} on joiltain osin muuttunut, ja ajattelimme ilmoittaa asiasta." msgstr "%{title} on joiltain osin muuttunut, ja ajattelimme ilmoittaa asiasta."
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -10,7 +10,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"POT-Creation-Date: \n" "POT-Creation-Date: \n"
"PO-Revision-Date: 2020-10-08 08:52+0200\n" "PO-Revision-Date: 2020-10-09 09:46+0200\n"
"Last-Translator: Thomas Citharel <thomas.citharel@framasoft.org>\n" "Last-Translator: Thomas Citharel <thomas.citharel@framasoft.org>\n"
"Language-Team: French <https://weblate.framasoft.org/projects/mobilizon/backend/fr/>\n" "Language-Team: French <https://weblate.framasoft.org/projects/mobilizon/backend/fr/>\n"
"Language: fr\n" "Language: fr\n"
@ -1094,3 +1094,15 @@ msgstr "Titre de l'événement"
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "Il y a eu des changements pour <b>%{title}</b> donc nous avons pensé que nous vous le ferions savoir." msgstr "Il y a eu des changements pour <b>%{title}</b> donc nous avons pensé que nous vous le ferions savoir."
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr "Le serveur Mobilizon semble être temporairement hors-service."
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr "Cette page nest pas correcte"
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr "Nous sommes désolé·e·s, mais quelque chose sest mal passé de notre côté."

View File

@ -1369,12 +1369,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Evento" msgstr "Evento"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1359,12 +1359,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "イベント" msgstr "イベント"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1394,12 +1394,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Evenement" msgstr "Evenement"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1396,12 +1396,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Eveniment" msgstr "Eveniment"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1407,12 +1407,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Wydarzenie" msgstr "Wydarzenie"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1364,12 +1364,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1486,12 +1486,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Evento" msgstr "Evento"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1382,12 +1382,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Событие" msgstr "Событие"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -1387,12 +1387,27 @@ msgstr ""
msgid "You issued a request to attend <b>%{title}</b>." msgid "You issued a request to attend <b>%{title}</b>."
msgstr "" msgstr ""
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:64 #: lib/web/templates/email/event_updated.html.eex:64
msgid "Event title" msgid "Event title"
msgstr "Evenemang" msgstr "Evenemang"
#, elixir-format, fuzzy #, elixir-format
#: lib/web/templates/email/event_updated.html.eex:38 #: lib/web/templates/email/event_updated.html.eex:38
msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know." msgid "There have been changes for <b>%{title}</b> so we'd thought we'd let you know."
msgstr "" msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:46
msgid "The Mobilizon server seems to be temporarily down."
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:7
msgid "This page is not correct"
msgstr ""
#, elixir-format
#: lib/web/templates/error/500_page.html.eex:45
msgid "We're sorry, but something went wrong on our end."
msgstr ""

View File

@ -35,13 +35,14 @@ server {
# ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem; # ssl_certificate_key /etc/letsencrypt/live/example.tld/privkey.pem;
# Add TLSv1.3 if it's supported by your system # Add TLSv1.3 if it's supported by your system
ssl_protocols TLSv1.2; ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA'; ssl_ciphers 'EECDH+aRSA+AESGCM:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:+CAMELLIA256:+AES256:+CAMELLIA128:+AES128:+SSLv3:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!DSS:!RC4:!SEED:!ECDSA';
ssl_prefer_server_ciphers on; ssl_prefer_server_ciphers on;
ssl_ecdh_curve prime256v1; ssl_ecdh_curve prime256v1;
# ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1; # ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
ssl_stapling on; ssl_stapling on;
ssl_stapling_verify on; ssl_stapling_verify on;
add_header Strict-Transport-Security "max-age=31536000";
gzip on; gzip on;
gzip_disable "msie6"; gzip_disable "msie6";
@ -55,6 +56,18 @@ server {
# the nginx default is 1m, not enough for large media uploads # the nginx default is 1m, not enough for large media uploads
client_max_body_size 16m; client_max_body_size 16m;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
location / {
try_files $uri @proxy;
}
# Let's Encrypt keeps its files here # Let's Encrypt keeps its files here
location ^~ '/.well-known/acme-challenge' { location ^~ '/.well-known/acme-challenge' {
root /var/www/certbot; root /var/www/certbot;
@ -62,29 +75,27 @@ server {
} }
location / { location / {
gzip off;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# For Websocket support
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://localhost:4000; proxy_pass http://localhost:4000;
client_max_body_size 16m;
} }
location ~* \.(css|js)$ { location ~ ^/(js|css) {
root /home/mobilizon/live/priv/static; root /home/mobilizon/live/priv/static;
etag off; etag off;
expires 1y;
access_log off; access_log off;
add_header Cache-Control public; add_header Cache-Control "public, max-age=31536000, immutable";
}
location ~ ^/(media|proxy) {
etag off;
access_log off;
add_header Cache-Control "public, max-age=31536000, immutable";
proxy_pass http://localhost:4000;
}
error_page 500 501 502 503 504 @error;
location @error {
root /home/tcit/dev/frama/mobilizon/priv/errors;
try_files /error.html 502;
} }
} }

View File

@ -0,0 +1,31 @@
defmodule Mobilizon.Service.ErrorPageTest do
@moduledoc """
Test the error page producer module
"""
alias Mobilizon.Config
alias Mobilizon.Service.ErrorPage
use Mobilizon.DataCase
describe "init/0" do
test "renders an error page in the default language" do
ErrorPage.init()
path = Path.join(Application.app_dir(:mobilizon, "priv/errors"), "error.html")
assert File.exists?(path)
assert {:ok, data} = File.read(path)
assert data =~ "This page is not correct"
end
test "uses the instance default language if defined" do
Config.put([:instance, :default_language], "fr")
ErrorPage.init()
path = Path.join(Application.app_dir(:mobilizon, "priv/errors"), "error.html")
assert File.exists?(path)
assert {:ok, data} = File.read(path)
refute data =~ "This page is not correct"
assert data =~ "<html lang=\"fr\">"
Config.put([:instance, :default_language], "en")
end
end
end

View File

@ -17,10 +17,14 @@ defmodule Mobilizon.Web.ErrorViewTest do
end end
test "render 500.html" do test "render 500.html" do
assert render_to_string(ErrorView, "500.html", []) == "Internal server error" assert render_to_string(ErrorView, "500.html", []) =~
Phoenix.HTML.html_escape("We're sorry, but something went wrong on our end.")
|> Phoenix.HTML.safe_to_string()
end end
test "render any other" do test "render any other" do
assert render_to_string(ErrorView, "505.html", []) == "Internal server error" assert render_to_string(ErrorView, "505.html", []) =~
Phoenix.HTML.html_escape("We're sorry, but something went wrong on our end.")
|> Phoenix.HTML.safe_to_string()
end end
end end