summaryrefslogtreecommitdiff
path: root/lib/pleroma
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pleroma')
-rw-r--r--lib/pleroma/web.ex (renamed from lib/pleroma/web/web.ex)5
-rw-r--r--lib/pleroma/web/mongoose_im/mongoose_im_controller.ex (renamed from lib/pleroma/web/mongooseim/mongoose_im_controller.ex)0
-rw-r--r--lib/pleroma/web/o_status/o_status_controller.ex (renamed from lib/pleroma/web/ostatus/ostatus_controller.ex)0
-rw-r--r--lib/pleroma/web/plug.ex8
-rw-r--r--lib/pleroma/web/push.ex (renamed from lib/pleroma/web/push/push.ex)0
-rw-r--r--lib/pleroma/web/rich_media/parsers/o_embed.ex (renamed from lib/pleroma/web/rich_media/parsers/oembed_parser.ex)0
-rw-r--r--lib/pleroma/web/streamer.ex (renamed from lib/pleroma/web/streamer/streamer.ex)0
-rw-r--r--lib/pleroma/web/twitter_api/controller.ex (renamed from lib/pleroma/web/twitter_api/twitter_api_controller.ex)0
-rw-r--r--lib/pleroma/web/web_finger.ex (renamed from lib/pleroma/web/web_finger/web_finger.ex)0
-rw-r--r--lib/pleroma/web/xml.ex (renamed from lib/pleroma/web/xml/xml.ex)0
-rw-r--r--lib/pleroma/xml_builder.ex49
11 files changed, 57 insertions, 5 deletions
diff --git a/lib/pleroma/web/web.ex b/lib/pleroma/web.ex
index 4f9281851..9ca52733d 100644
--- a/lib/pleroma/web/web.ex
+++ b/lib/pleroma/web.ex
@@ -2,11 +2,6 @@
# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
# SPDX-License-Identifier: AGPL-3.0-only
-defmodule Pleroma.Web.Plug do
- # Substitute for `call/2` which is defined with `use Pleroma.Web, :plug`
- @callback perform(Plug.Conn.t(), Plug.opts()) :: Plug.Conn.t()
-end
-
defmodule Pleroma.Web do
@moduledoc """
A module that keeps using definitions for controllers,
diff --git a/lib/pleroma/web/mongooseim/mongoose_im_controller.ex b/lib/pleroma/web/mongoose_im/mongoose_im_controller.ex
index 6cbbe8fd8..6cbbe8fd8 100644
--- a/lib/pleroma/web/mongooseim/mongoose_im_controller.ex
+++ b/lib/pleroma/web/mongoose_im/mongoose_im_controller.ex
diff --git a/lib/pleroma/web/ostatus/ostatus_controller.ex b/lib/pleroma/web/o_status/o_status_controller.ex
index de1b0b3f0..de1b0b3f0 100644
--- a/lib/pleroma/web/ostatus/ostatus_controller.ex
+++ b/lib/pleroma/web/o_status/o_status_controller.ex
diff --git a/lib/pleroma/web/plug.ex b/lib/pleroma/web/plug.ex
new file mode 100644
index 000000000..840b35072
--- /dev/null
+++ b/lib/pleroma/web/plug.ex
@@ -0,0 +1,8 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.Web.Plug do
+ # Substitute for `call/2` which is defined with `use Pleroma.Web, :plug`
+ @callback perform(Plug.Conn.t(), Plug.opts()) :: Plug.Conn.t()
+end
diff --git a/lib/pleroma/web/push/push.ex b/lib/pleroma/web/push.ex
index b80a6438d..b80a6438d 100644
--- a/lib/pleroma/web/push/push.ex
+++ b/lib/pleroma/web/push.ex
diff --git a/lib/pleroma/web/rich_media/parsers/oembed_parser.ex b/lib/pleroma/web/rich_media/parsers/o_embed.ex
index 1fe6729c3..1fe6729c3 100644
--- a/lib/pleroma/web/rich_media/parsers/oembed_parser.ex
+++ b/lib/pleroma/web/rich_media/parsers/o_embed.ex
diff --git a/lib/pleroma/web/streamer/streamer.ex b/lib/pleroma/web/streamer.ex
index 5475f18a6..5475f18a6 100644
--- a/lib/pleroma/web/streamer/streamer.ex
+++ b/lib/pleroma/web/streamer.ex
diff --git a/lib/pleroma/web/twitter_api/twitter_api_controller.ex b/lib/pleroma/web/twitter_api/controller.ex
index c2de26b0b..c2de26b0b 100644
--- a/lib/pleroma/web/twitter_api/twitter_api_controller.ex
+++ b/lib/pleroma/web/twitter_api/controller.ex
diff --git a/lib/pleroma/web/web_finger/web_finger.ex b/lib/pleroma/web/web_finger.ex
index 6629f5356..6629f5356 100644
--- a/lib/pleroma/web/web_finger/web_finger.ex
+++ b/lib/pleroma/web/web_finger.ex
diff --git a/lib/pleroma/web/xml/xml.ex b/lib/pleroma/web/xml.ex
index c69a86a1e..c69a86a1e 100644
--- a/lib/pleroma/web/xml/xml.ex
+++ b/lib/pleroma/web/xml.ex
diff --git a/lib/pleroma/xml_builder.ex b/lib/pleroma/xml_builder.ex
new file mode 100644
index 000000000..33b63a71f
--- /dev/null
+++ b/lib/pleroma/xml_builder.ex
@@ -0,0 +1,49 @@
+# Pleroma: A lightweight social networking server
+# Copyright © 2017-2020 Pleroma Authors <https://pleroma.social/>
+# SPDX-License-Identifier: AGPL-3.0-only
+
+defmodule Pleroma.XmlBuilder do
+ def to_xml({tag, attributes, content}) do
+ open_tag = make_open_tag(tag, attributes)
+
+ content_xml = to_xml(content)
+
+ "<#{open_tag}>#{content_xml}</#{tag}>"
+ end
+
+ def to_xml({tag, %{} = attributes}) do
+ open_tag = make_open_tag(tag, attributes)
+
+ "<#{open_tag} />"
+ end
+
+ def to_xml({tag, content}), do: to_xml({tag, %{}, content})
+
+ def to_xml(content) when is_binary(content) do
+ to_string(content)
+ end
+
+ def to_xml(content) when is_list(content) do
+ for element <- content do
+ to_xml(element)
+ end
+ |> Enum.join()
+ end
+
+ def to_xml(%NaiveDateTime{} = time) do
+ NaiveDateTime.to_iso8601(time)
+ end
+
+ def to_doc(content), do: ~s(<?xml version="1.0" encoding="UTF-8"?>) <> to_xml(content)
+
+ defp make_open_tag(tag, attributes) do
+ attributes_string =
+ for {attribute, value} <- attributes do
+ value = String.replace(value, "\"", "&quot;")
+ "#{attribute}=\"#{value}\""
+ end
+ |> Enum.join(" ")
+
+ [tag, attributes_string] |> Enum.join(" ") |> String.trim()
+ end
+end