web/manifest: fix icons not being user-configurable
All checks were successful
ci/woodpecker/pr/test/2 Pipeline was successful
ci/woodpecker/pr/test/1 Pipeline was successful
ci/woodpecker/push/docs Pipeline was successful
ci/woodpecker/push/publish/4 Pipeline was successful
ci/woodpecker/push/publish/1 Pipeline was successful
ci/woodpecker/push/publish/2 Pipeline was successful

The docuemnted config options only worked for the MastoFE version.
While at it, just allow all keys to be overriden by admins and
merge logic for both manifest variants.

Reported-by: Clovis <clovis@bdx.town>
This commit is contained in:
Oneric 2026-04-20 00:00:00 +00:00
commit bc4699059f
5 changed files with 21 additions and 36 deletions

View file

@ -359,16 +359,6 @@ config :pleroma, :assets,
],
default_mascot: :pleroma_fox_tan
config :pleroma, :manifest,
icons: [
%{
src: "/static/logo.svg",
type: "image/svg+xml"
}
],
theme_color: "#282c37",
background_color: "#191b22"
config :pleroma, :activitypub,
unfollow_blocked: true,
outgoing_blocks: false,

View file

@ -1496,8 +1496,7 @@ config :pleroma, :config_description, [
group: :pleroma,
key: :manifest,
type: :group,
description:
"This section describe PWA manifest instance-specific values. Currently this option relate only for MastoFE.",
description: "This section describe PWA manifest instance-specific values.",
children: [
%{
key: :icons,

View file

@ -371,7 +371,8 @@ Currently, the only option relates to mascots on masto-fe
### :manifest
This section describes PWA manifest instance-specific values. Currently this option relate only for masto-fe.
This section describes PWA manifest instance-specific values.
Almost all PWA manifest keys can be overriden or added here, below some particularly relevant examples:
* `icons`: Describe the icons of the app, this is a list of maps describing icons as
detailed in its [spec](https://www.w3.org/TR/appmanifest/#imageresource-and-its-members).

View file

@ -7,7 +7,13 @@ defmodule Pleroma.Web.ManifestView do
alias Pleroma.Config
alias Pleroma.Web.Endpoint
def render("manifest.json", _params) do
def render("manifest.json", params) do
user_overrides = Config.get([:manifest], []) |> Enum.into(%{})
api_overrides =
params[:api_manifest_overrides] ||
%{start_url: "/", serviceworker: %{src: "/sw-pleroma.js"}}
%{
name: Config.get([:instance, :name]),
description: Config.get([:instance, :description]),
@ -28,17 +34,15 @@ defmodule Pleroma.Web.ManifestView do
type: "image/png"
}
],
theme_color: Config.get([:manifest, :theme_color]),
background_color: Config.get([:manifest, :background_color]),
theme_color: "#282c37",
background_color: "#191b22",
display: "standalone",
scope: Endpoint.url(),
start_url: "/",
categories: [
"social"
],
serviceworker: %{
src: "/sw-pleroma.js"
}
]
}
|> Map.merge(user_overrides)
|> Map.merge(api_overrides)
end
end

View file

@ -8,6 +8,7 @@ defmodule Pleroma.Web.MastoFEView do
alias Pleroma.User
alias Pleroma.Web.MastodonAPI.AccountView
alias Pleroma.Web.MastodonAPI.CustomEmojiView
alias Pleroma.Web.ManifestView
def initial_state(token, user, custom_emojis) do
limit = Config.get([:instance, :limit])
@ -77,21 +78,11 @@ defmodule Pleroma.Web.MastoFEView do
defp present?(_), do: true
def render("manifest.json", _params) do
%{
name: Config.get([:instance, :name]),
description: Config.get([:instance, :description]),
icons: Config.get([:manifest, :icons]),
theme_color: Config.get([:manifest, :theme_color]),
background_color: Config.get([:manifest, :background_color]),
display: "standalone",
scope: Pleroma.Web.Endpoint.url(),
start_url: ~p"/web/getting-started",
categories: [
"social"
],
serviceworker: %{
src: "/sw.js"
ManifestView.render("manifest.json",
api_manifest_overrides: %{
start_url: ~p"/web/getting-started",
serviceworker: %{src: "/sw.js"}
}
}
)
end
end