Improve Backend Error page

Mostly handle things properly when the front-end is missing

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-03-09 19:39:54 +01:00
parent 2133287e26
commit 57662aa690
49 changed files with 4551 additions and 4284 deletions

View File

@@ -63,16 +63,26 @@ defmodule Mobilizon.Web.PageView do
def render(page, %{object: object, conn: conn} = _assigns)
when page in ["actor.html", "event.html", "comment.html", "post.html"] do
locale = get_locale(conn)
tags = object |> Metadata.build_tags(locale)
inject_tags(tags, locale)
with locale <- get_locale(conn),
tags <- object |> Metadata.build_tags(locale),
{:ok, html} <- inject_tags(tags, locale) do
html
else
{:error, error} ->
return_error(conn, error)
end
end
# Discussions are private, no need to embed metadata
def render("discussion.html", params), do: render("index.html", params)
def render("index.html", %{conn: conn}) do
tags = Instance.build_tags()
inject_tags(tags, get_locale(conn))
with tags <- Instance.build_tags(),
{:ok, html} <- inject_tags(tags, get_locale(conn)) do
html
else
{:error, error} ->
return_error(conn, error)
end
end
end