For pleroma.emoji downloaded packs, generate pack.json instead
authorEkaterina Vaartis <vaartis@cock.li>
Mon, 30 Sep 2019 13:04:30 +0000 (16:04 +0300)
committerEkaterina Vaartis <vaartis@cock.li>
Tue, 15 Oct 2019 06:53:28 +0000 (09:53 +0300)
lib/mix/tasks/pleroma/emoji.ex

index 881a6f7253b127b956dcca1a77b5833d63fbd5cb..1470b9b7279a04aa5228ede65f7da053fe4d6283 100644 (file)
@@ -158,19 +158,21 @@ defmodule Mix.Tasks.Pleroma.Emoji do
             file_list: files_to_unzip
           )
 
-        IO.puts(IO.ANSI.format(["Writing emoji.txt for ", :bright, pack_name]))
-
-        emoji_txt_str =
-          Enum.map(
-            files,
-            fn {shortcode, path} ->
-              emojo_path = Path.join("/emoji/#{pack_name}", path)
-              "#{shortcode}, #{emojo_path}"
-            end
-          )
-          |> Enum.join("\n")
-
-        File.write!(Path.join(pack_path, "emoji.txt"), emoji_txt_str)
+        IO.puts(IO.ANSI.format(["Writing pack.json for ", :bright, pack_name]))
+
+        pack_json = %{
+          pack: %{
+            "license" => pack["license"],
+            "homepage" => pack["homepage"],
+            "description" => pack["description"],
+            "fallback-src" => pack["src"],
+            "fallback-src-sha256" => pack["src_sha256"],
+            "share-files" => true
+          },
+          files: files
+        }
+
+        File.write!(Path.join(pack_path, "pack.json"), Jason.encode!(pack_json, pretty: true))
       else
         IO.puts(IO.ANSI.format([:bright, :red, "No pack named \"#{pack_name}\" found"]))
       end