mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 00:26:30 +00:00
RedirectController: Unify server-generated-meta insertion code
This commit is contained in:
parent
a5aa8ea796
commit
5d3e145dc4
1 changed files with 14 additions and 19 deletions
|
@ -17,19 +17,24 @@ defmodule Pleroma.Web.Fallback.RedirectController do
|
|||
|> json(%{error: "Not implemented"})
|
||||
end
|
||||
|
||||
def redirector(conn, _params, code \\ 200) do
|
||||
{:ok, index_content} = File.read(index_file_path())
|
||||
|
||||
def add_generated_metadata(page_content, extra \\ "") do
|
||||
title = "<title>#{Pleroma.Config.get([:instance, :name])}</title>"
|
||||
favicon = "<link rel='icon' href='#{Pleroma.Config.get([:instance, :favicon])}'>"
|
||||
manifest = "<link rel='manifest' href='/manifest.json'>"
|
||||
|
||||
page_content
|
||||
|> String.replace(
|
||||
"<!--server-generated-meta-->",
|
||||
title <> favicon <> manifest <> extra
|
||||
)
|
||||
end
|
||||
|
||||
def redirector(conn, _params, code \\ 200) do
|
||||
{:ok, index_content} = File.read(index_file_path())
|
||||
|
||||
response =
|
||||
index_content
|
||||
|> String.replace(
|
||||
"<!--server-generated-meta-->",
|
||||
title <> favicon <> manifest
|
||||
)
|
||||
|> add_generated_metadata()
|
||||
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|
@ -47,19 +52,12 @@ defmodule Pleroma.Web.Fallback.RedirectController do
|
|||
|
||||
def redirector_with_meta(conn, params) do
|
||||
{:ok, index_content} = File.read(index_file_path())
|
||||
|
||||
tags = build_tags(conn, params)
|
||||
preloads = preload_data(conn, params)
|
||||
title = "<title>#{Pleroma.Config.get([:instance, :name])}</title>"
|
||||
favicon = "<link rel='icon' href='#{Pleroma.Config.get([:instance, :favicon])}'>"
|
||||
manifest = "<link rel='manifest' href='/manifest.json'>"
|
||||
|
||||
response =
|
||||
index_content
|
||||
|> String.replace(
|
||||
"<!--server-generated-meta-->",
|
||||
tags <> preloads <> title <> favicon <> manifest
|
||||
)
|
||||
|> add_generated_metadata(tags <> preloads)
|
||||
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|
@ -73,13 +71,10 @@ defmodule Pleroma.Web.Fallback.RedirectController do
|
|||
def redirector_with_preload(conn, params) do
|
||||
{:ok, index_content} = File.read(index_file_path())
|
||||
preloads = preload_data(conn, params)
|
||||
title = "<title>#{Pleroma.Config.get([:instance, :name])}</title>"
|
||||
favicon = "<link rel='icon' href='#{Pleroma.Config.get([:instance, :favicon])}'>"
|
||||
manifest = "<link rel='manifest' href='/manifest.json'>"
|
||||
|
||||
response =
|
||||
index_content
|
||||
|> String.replace("<!--server-generated-meta-->", preloads <> title <> favicon <> manifest)
|
||||
|> add_generated_metadata(preloads)
|
||||
|
||||
conn
|
||||
|> put_resp_content_type("text/html")
|
||||
|
|
Loading…
Reference in a new issue