Haytni v0.0.1 HaytniWeb.Shared View Source
Contains shared stuffs between Haytni base plugins.
Mainly handle a message view/template which is intended to replace “abusive” Phoenix.Controller.put_flash/3
.
put_flash
stores messages in session and may have several issues:
- it can conflict if you use multiple tabs or instances of a same browser
- excessive reads/writes (depending on the backend)
- incompatible with HTTP caching
Link to this section Summary
Functions
Momorize the original HTTP referer by adding it to a changeset. Have to be called on new
or edit
action
(not create
nor update
)
Add a back/cancel link for MessageView
Add a next step link for MessageView
Set connection to render MessageView/message.html
Link to this section Functions
add_referer_to_changeset(conn :: Plug.Conn.t(), changeset :: Ecto.Changeset.t()) :: Ecto.Changeset.t()
Momorize the original HTTP referer by adding it to a changeset. Have to be called on new
or edit
action
(not create
nor update
).
back_link(conn :: Plug.Conn.t(), struct :: struct(), default :: String.t()) :: Plug.Conn.t()
Add a back/cancel link for MessageView.
NOTE: we do not use "javascript:history.back()"
as default since this may be inappropriate with Content
Security Policy (CSP). But user is free to use it by indicating it as value for default.
next_step_link(conn :: Plug.Conn.t(), href :: String.t(), text :: String.t()) :: Plug.Conn.t()
Add a next step link for MessageView.
render_message(conn :: Plug.Conn.t(), message :: String.t(), type :: atom()) :: Plug.Conn.t()
Set connection to render MessageView/message.html.