diff options
author | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2019-02-12 14:59:34 +0100 |
---|---|---|
committer | Haelwenn (lanodan) Monnier <contact@hacktivis.me> | 2019-05-03 16:27:50 +0200 |
commit | 2f76a40d028c45e99425b061298a1b05e4b59923 (patch) | |
tree | 6a3f9ee4e90915dd6d44422f92969b3d856b44c2 /lib/pleroma/formatter.ex | |
parent | d70af32127bda1431bacad58e7c6516a2e652fcd (diff) | |
download | pleroma-2f76a40d028c45e99425b061298a1b05e4b59923.tar.gz |
formatter.ex: Add get_emoji_map/1
Diffstat (limited to 'lib/pleroma/formatter.ex')
-rw-r--r-- | lib/pleroma/formatter.ex | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/pleroma/formatter.ex b/lib/pleroma/formatter.ex index 0ec6bcee0..3d7c36d21 100644 --- a/lib/pleroma/formatter.ex +++ b/lib/pleroma/formatter.ex @@ -128,12 +128,23 @@ defmodule Pleroma.Formatter do def demojify(text, nil), do: text + @doc "Outputs a list of the emoji-shortcodes in a text" def get_emoji(text) when is_binary(text) do Enum.filter(Emoji.get_all(), fn {emoji, _, _} -> String.contains?(text, ":#{emoji}:") end) end def get_emoji(_), do: [] + @doc "Outputs a list of the emoji-Maps in a text" + def get_emoji_map(text) when is_binary(text) do + get_emoji(text) + |> Enum.reduce(%{}, fn {name, file, _group}, acc -> + Map.put(acc, name, "#{Pleroma.Web.Endpoint.static_url()}#{file}") + end) + end + + def get_emoji_map(_), do: [] + def html_escape({text, mentions, hashtags}, type) do {html_escape(text, type), mentions, hashtags} end |