Add support for configuring a favicon and embed PWA manifest in server-generated-meta
This commit is contained in:
parent
bf2d6abaf2
commit
a5aa8ea796
1
changelog.d/favicon.add
Normal file
1
changelog.d/favicon.add
Normal file
@ -0,0 +1 @@
|
|||||||
|
Add support for configuring favicon, embed favicon and PWA manifest in server-generated meta
|
@ -171,6 +171,7 @@ config :pleroma, :instance,
|
|||||||
short_description: "",
|
short_description: "",
|
||||||
background_image: "/images/city.jpg",
|
background_image: "/images/city.jpg",
|
||||||
instance_thumbnail: "/instance/thumbnail.jpeg",
|
instance_thumbnail: "/instance/thumbnail.jpeg",
|
||||||
|
favicon: "/favicon.png",
|
||||||
limit: 5_000,
|
limit: 5_000,
|
||||||
description_limit: 5_000,
|
description_limit: 5_000,
|
||||||
remote_limit: 100_000,
|
remote_limit: 100_000,
|
||||||
@ -346,6 +347,8 @@ config :pleroma, :manifest,
|
|||||||
icons: [
|
icons: [
|
||||||
%{
|
%{
|
||||||
src: "/static/logo.svg",
|
src: "/static/logo.svg",
|
||||||
|
sizes: "144x144",
|
||||||
|
purpose: "any",
|
||||||
type: "image/svg+xml"
|
type: "image/svg+xml"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -987,6 +987,12 @@ config :pleroma, :config_description, [
|
|||||||
"The instance thumbnail can be any image that represents your instance and is used by some apps or services when they display information about your instance.",
|
"The instance thumbnail can be any image that represents your instance and is used by some apps or services when they display information about your instance.",
|
||||||
suggestions: ["/instance/thumbnail.jpeg"]
|
suggestions: ["/instance/thumbnail.jpeg"]
|
||||||
},
|
},
|
||||||
|
%{
|
||||||
|
key: :favicon,
|
||||||
|
type: {:string, :image},
|
||||||
|
description: "Favicon of the instance",
|
||||||
|
suggestions: ["/favicon.png"]
|
||||||
|
},
|
||||||
%{
|
%{
|
||||||
key: :show_reactions,
|
key: :show_reactions,
|
||||||
type: :boolean,
|
type: :boolean,
|
||||||
|
@ -18,9 +18,22 @@ defmodule Pleroma.Web.Fallback.RedirectController do
|
|||||||
end
|
end
|
||||||
|
|
||||||
def redirector(conn, _params, code \\ 200) do
|
def redirector(conn, _params, code \\ 200) do
|
||||||
|
{:ok, index_content} = File.read(index_file_path())
|
||||||
|
|
||||||
|
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-->",
|
||||||
|
title <> favicon <> manifest
|
||||||
|
)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_resp_content_type("text/html")
|
|> put_resp_content_type("text/html")
|
||||||
|> send_file(code, index_file_path())
|
|> send_resp(code, response)
|
||||||
end
|
end
|
||||||
|
|
||||||
def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
|
def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
|
||||||
@ -38,10 +51,15 @@ defmodule Pleroma.Web.Fallback.RedirectController do
|
|||||||
tags = build_tags(conn, params)
|
tags = build_tags(conn, params)
|
||||||
preloads = preload_data(conn, params)
|
preloads = preload_data(conn, params)
|
||||||
title = "<title>#{Pleroma.Config.get([:instance, :name])}</title>"
|
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 =
|
response =
|
||||||
index_content
|
index_content
|
||||||
|> String.replace("<!--server-generated-meta-->", tags <> preloads <> title)
|
|> String.replace(
|
||||||
|
"<!--server-generated-meta-->",
|
||||||
|
tags <> preloads <> title <> favicon <> manifest
|
||||||
|
)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_resp_content_type("text/html")
|
|> put_resp_content_type("text/html")
|
||||||
@ -56,10 +74,12 @@ defmodule Pleroma.Web.Fallback.RedirectController do
|
|||||||
{:ok, index_content} = File.read(index_file_path())
|
{:ok, index_content} = File.read(index_file_path())
|
||||||
preloads = preload_data(conn, params)
|
preloads = preload_data(conn, params)
|
||||||
title = "<title>#{Pleroma.Config.get([:instance, :name])}</title>"
|
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 =
|
response =
|
||||||
index_content
|
index_content
|
||||||
|> String.replace("<!--server-generated-meta-->", preloads <> title)
|
|> String.replace("<!--server-generated-meta-->", preloads <> title <> favicon <> manifest)
|
||||||
|
|
||||||
conn
|
conn
|
||||||
|> put_resp_content_type("text/html")
|
|> put_resp_content_type("text/html")
|
||||||
|
Loading…
Reference in New Issue
Block a user