Make emoji configurable in files.
authorRoger Braun <roger@rogerbraun.net>
Sat, 16 Sep 2017 14:49:46 +0000 (16:49 +0200)
committerRoger Braun <roger@rogerbraun.net>
Sat, 16 Sep 2017 14:49:46 +0000 (16:49 +0200)
config/emoji.txt [new file with mode: 0644]
lib/pleroma/formatter.ex
lib/pleroma/web/endpoint.ex
priv/static/emoji/Firefox.gif [new file with mode: 0644]
test/support/httpoison_mock.ex

diff --git a/config/emoji.txt b/config/emoji.txt
new file mode 100644 (file)
index 0000000..0e668e6
--- /dev/null
@@ -0,0 +1 @@
+firefox, /emoji/Firefox.gif
index e9f4bf06bf0231e089c06d58b09336347525e6aa..728d2b3e8e383da7dc4bd59f673beab8a5b5a56c 100644 (file)
@@ -93,7 +93,19 @@ defmodule Pleroma.Formatter do
     {finmoji, "/finmoji/128px/#{finmoji}-128.png"}
   end)
 
-  @emoji @finmoji_with_filenames
+  @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}
+                     end)
+                    else
+                      _ -> []
+                   end)
+
+  @emoji @finmoji_with_filenames ++ @emoji_from_file
 
   def emojify(text, additional \\ nil) do
     all_emoji = if additional do
index e869448de0d1cef67839a947c398cdaf82b4720e..a1b4108cd6e6f99fc2a3cf8abffc70889b83babc 100644 (file)
@@ -11,7 +11,7 @@ defmodule Pleroma.Web.Endpoint do
     at: "/media", from: "uploads", gzip: false
   plug Plug.Static,
     at: "/", from: :pleroma,
-    only: ~w(index.html static finmoji)
+    only: ~w(index.html static finmoji emoji)
 
   # Code reloading can be explicitly enabled under the
   # :code_reloader configuration of your endpoint.
diff --git a/priv/static/emoji/Firefox.gif b/priv/static/emoji/Firefox.gif
new file mode 100644 (file)
index 0000000..27e29b9
Binary files /dev/null and b/priv/static/emoji/Firefox.gif differ
index 091fb9dede3b8401b5f8fa936e5f773b3c8db1f9..21607ba95ed510f61bf3cc24e08c4c096756b16b 100644 (file)
@@ -240,6 +240,13 @@ defmodule HTTPoisonMock do
     }}
   end
 
+  def get("https://pleroma.soykaf.com/.well-known/webfinger?resource=https://pleroma.soykaf.com/users/shp", [Accept: "application/xrd+xml"], []) do
+    {:ok, %Response{
+      status_code: 200,
+      body: File.read!("test/fixtures/httpoison_mock/shp@pleroma.soykaf.com.webfigner")
+    }}
+  end
+
   def get("https://squeet.me/xrd/?uri=lain@squeet.me", [Accept: "application/xrd+xml"], []) do
     {:ok, %Response{
       status_code: 200,
@@ -259,7 +266,13 @@ defmodule HTTPoisonMock do
       status_code: 200,
       body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom")
     }}
+  end
 
+  def get("https://pleroma.soykaf.com/users/shp/feed.atom", _, _) do
+    {:ok, %Response{
+      status_code: 200,
+      body: File.read!("test/fixtures/httpoison_mock/shp@pleroma.soykaf.com.feed")
+    }}
   end
 
   def get("http://social.heldscal.la/.well-known/host-meta", [], [follow_redirect: true]) do