|
|
@ -173,23 +173,30 @@ defmodule Pleroma.Web.TwitterAPI.UtilController do
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def emoji(conn, _params) do
|
|
|
|
def emoji(conn, _params) do
|
|
|
|
emoji_dir = Path.join(:code.priv_dir(:pleroma), "static/emoji")
|
|
|
|
static_dir = Path.join(:code.priv_dir(:pleroma), "static")
|
|
|
|
|
|
|
|
|
|
|
|
shortcode_emoji_glob =
|
|
|
|
emoji_shortcode_glob =
|
|
|
|
Path.join(
|
|
|
|
Application.get_env(:pleroma, :emoji, [])
|
|
|
|
emoji_dir,
|
|
|
|
|> Keyword.get(:shortcode_glob)
|
|
|
|
Application.get_env(:pleroma, :emoji, []) |>
|
|
|
|
|
|
|
|
Keyword.get(:glob, "by-shortcode/**/*.png")
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
shortcode_emoji =
|
|
|
|
shortcode_emoji =
|
|
|
|
Path.wildcard(shortcode_emoji_glob) |>
|
|
|
|
case emoji_shortcode_glob do
|
|
|
|
Enum.map(fn path ->
|
|
|
|
nil ->
|
|
|
|
shortcode = Path.basename(path, ".png")
|
|
|
|
[]
|
|
|
|
serve_path = Path.join("/emoji", Path.relative_to(path, emoji_dir))
|
|
|
|
|
|
|
|
{shortcode, serve_path}
|
|
|
|
glob ->
|
|
|
|
end)
|
|
|
|
Path.join(static_dir, glob)
|
|
|
|
|
|
|
|
|> Path.wildcard()
|
|
|
|
|
|
|
|
|> Enum.map(fn path ->
|
|
|
|
|
|
|
|
shortcode = Path.basename(path, ".png")
|
|
|
|
|
|
|
|
serve_path = Path.join("/", Path.relative_to(path, static_dir))
|
|
|
|
|
|
|
|
{shortcode, serve_path}
|
|
|
|
|
|
|
|
end)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
emoji = Enum.into(Formatter.get_custom_emoji(), shortcode_emoji) |> Enum.into(%{})
|
|
|
|
emoji =
|
|
|
|
|
|
|
|
Enum.into(Formatter.get_custom_emoji(), shortcode_emoji)
|
|
|
|
|
|
|
|
|> Enum.into(%{})
|
|
|
|
|
|
|
|
|
|
|
|
json(conn, emoji)
|
|
|
|
json(conn, emoji)
|
|
|
|
end
|
|
|
|
end
|
|
|
|