mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2024-11-17 22:54:40 +00:00
Move emoji glob setting to config.exs
Also, a bit of formatting, and the glob includes an "/emoji/" prefix to make it more intuitive to users
This commit is contained in:
parent
0bfbf15b37
commit
c171f9790b
2 changed files with 23 additions and 14 deletions
|
@ -12,6 +12,8 @@ config :pleroma, Pleroma.Repo, types: Pleroma.PostgresTypes
|
||||||
|
|
||||||
config :pleroma, Pleroma.Upload, uploads: "uploads"
|
config :pleroma, Pleroma.Upload, uploads: "uploads"
|
||||||
|
|
||||||
|
config :pleroma, :emoji, shortcode_glob: "/emoji/by-shortcode/**/*.png"
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
|
|
|
@ -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")
|
||||||
|
|
||||||
|
emoji_shortcode_glob =
|
||||||
|
Application.get_env(:pleroma, :emoji, [])
|
||||||
|
|> Keyword.get(:shortcode_glob)
|
||||||
|
|
||||||
shortcode_emoji_glob =
|
|
||||||
Path.join(
|
|
||||||
emoji_dir,
|
|
||||||
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}
|
|
||||||
end)
|
|
||||||
|
|
||||||
emoji = Enum.into(Formatter.get_custom_emoji(), shortcode_emoji) |> Enum.into(%{})
|
glob ->
|
||||||
|
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(%{})
|
||||||
|
|
||||||
json(conn, emoji)
|
json(conn, emoji)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue