Commit 8745c8c9 authored by rinpatch's avatar rinpatch
Browse files

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

parent 2858fd2d
......@@ -7,7 +7,7 @@ def build_tags(params) 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 @@ defp opengraph_tags(%{user: user}) do
]
end
end
defp opengraph_tags(_) do
[]
end
def to_tag(data) do
with {name, attrs, _content = []} <- data do
HTML.Tag.tag(name, attrs)
......
......@@ -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 @@ defmodule Pleroma.Web.Router do
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 @@ def redirector(conn, _params) 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)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment