2020-01-26 20:36:50 +00:00
|
|
|
defmodule Mobilizon.Web do
|
2017-12-08 08:58:14 +00: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 20:36:50 +00:00
|
|
|
use Mobilizon.Web, :controller
|
|
|
|
use Mobilizon.Web, :view
|
2017-12-08 08:58:14 +00: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 20:36:50 +00:00
|
|
|
use Phoenix.Controller, namespace: Mobilizon.Web
|
2017-12-08 08:58:14 +00:00
|
|
|
import Plug.Conn
|
2020-01-26 20:36:50 +00:00
|
|
|
import Mobilizon.Web.Router.Helpers
|
|
|
|
import Mobilizon.Web.Gettext
|
2017-12-08 08:58:14 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def view do
|
|
|
|
quote do
|
2018-07-27 08:45:35 +00:00
|
|
|
use Phoenix.View,
|
2020-01-26 20:36:50 +00:00
|
|
|
root: "lib/web/templates",
|
2021-03-23 14:18:03 +00:00
|
|
|
pattern: "**/*",
|
2020-01-26 20:36:50 +00:00
|
|
|
namespace: Mobilizon.Web
|
2017-12-08 08:58:14 +00:00
|
|
|
|
|
|
|
# Import convenience functions from controllers
|
|
|
|
import Phoenix.Controller, only: [get_flash: 2, view_module: 1]
|
|
|
|
|
|
|
|
# Use all HTML functionality (forms, tags, etc)
|
|
|
|
use Phoenix.HTML
|
|
|
|
|
2020-01-26 20:36:50 +00:00
|
|
|
import Mobilizon.Web.Router.Helpers
|
|
|
|
import Mobilizon.Web.ErrorHelpers
|
|
|
|
import Mobilizon.Web.Gettext
|
2017-12-08 08:58:14 +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
|
2020-01-26 20:36:50 +00:00
|
|
|
import Mobilizon.Web.Gettext
|
2017-12-08 08:58:14 +00: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
|