proxy emojis
(i fix emojos better than gargon but sshhhhh)
This commit is contained in:
parent
8e82547179
commit
f909aec050
2 changed files with 4 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
||||||
defmodule Pleroma.Formatter do
|
defmodule Pleroma.Formatter do
|
||||||
alias Pleroma.User
|
alias Pleroma.User
|
||||||
|
alias Pleroma.Web.MediaProxy
|
||||||
|
|
||||||
@link_regex ~r/https?:\/\/[\w\.\/?=\-#%&@~\(\)]+[\w\/]/u
|
@link_regex ~r/https?:\/\/[\w\.\/?=\-#%&@~\(\)]+[\w\/]/u
|
||||||
def linkify(text) do
|
def linkify(text) do
|
||||||
|
@ -125,7 +126,7 @@ defmodule Pleroma.Formatter do
|
||||||
end
|
end
|
||||||
|
|
||||||
Enum.reduce(all_emoji, text, fn ({emoji, file}, text) ->
|
Enum.reduce(all_emoji, text, fn ({emoji, file}, text) ->
|
||||||
String.replace(text, ":#{emoji}:", "<img height='32px' width='32px' alt='#{emoji}' title='#{emoji}' src='#{file}' />")
|
String.replace(text, ":#{emoji}:", "<img height='32px' width='32px' alt='#{emoji}' title='#{emoji}' src='#{MediaProxy.url(file)}' />")
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,8 @@ defmodule Pleroma.Web.MediaProxy do
|
||||||
|
|
||||||
def url(nil), do: nil
|
def url(nil), do: nil
|
||||||
|
|
||||||
|
def url(url = "/" <> _), do: url
|
||||||
|
|
||||||
def url(url) do
|
def url(url) do
|
||||||
config = Application.get_env(:pleroma, :media_proxy, [])
|
config = Application.get_env(:pleroma, :media_proxy, [])
|
||||||
if !Keyword.get(config, :enabled, false) or String.starts_with?(url, Pleroma.Web.base_url) do
|
if !Keyword.get(config, :enabled, false) or String.starts_with?(url, Pleroma.Web.base_url) do
|
||||||
|
|
Loading…
Reference in a new issue