mirror of
https://git.pleroma.social/pleroma/pleroma.git
synced 2024-12-23 16:40:29 +00:00
Expose /manifest.json for PWA
This commit is contained in:
parent
0b2119d4a7
commit
cb9359335f
5 changed files with 66 additions and 0 deletions
14
lib/pleroma/web/manifest_controller.ex
Normal file
14
lib/pleroma/web/manifest_controller.ex
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ManifestController do
|
||||||
|
use Pleroma.Web, :controller
|
||||||
|
|
||||||
|
plug(:skip_auth when action == :show)
|
||||||
|
|
||||||
|
@doc "GET /manifest.json"
|
||||||
|
def show(conn, _params) do
|
||||||
|
render(conn, "manifest.json")
|
||||||
|
end
|
||||||
|
end
|
|
@ -750,6 +750,12 @@ defmodule Pleroma.Web.Router do
|
||||||
get("/web/manifest.json", MastoFEController, :manifest)
|
get("/web/manifest.json", MastoFEController, :manifest)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scope "/", Pleroma.Web do
|
||||||
|
pipe_through(:api)
|
||||||
|
|
||||||
|
get("/manifest.json", ManifestController, :show)
|
||||||
|
end
|
||||||
|
|
||||||
scope "/", Pleroma.Web do
|
scope "/", Pleroma.Web do
|
||||||
pipe_through(:mastodon_html)
|
pipe_through(:mastodon_html)
|
||||||
|
|
||||||
|
|
28
lib/pleroma/web/views/manifest_view.ex
Normal file
28
lib/pleroma/web/views/manifest_view.ex
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ManifestView do
|
||||||
|
use Pleroma.Web, :view
|
||||||
|
alias Pleroma.Config
|
||||||
|
alias Pleroma.Web.Endpoint
|
||||||
|
|
||||||
|
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: Endpoint.url(),
|
||||||
|
start_url: "/",
|
||||||
|
categories: [
|
||||||
|
"social"
|
||||||
|
],
|
||||||
|
serviceworker: %{
|
||||||
|
src: "/sw.js"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
17
test/pleroma/web/manifest_controller_test.exs
Normal file
17
test/pleroma/web/manifest_controller_test.exs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
# Pleroma: A lightweight social networking server
|
||||||
|
# Copyright © 2017-2021 Pleroma Authors <https://pleroma.social/>
|
||||||
|
# SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
defmodule Pleroma.Web.ManifestControllerTest do
|
||||||
|
use Pleroma.Web.ConnCase
|
||||||
|
|
||||||
|
setup do
|
||||||
|
clear_config([:instance, :name], "Manifest Test")
|
||||||
|
clear_config([:manifest, :theme_color], "#ff0000")
|
||||||
|
end
|
||||||
|
|
||||||
|
test "manifest.json", %{conn: conn} do
|
||||||
|
conn = get(conn, "/manifest.json")
|
||||||
|
assert %{"name" => "Manifest Test", "theme_color" => "#ff0000"} = json_response(conn, 200)
|
||||||
|
end
|
||||||
|
end
|
|
@ -95,6 +95,7 @@ defmodule Pleroma.Web.Plugs.FrontendStaticPlugTest do
|
||||||
".well-known",
|
".well-known",
|
||||||
"nodeinfo",
|
"nodeinfo",
|
||||||
"web",
|
"web",
|
||||||
|
"manifest.json",
|
||||||
"auth",
|
"auth",
|
||||||
"embed",
|
"embed",
|
||||||
"proxy",
|
"proxy",
|
||||||
|
|
Loading…
Reference in a new issue