2017-03-17 16:09:58 +00:00
|
|
|
defmodule Pleroma.Web do
|
|
|
|
@moduledoc """
|
|
|
|
A module that keeps using definitions for controllers,
|
|
|
|
views and so on.
|
|
|
|
|
|
|
|
This can be used in your application as:
|
|
|
|
|
|
|
|
use Pleroma.Web, :controller
|
|
|
|
use Pleroma.Web, :view
|
|
|
|
|
|
|
|
The definitions below will be executed for every view,
|
|
|
|
controller, etc, so keep them short and clean, focused
|
|
|
|
on imports, uses and aliases.
|
|
|
|
|
|
|
|
Do NOT define functions inside the quoted expressions
|
|
|
|
below.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def controller do
|
|
|
|
quote do
|
|
|
|
use Phoenix.Controller, namespace: Pleroma.Web
|
|
|
|
import Plug.Conn
|
2017-04-27 13:18:50 +00:00
|
|
|
import Pleroma.Web.{Gettext, Router.Helpers}
|
2017-03-17 16:09:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def view do
|
|
|
|
quote do
|
|
|
|
use Phoenix.View, root: "lib/pleroma/web/templates",
|
|
|
|
namespace: Pleroma.Web
|
|
|
|
|
|
|
|
# Import convenience functions from controllers
|
|
|
|
import Phoenix.Controller, only: [get_csrf_token: 0, get_flash: 2, view_module: 1]
|
|
|
|
|
2017-04-27 13:18:50 +00:00
|
|
|
import Pleroma.Web.{ErrorHelpers, Gettext, Router.Helpers}
|
2017-03-17 16:09:58 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def router do
|
|
|
|
quote do
|
|
|
|
use Phoenix.Router
|
|
|
|
import Plug.Conn
|
|
|
|
import Phoenix.Controller
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def channel do
|
|
|
|
quote do
|
|
|
|
use Phoenix.Channel
|
|
|
|
import Pleroma.Web.Gettext
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
When used, dispatch to the appropriate controller/view/etc.
|
|
|
|
"""
|
|
|
|
defmacro __using__(which) when is_atom(which) do
|
|
|
|
apply(__MODULE__, which, [])
|
|
|
|
end
|
2017-03-30 12:32:36 +00:00
|
|
|
|
|
|
|
def base_url do
|
2017-05-03 12:26:49 +00:00
|
|
|
Pleroma.Web.Endpoint.url
|
2017-03-30 12:32:36 +00:00
|
|
|
end
|
2017-03-17 16:09:58 +00:00
|
|
|
end
|