Make emoji configurable in files.

This commit is contained in:
Roger Braun 2017-09-16 16:49:46 +02:00
parent 959e993c7d
commit 7c82b82197
5 changed files with 28 additions and 2 deletions

1
config/emoji.txt Normal file
View file

@ -0,0 +1 @@
firefox, /emoji/Firefox.gif

View file

@ -93,7 +93,19 @@ def parse_mentions(text) do
{finmoji, "/finmoji/128px/#{finmoji}-128.png"} {finmoji, "/finmoji/128px/#{finmoji}-128.png"}
end) 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 def emojify(text, additional \\ nil) do
all_emoji = if additional do all_emoji = if additional do

View file

@ -11,7 +11,7 @@ defmodule Pleroma.Web.Endpoint do
at: "/media", from: "uploads", gzip: false at: "/media", from: "uploads", gzip: false
plug Plug.Static, plug Plug.Static,
at: "/", from: :pleroma, 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 reloading can be explicitly enabled under the
# :code_reloader configuration of your endpoint. # :code_reloader configuration of your endpoint.

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -240,6 +240,13 @@ def get("https://social.sakamoto.gq/.well-known/webfinger?resource=https://socia
}} }}
end 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 def get("https://squeet.me/xrd/?uri=lain@squeet.me", [Accept: "application/xrd+xml"], []) do
{:ok, %Response{ {:ok, %Response{
status_code: 200, status_code: 200,
@ -259,7 +266,13 @@ def get("https://social.sakamoto.gq/objects/0ccc1a2c-66b0-4305-b23a-7f7f2b040056
status_code: 200, status_code: 200,
body: File.read!("test/fixtures/httpoison_mock/sakamoto.atom") 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 end
def get("http://social.heldscal.la/.well-known/host-meta", [], [follow_redirect: true]) do def get("http://social.heldscal.la/.well-known/host-meta", [], [follow_redirect: true]) do