From 631def2df228ceb0ec8921c63b90867758e0c308 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 11 Nov 2020 17:10:59 +0100 Subject: [PATCH 1/3] RedirectController: Don't replace title, but inject into the meta --- lib/pleroma/web/fallback/redirect_controller.ex | 6 ++---- test/pleroma/web/fallback_test.exs | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/pleroma/web/fallback/redirect_controller.ex b/lib/pleroma/web/fallback/redirect_controller.ex index 712991c18..1ac1319f8 100644 --- a/lib/pleroma/web/fallback/redirect_controller.ex +++ b/lib/pleroma/web/fallback/redirect_controller.ex @@ -41,8 +41,7 @@ def redirector_with_meta(conn, params) do response = index_content - |> String.replace(~r/.+?<\/title>/, title) - |> String.replace("<!--server-generated-meta-->", tags <> preloads) + |> String.replace("<!--server-generated-meta-->", tags <> preloads <> title) conn |> put_resp_content_type("text/html") @@ -60,8 +59,7 @@ def redirector_with_preload(conn, params) do response = index_content - |> String.replace(~r/<title>.+?<\/title>/, title) - |> String.replace("<!--server-generated-meta-->", preloads) + |> String.replace("<!--server-generated-meta-->", preloads <> title) conn |> put_resp_content_type("text/html") diff --git a/test/pleroma/web/fallback_test.exs b/test/pleroma/web/fallback_test.exs index a65865860..46c7bad1c 100644 --- a/test/pleroma/web/fallback_test.exs +++ b/test/pleroma/web/fallback_test.exs @@ -20,15 +20,26 @@ test "GET /*path", %{conn: conn} do end end + test "GET /*path adds a title", %{conn: conn} do + clear_config([:instance, :name], "a cool title") + + assert conn + |> get("/") + |> html_response(200) =~ "<title>a cool title" + end + describe "preloaded data and metadata attached to" do test "GET /:maybe_nickname_or_id", %{conn: conn} do + clear_config([:instance, :name], "a cool title") + user = insert(:user) user_missing = get(conn, "/foo") user_present = get(conn, "/#{user.nickname}") - assert(html_response(user_missing, 200) =~ "") + assert html_response(user_missing, 200) =~ "" refute html_response(user_present, 200) =~ "" assert html_response(user_present, 200) =~ "initial-results" + assert html_response(user_present, 200) =~ "a cool title" end test "GET /*path", %{conn: conn} do @@ -44,10 +55,13 @@ test "GET /*path", %{conn: conn} do describe "preloaded data is attached to" do test "GET /main/public", %{conn: conn} do + clear_config([:instance, :name], "a cool title") + public_page = get(conn, "/main/public") refute html_response(public_page, 200) =~ "" assert html_response(public_page, 200) =~ "initial-results" + assert html_response(public_page, 200) =~ "a cool title" end test "GET /main/all", %{conn: conn} do From 25bd64b03ac78857dc4d560be0c75ea096080c33 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 11 Nov 2020 17:17:41 +0100 Subject: [PATCH 2/3] Bundled FE: Remove title tag --- priv/static/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/priv/static/index.html b/priv/static/index.html index f5690a8d6..e848c5f8c 100644 --- a/priv/static/index.html +++ b/priv/static/index.html @@ -1 +1 @@ -Pleroma
\ No newline at end of file +
From b0e4e0cf2a151900d29da56424f596f3defa23e3 Mon Sep 17 00:00:00 2001 From: lain Date: Wed, 11 Nov 2020 17:19:09 +0100 Subject: [PATCH 3/3] Changelog: Add info about title injection --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b15ddb943..b619bd891 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Account backup - Configuration: Add `:instance, autofollowing_nicknames` setting to provide a way to make accounts automatically follow new users that register on the local Pleroma instance. - Ability to view remote timelines, with ex. `/api/v1/timelines/public?instance=lain.com` and streams `public:remote` and `public:remote:media` +- The site title is now injected as a `title` tag like preloads or metadata. ### Changed