Split emoji to default and custom.
authoreal <eal@waifu.club>
Wed, 31 Jan 2018 14:23:31 +0000 (16:23 +0200)
committereal <eal@waifu.club>
Wed, 31 Jan 2018 14:29:22 +0000 (16:29 +0200)
config/emoji_default.txt [moved from config/emoji.txt with 100% similarity]
lib/pleroma/formatter.ex

similarity index 100%
rename from config/emoji.txt
rename to config/emoji_default.txt
index 8b736797bf0299852f46a9c9d881422a2bb497ba..fdf91f56e4877cc3c2c5e8aaf02db7e279170fb9 100644 (file)
@@ -104,13 +104,19 @@ defmodule Pleroma.Formatter do
     {finmoji, "/finmoji/128px/#{finmoji}-128.png"}
   end)
 
-  @emoji_from_file (with {:ok, file} <- File.read("config/emoji.txt") do
-                     file
-                     |> String.trim
-                     |> String.split("\n")
-                     |> Enum.map(fn(line) ->
-                       [name, file] = String.split(line, ", ")
-                       {name, file}
+  @emoji_from_file (with {:ok, default} <- File.read("config/emoji.txt") do
+                      custom =
+                        with {:ok, custom} <- File.read("config/custom_emoji.txt") do
+                          custom
+                        else
+                          _e -> ""
+                        end
+                      (default <> "\n" <> custom)
+                      |> String.trim()
+                      |> String.split(~r/\n+/)
+                      |> Enum.map(fn(line) ->
+                        [name, file] = String.split(line, ~r/,\s*/)
+                        {name, file}
                      end)
                     else
                       _ -> []