2020-01-26 21:36:50 +01:00
|
|
|
defmodule Mobilizon.Web do
|
2017-12-08 09:58:14 +01:00
|
|
|
@moduledoc """
|
|
|
|
The entrypoint for defining your web interface, such
|
|
|
|
as controllers, views, channels and so on.
|
|
|
|
|
|
|
|
This can be used in your application as:
|
|
|
|
|
2020-01-26 21:36:50 +01:00
|
|
|
use Mobilizon.Web, :controller
|
|
|
|
use Mobilizon.Web, :view
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
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. Instead, define any helper function in modules
|
|
|
|
and import those modules here.
|
|
|
|
"""
|
|
|
|
|
|
|
|
def controller do
|
|
|
|
quote do
|
2020-01-26 21:36:50 +01:00
|
|
|
use Phoenix.Controller, namespace: Mobilizon.Web
|
2017-12-08 09:58:14 +01:00
|
|
|
import Plug.Conn
|
2020-01-26 21:36:50 +01:00
|
|
|
import Mobilizon.Web.Gettext
|
2021-09-10 11:27:59 +02:00
|
|
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def view do
|
|
|
|
quote do
|
2018-07-27 10:45:35 +02:00
|
|
|
use Phoenix.View,
|
2020-01-26 21:36:50 +01:00
|
|
|
root: "lib/web/templates",
|
2021-03-23 15:18:03 +01:00
|
|
|
pattern: "**/*",
|
2020-01-26 21:36:50 +01:00
|
|
|
namespace: Mobilizon.Web
|
2017-12-08 09:58:14 +01:00
|
|
|
|
|
|
|
# Use all HTML functionality (forms, tags, etc)
|
|
|
|
use Phoenix.HTML
|
|
|
|
|
2021-09-10 11:27:59 +02:00
|
|
|
import Phoenix.View
|
|
|
|
import Mobilizon.Web.ErrorHelpers
|
2020-01-26 21:36:50 +01:00
|
|
|
import Mobilizon.Web.Gettext
|
2021-09-10 11:27:59 +02:00
|
|
|
alias Mobilizon.Web.Router.Helpers, as: Routes
|
2017-12-08 09:58:14 +01: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
|
2020-01-26 21:36:50 +01:00
|
|
|
import Mobilizon.Web.Gettext
|
2017-12-08 09:58:14 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@doc """
|
|
|
|
When used, dispatch to the appropriate controller/view/etc.
|
|
|
|
"""
|
|
|
|
defmacro __using__(which) when is_atom(which) do
|
|
|
|
apply(__MODULE__, which, [])
|
|
|
|
end
|
|
|
|
end
|