Parse incoming retweets.
[akkoma] / lib / pleroma / web / web.ex
1 defmodule Pleroma.Web do
2 @moduledoc """
3 A module that keeps using definitions for controllers,
4 views and so on.
5
6 This can be used in your application as:
7
8 use Pleroma.Web, :controller
9 use Pleroma.Web, :view
10
11 The definitions below will be executed for every view,
12 controller, etc, so keep them short and clean, focused
13 on imports, uses and aliases.
14
15 Do NOT define functions inside the quoted expressions
16 below.
17 """
18
19 def controller do
20 quote do
21 use Phoenix.Controller, namespace: Pleroma.Web
22 import Plug.Conn
23 import Pleroma.Web.Router.Helpers
24 import Pleroma.Web.Gettext
25 end
26 end
27
28 def view do
29 quote do
30 use Phoenix.View, root: "lib/pleroma/web/templates",
31 namespace: Pleroma.Web
32
33 # Import convenience functions from controllers
34 import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]
35
36 import Pleroma.Web.Router.Helpers
37 import Pleroma.Web.ErrorHelpers
38 import Pleroma.Web.Gettext
39 end
40 end
41
42 def router do
43 quote do
44 use Phoenix.Router
45 import Plug.Conn
46 import Phoenix.Controller
47 end
48 end
49
50 def channel do
51 quote do
52 use Phoenix.Channel
53 import Pleroma.Web.Gettext
54 end
55 end
56
57 @doc """
58 When used, dispatch to the appropriate controller/view/etc.
59 """
60 defmacro __using__(which) when is_atom(which) do
61 apply(__MODULE__, which, [])
62 end
63
64 def base_url do
65 Pleroma.Web.Endpoint.url
66 end
67 end