remove useless newlines after every tag. Make domain.com/username provide opengraph too

This commit is contained in:
rinpatch 2019-01-15 18:34:47 +03:00
parent 2858fd2da2
commit 8745c8c990
2 changed files with 15 additions and 2 deletions

View File

@ -7,7 +7,7 @@ defmodule Pleroma.Web.Metadata do
if(meta_enabled?(:opengraph), do: opengraph_tags(params), else: [])
|> Enum.map(&to_tag/1)
|> Enum.map(&HTML.safe_to_string/1)
|> Enum.join("\n")
|> Enum.join()
end
def meta_enabled?(type) do
@ -57,9 +57,11 @@ defmodule Pleroma.Web.Metadata do
]
end
end
defp opengraph_tags(_) do
[]
end
def to_tag(data) do
with {name, attrs, _content = []} <- data do
HTML.Tag.tag(name, attrs)

View File

@ -505,7 +505,8 @@ defmodule Pleroma.Web.Router do
scope "/", Fallback do
get("/registration/:token", RedirectController, :registration_page)
get("/*path", RedirectController, :redirector_with_meta)
get("/:maybe_nickname_or_id", RedirectController, :redirector_with_meta)
get("/*path", RedirectController, :redirector)
options("/*path", RedirectController, :empty)
end
@ -514,6 +515,7 @@ end
defmodule Fallback.RedirectController do
use Pleroma.Web, :controller
alias Pleroma.Web.Metadata
alias Pleroma.User
def redirector(conn, _params) do
conn
@ -521,6 +523,15 @@ defmodule Fallback.RedirectController do
|> send_file(200, index_file_path())
end
def redirector_with_meta(conn, %{"maybe_nickname_or_id" => maybe_nickname_or_id} = params) do
with %User{} = user <- User.get_cached_by_nickname_or_id(maybe_nickname_or_id) do
redirector_with_meta(conn, %{user: user})
else
nil ->
redirector(conn, params)
end
end
def redirector_with_meta(conn, params) do
{:ok, index_content} = File.read(index_file_path())
tags = Metadata.build_tags(params)