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