aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config/config.exs10
-rw-r--r--config/description.exs39
-rw-r--r--docs/configuration/cheatsheet.md29
-rw-r--r--lib/pleroma/web/masto_fe_controller.ex6
-rw-r--r--lib/pleroma/web/router.ex6
-rw-r--r--lib/pleroma/web/templates/masto_fe/index.html.eex6
-rw-r--r--lib/pleroma/web/views/masto_fe_view.ex19
7 files changed, 114 insertions, 1 deletions
diff --git a/config/config.exs b/config/config.exs
index d0766a6e2..a69d41d17 100644
--- a/config/config.exs
+++ b/config/config.exs
@@ -322,6 +322,16 @@ config :pleroma, :assets,
],
default_mascot: :pleroma_fox_tan
+config :pleroma, :manifest,
+ icons: [
+ %{
+ src: "/static/logo.png",
+ type: "image/png"
+ }
+ ],
+ theme_color: "#282c37",
+ background_color: "#191b22"
+
config :pleroma, :activitypub,
unfollow_blocked: true,
outgoing_blocks: true,
diff --git a/config/description.exs b/config/description.exs
index 571c64bc1..70e963399 100644
--- a/config/description.exs
+++ b/config/description.exs
@@ -1100,6 +1100,45 @@ 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",
+ children: [
+ %{
+ key: :icons,
+ type: {:list, :map},
+ description: "Describe the icons of the app",
+ suggestion: [
+ %{
+ src: "/static/logo.png"
+ },
+ %{
+ src: "/static/icon.png",
+ type: "image/png"
+ },
+ %{
+ src: "/static/icon.ico",
+ sizes: "72x72 96x96 128x128 256x256"
+ }
+ ]
+ },
+ %{
+ key: :theme_color,
+ type: :string,
+ description: "Describe the theme color of the app",
+ suggestions: ["#282c37", "mediumpurple"]
+ },
+ %{
+ key: :background_color,
+ type: :string,
+ description: "Describe the background color of the app",
+ suggestions: ["#191b22", "aliceblue"]
+ }
+ ]
+ },
+ %{
+ group: :pleroma,
key: :mrf_simple,
type: :group,
description: "Message Rewrite Facility",
diff --git a/docs/configuration/cheatsheet.md b/docs/configuration/cheatsheet.md
index 8d85276ed..3427ae419 100644
--- a/docs/configuration/cheatsheet.md
+++ b/docs/configuration/cheatsheet.md
@@ -247,6 +247,35 @@ relates to mascots on the mastodon frontend
* `default_mascot`: An element from `mascots` - This will be used as the default mascot
on MastoFE (default: `:pleroma_fox_tan`)
+## :manifest
+
+This section describe PWA manifest instance-specific values. Currently this option relate only for MastoFE.
+
+* `icons`: Describe the icons of the app, this a list of maps describing icons in the same way as the
+ [spec](https://www.w3.org/TR/appmanifest/#imageresource-and-its-members) describes it.
+
+ Example:
+
+ ```elixir
+ config :pleroma, :manifest,
+ icons: [
+ %{
+ src: "/static/logo.png"
+ },
+ %{
+ src: "/static/icon.png",
+ type: "image/png"
+ },
+ %{
+ src: "/static/icon.ico",
+ sizes: "72x72 96x96 128x128 256x256"
+ }
+ ]
+ ```
+
+* `theme_color`: Describe the theme color of the app. (Example: `"#282c37"`, `"rebeccapurple"`)
+* `background_color`: Describe the background color of the app. (Example: `"#191b22"`, `"aliceblue"`)
+
## :mrf_simple
* `media_removal`: List of instances to remove medias from
* `media_nsfw`: List of instances to put medias as NSFW(sensitive) from
diff --git a/lib/pleroma/web/masto_fe_controller.ex b/lib/pleroma/web/masto_fe_controller.ex
index 87860f1d5..93b38e8f4 100644
--- a/lib/pleroma/web/masto_fe_controller.ex
+++ b/lib/pleroma/web/masto_fe_controller.ex
@@ -34,6 +34,12 @@ defmodule Pleroma.Web.MastoFEController do
end
end
+ @doc "GET /web/manifest.json"
+ def manifest(conn, _params) do
+ conn
+ |> render("manifest.json")
+ end
+
@doc "PUT /api/web/settings"
def put_settings(%{assigns: %{user: user}} = conn, %{"data" => settings} = _params) do
with {:ok, _} <- User.update_info(user, &User.Info.mastodon_settings_update(&1, settings)) do
diff --git a/lib/pleroma/web/router.ex b/lib/pleroma/web/router.ex
index 66e7a2263..f2588f89e 100644
--- a/lib/pleroma/web/router.ex
+++ b/lib/pleroma/web/router.ex
@@ -593,6 +593,12 @@ defmodule Pleroma.Web.Router do
end
scope "/", Pleroma.Web do
+ pipe_through(:api)
+
+ get("/web/manifest.json", MastoFEController, :manifest)
+ end
+
+ scope "/", Pleroma.Web do
pipe_through(:mastodon_html)
get("/web/login", MastodonAPI.AuthController, :login)
diff --git a/lib/pleroma/web/templates/masto_fe/index.html.eex b/lib/pleroma/web/templates/masto_fe/index.html.eex
index feff36fae..c330960fa 100644
--- a/lib/pleroma/web/templates/masto_fe/index.html.eex
+++ b/lib/pleroma/web/templates/masto_fe/index.html.eex
@@ -4,9 +4,13 @@
<meta charset='utf-8'>
<meta content='width=device-width, initial-scale=1' name='viewport'>
<title>
-<%= Pleroma.Config.get([:instance, :name]) %>
+<%= Config.get([:instance, :name]) %>
</title>
<link rel="icon" type="image/png" href="/favicon.png"/>
+<link rel="manifest" type="applicaton/manifest+json" href="<%= masto_fe_path(Pleroma.Web.Endpoint, :manifest) %>" />
+
+<meta name="theme-color" content="<%= Config.get([:manifest, :theme_color]) %>" />
+
<script crossorigin='anonymous' src="/packs/locales.js"></script>
<script crossorigin='anonymous' src="/packs/locales/glitch/en.js"></script>
diff --git a/lib/pleroma/web/views/masto_fe_view.ex b/lib/pleroma/web/views/masto_fe_view.ex
index 21b086d4c..85b164b59 100644
--- a/lib/pleroma/web/views/masto_fe_view.ex
+++ b/lib/pleroma/web/views/masto_fe_view.ex
@@ -99,4 +99,23 @@ defmodule Pleroma.Web.MastoFEView do
defp present?(nil), do: false
defp present?(false), do: false
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.base_url(),
+ start_url: masto_fe_path(Pleroma.Web.Endpoint, :index, ["getting-started"]),
+ categories: [
+ "social"
+ ],
+ serviceworker: %{
+ src: "/sw.js"
+ }
+ }
+ end
end