Merge branch 'title-injection-change' into 'develop'
Title injection change See merge request pleroma/pleroma!3132
This commit is contained in:
commit
99bc175f02
4 changed files with 19 additions and 6 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -41,8 +41,7 @@ def redirector_with_meta(conn, params) do
|
|||
|
||||
response =
|
||||
index_content
|
||||
|> String.replace(~r/<title>.+?<\/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")
|
||||
|
|
|
@ -1 +1 @@
|
|||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,user-scalable=no"><title>Pleroma</title><!--server-generated-meta--><link rel=icon type=image/png href=/favicon.png><link href=/static/css/app.77b1644622e3bae24b6b.css rel=stylesheet><link href=/static/fontello.1600365488745.css rel=stylesheet></head><body class=hidden><noscript>To use Pleroma, please enable JavaScript.</noscript><div id=app></div><script type=text/javascript src=/static/js/vendors~app.90c4af83c1ae68f4cd95.js></script><script type=text/javascript src=/static/js/app.826c44232e0a76bbd9ba.js></script></body></html>
|
||||
<!DOCTYPE html><html lang=en><head><meta charset=utf-8><meta name=viewport content="width=device-width,initial-scale=1,user-scalable=no"><!--server-generated-meta--><link rel=icon type=image/png href=/favicon.png><link href=/static/css/app.77b1644622e3bae24b6b.css rel=stylesheet><link href=/static/fontello.1600365488745.css rel=stylesheet></head><body class=hidden><noscript>To use Pleroma, please enable JavaScript.</noscript><div id=app></div><script type=text/javascript src=/static/js/vendors~app.90c4af83c1ae68f4cd95.js></script><script type=text/javascript src=/static/js/app.826c44232e0a76bbd9ba.js></script></body></html>
|
||||
|
|
|
@ -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</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) =~ "<!--server-generated-meta-->")
|
||||
assert html_response(user_missing, 200) =~ "<!--server-generated-meta-->"
|
||||
refute html_response(user_present, 200) =~ "<!--server-generated-meta-->"
|
||||
assert html_response(user_present, 200) =~ "initial-results"
|
||||
assert html_response(user_present, 200) =~ "<title>a cool title</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) =~ "<!--server-generated-meta-->"
|
||||
assert html_response(public_page, 200) =~ "initial-results"
|
||||
assert html_response(public_page, 200) =~ "<title>a cool title</title>"
|
||||
end
|
||||
|
||||
test "GET /main/all", %{conn: conn} do
|
||||
|
|
Loading…
Reference in a new issue