Allow additionnal schemes in the config
This commit is contained in:
parent
32a55e9695
commit
d5091c3175
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"]
|
config :pleroma, :emoji, shortcode_globs: ["/emoji/custom/**/*.png"]
|
||||||
|
|
||||||
|
config :pleroma, :uri_schemes, additionnal_schemes: []
|
||||||
|
|
||||||
# Configures the endpoint
|
# Configures the endpoint
|
||||||
config :pleroma, Pleroma.Web.Endpoint,
|
config :pleroma, Pleroma.Web.Endpoint,
|
||||||
url: [host: "localhost"],
|
url: [host: "localhost"],
|
||||||
|
|
|
@ -199,10 +199,14 @@ def html_escape(text) do
|
||||||
|
|
||||||
@doc "changes scheme:... urls to html links"
|
@doc "changes scheme:... urls to html links"
|
||||||
def add_links({subs, text}) do
|
def add_links({subs, text}) do
|
||||||
|
additionnal_schemes =
|
||||||
|
Application.get_env(:pleroma, :uri_schemes, [])
|
||||||
|
|> Keyword.get(:additionnal_schemes, [])
|
||||||
|
|
||||||
links =
|
links =
|
||||||
text
|
text
|
||||||
|> String.split([" ", "\t", "<br>"])
|
|> String.split([" ", "\t", "<br>"])
|
||||||
|> Enum.filter(fn word -> String.starts_with?(word, @uri_schemes) end)
|
|> Enum.filter(fn word -> String.starts_with?(word, @uri_schemes ++ additionnal_schemes) end)
|
||||||
|> Enum.filter(fn word -> Regex.match?(@link_regex, word) end)
|
|> Enum.filter(fn word -> Regex.match?(@link_regex, word) end)
|
||||||
|> Enum.map(fn url -> {Ecto.UUID.generate(), url} end)
|
|> Enum.map(fn url -> {Ecto.UUID.generate(), url} end)
|
||||||
|> Enum.sort_by(fn {_, url} -> -String.length(url) end)
|
|> Enum.sort_by(fn {_, url} -> -String.length(url) end)
|
||||||
|
|
Loading…
Reference in New Issue