philomena/lib/philomena_web/plugs/site_notice_plug.ex

26 lines
491 B
Elixir
Raw Permalink Normal View History

2019-11-18 18:32:23 +01:00
defmodule PhilomenaWeb.SiteNoticePlug do
@moduledoc """
This plug stores the current site-wide notices.
## Example
plug PhilomenaWeb.SiteNoticePlug
"""
alias Plug.Conn
alias Philomena.SiteNotices
@doc false
@spec init(any()) :: any()
def init(opts), do: opts
@doc false
@spec call(Plug.Conn.t(), any()) :: Plug.Conn.t()
def call(conn, _opts) do
notices = SiteNotices.active_site_notices()
conn
|> Conn.assign(:site_notices, notices)
end
2020-01-11 05:20:19 +01:00
end