diff options
author | Ekaterina Vaartis <vaartis@cock.li> | 2019-04-18 18:04:02 +0300 |
---|---|---|
committer | Ekaterina Vaartis <vaartis@cock.li> | 2019-04-20 11:17:17 +0300 |
commit | a141f0807bc84868fb84e3d628ab8f99f429d5c0 (patch) | |
tree | 872642c635c33ecd735981f57384a7a4aa85cbf4 /lib/mix | |
parent | eff725c3af4537b2d993f85a236636cd5d5e17d0 (diff) | |
download | pleroma-a141f0807bc84868fb84e3d628ab8f99f429d5c0.tar.gz |
Assume packs without emoji.txt only have emoji pictures, unhardcode
unhardcode: remove hardcoded /instance/static and actually use the config option
as it is used in other places.
packs without emoji.txt: these are now assumed to have .png files that
are all emojis, their names are used as shortcodes
Diffstat (limited to 'lib/mix')
-rw-r--r-- | lib/mix/tasks/pleroma/emoji.ex | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/lib/mix/tasks/pleroma/emoji.ex b/lib/mix/tasks/pleroma/emoji.ex index 2126588b1..4fb383b61 100644 --- a/lib/mix/tasks/pleroma/emoji.ex +++ b/lib/mix/tasks/pleroma/emoji.ex @@ -115,11 +115,14 @@ defmodule Mix.Tasks.Pleroma.Emoji do IO.puts(IO.ANSI.format(["Writing emoji.txt for ", :bright, pack_name])) + common_pack_path = Path.join([ + "/", Pleroma.Config.get!([:instance, :static_dir]), "emoji", pack_name + ]) emoji_txt_str = Enum.map( files, fn {shortcode, path} -> - "#{shortcode}, /instance/static/emoji/#{pack_name}/#{path}" + "#{shortcode}, #{Path.join(common_pack_path, path)}" end ) |> Enum.join("\n") @@ -182,11 +185,8 @@ defmodule Mix.Tasks.Pleroma.Emoji do cwd: tmp_pack_dir ) - emoji_map = - find_all_emoji(tmp_pack_dir, exts) |> - Enum.map(&Path.relative_to(&1, tmp_pack_dir)) |> - Enum.map(fn f -> {f |> Path.basename() |> Path.rootname(), f} end) |> - Enum.into(%{}) + emoji_map = Pleroma.Emoji.make_shortcode_to_file_map(tmp_pack_dir, exts) + File.write!(files_name, Poison.encode!(emoji_map, pretty: true)) @@ -219,21 +219,6 @@ defmodule Mix.Tasks.Pleroma.Emoji do end - defp find_all_emoji(dir, exts) do - Enum.reduce( - File.ls!(dir), - [], - fn f, acc -> - filepath = Path.join(dir, f) - if File.dir?(filepath) do - acc ++ find_all_emoji(filepath, exts) - else - acc ++ [filepath] - end - end - ) |> Enum.filter(fn f -> Path.extname(f) in exts end) - end - defp fetch_manifest(from) do Tesla.get!(from).body |> Poison.decode!() end |