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
]
end
end
+
defp opengraph_tags(_) do
[]
end
+
def to_tag(data) do
with {name, attrs, _content = []} <- data do
HTML.Tag.tag(name, attrs)
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
defmodule Fallback.RedirectController do
use Pleroma.Web, :controller
alias Pleroma.Web.Metadata
+ alias Pleroma.User
def redirector(conn, _params) do
conn
|> 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)