Drop the eex template and directly use the webpack index.html
Partly reverts ff7fd460
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
defmodule MobilizonWeb.LayoutView do
|
||||
use MobilizonWeb, :view
|
||||
alias Mobilizon.Service.Metadata
|
||||
end
|
||||
|
||||
@@ -5,6 +5,8 @@ defmodule MobilizonWeb.PageView do
|
||||
use MobilizonWeb, :view
|
||||
alias Mobilizon.Actors.Actor
|
||||
alias Mobilizon.Service.ActivityPub.Utils
|
||||
alias Mobilizon.Service.Metadata
|
||||
alias Mobilizon.Service.MetadataUtils
|
||||
|
||||
def render("actor.activity-json", %{conn: %{assigns: %{object: actor}}}) do
|
||||
public_key = Mobilizon.Service.ActivityPub.Utils.pem_to_public_key_pem(actor.keys)
|
||||
@@ -82,4 +84,23 @@ defmodule MobilizonWeb.PageView do
|
||||
}
|
||||
|> Map.merge(Utils.make_json_ld_header())
|
||||
end
|
||||
|
||||
def render(page, %{object: object} = _assigns)
|
||||
when page in ["actor.html", "event.html", "comment.html"] do
|
||||
with {:ok, index_content} <- File.read(index_file_path()) do
|
||||
tags = object |> Metadata.build_tags() |> MetadataUtils.stringify_tags()
|
||||
index_content = String.replace(index_content, "<!--server-generated-meta-->", tags)
|
||||
{:safe, index_content}
|
||||
end
|
||||
end
|
||||
|
||||
def render("index.html", _assigns) do
|
||||
with {:ok, index_content} <- File.read(index_file_path()) do
|
||||
{:safe, index_content}
|
||||
end
|
||||
end
|
||||
|
||||
defp index_file_path() do
|
||||
Path.join(Application.app_dir(:mobilizon, "priv/static/js"), "index.html")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user