Remove @providers and call Pleroma.config on runtime
[akkoma] / lib / pleroma / web / metadata.ex
1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2019 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
4 defmodule Pleroma.Web.Metadata do
5 alias Phoenix.HTML
6
7 def build_tags(params) do
8 Enum.reduce(Pleroma.Config.get([__MODULE__, :providers], []), "", fn parser, acc ->
9 rendered_html =
10 params
11 |> parser.build_tags()
12 |> Enum.map(&to_tag/1)
13 |> Enum.map(&HTML.safe_to_string/1)
14 |> Enum.join()
15
16 acc <> rendered_html
17 end)
18 end
19
20 def to_tag(data) do
21 with {name, attrs, _content = []} <- data do
22 HTML.Tag.tag(name, attrs)
23 else
24 {name, attrs, content} ->
25 HTML.Tag.content_tag(name, content, attrs)
26
27 _ ->
28 raise ArgumentError, message: "make_tag invalid args"
29 end
30 end
31 end