providers: [
Pleroma.Web.Preload.Providers.Instance,
Pleroma.Web.Preload.Providers.User,
- Pleroma.Web.Preload.Providers.Timelines
+ Pleroma.Web.Preload.Providers.Timelines,
+ Pleroma.Web.Preload.Providers.StatusNet
]
config :pleroma, :http_security,
def build_tags(_conn, params) do
preload_data =
Enum.reduce(Pleroma.Config.get([__MODULE__, :providers], []), %{}, fn parser, acc ->
- Map.merge(acc, parser.generate_terms(params))
+ terms =
+ params
+ |> parser.generate_terms()
+ |> Enum.map(fn {k, v} -> {k, Base.encode64(Jason.encode!(v))} end)
+ |> Enum.into(%{})
+
+ Map.merge(acc, terms)
end)
rendered_html =
end
def build_script_tag(content) do
- content = Base.encode64(content)
-
HTML.Tag.content_tag(:script, HTML.raw(content),
id: "initial-results",
type: "application/json"
--- /dev/null
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Preload.Providers.StatusNet do
+ alias Pleroma.Web.TwitterAPI.UtilView
+ alias Pleroma.Web.Preload.Providers.Provider
+
+ @behaviour Provider
+ @config_url :"/api/statusnet/config.json"
+
+ @impl Provider
+ def generate_terms(_params) do
+ %{}
+ |> build_config_tag()
+ end
+
+ defp build_config_tag(acc) do
+ instance = Pleroma.Config.get(:instance)
+ info_data = UtilView.status_net_config(instance)
+
+ Map.put(acc, @config_url, info_data)
+ end
+end
alias Pleroma.User
alias Pleroma.Web
alias Pleroma.Web.CommonAPI
+ alias Pleroma.Web.TwitterAPI.UtilView
alias Pleroma.Web.WebFinger
plug(Pleroma.Web.FederatingPlug when action == :remote_subscribe)
def config(%{assigns: %{format: "xml"}} = conn, _params) do
instance = Pleroma.Config.get(:instance)
-
- response = """
- <config>
- <site>
- <name>#{Keyword.get(instance, :name)}</name>
- <site>#{Web.base_url()}</site>
- <textlimit>#{Keyword.get(instance, :limit)}</textlimit>
- <closed>#{!Keyword.get(instance, :registrations_open)}</closed>
- </site>
- </config>
- """
+ response = UtilView.status_net_config(instance)
conn
|> put_resp_content_type("application/xml")
defmodule Pleroma.Web.TwitterAPI.UtilView do
use Pleroma.Web, :view
import Phoenix.HTML.Form
+ alias Pleroma.Web
+
+ def status_net_config(instance) do
+ """
+ <config>
+ <site>
+ <name>#{Keyword.get(instance, :name)}</name>
+ <site>#{Web.base_url()}</site>
+ <textlimit>#{Keyword.get(instance, :limit)}</textlimit>
+ <closed>#{!Keyword.get(instance, :registrations_open)}</closed>
+ </site>
+ </config>
+ """
+ end
end
--- /dev/null
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Preload.Providers.StatusNetTest do
+ use Pleroma.DataCase
+ alias Pleroma.Web.Preload.Providers.StatusNet
+
+ setup do: {:ok, StatusNet.generate_terms(nil)}
+
+ test "it renders the info", %{"/api/statusnet/config.json": info} do
+ assert info =~ "<name>Pleroma</name>"
+ end
+end