add dev email preview route
This commit is contained in:
parent
776d8a0250
commit
8cb8294ffd
23
lib/cannery_web/controllers/email_controller.ex
Normal file
23
lib/cannery_web/controllers/email_controller.ex
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
defmodule CanneryWeb.EmailController do
|
||||||
|
@moduledoc """
|
||||||
|
A dev controller used to develop on emails
|
||||||
|
"""
|
||||||
|
|
||||||
|
use CanneryWeb, :controller
|
||||||
|
alias Cannery.Accounts.User
|
||||||
|
|
||||||
|
plug :put_layout, {CanneryWeb.LayoutView, :email}
|
||||||
|
|
||||||
|
@sample_assigns %{
|
||||||
|
email: %{subject: "Example subject"},
|
||||||
|
url: "https://cannery.bubbletea.dev/sample_url",
|
||||||
|
user: %User{email: "sample@email.com"}
|
||||||
|
}
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Debug route used to preview emails
|
||||||
|
"""
|
||||||
|
def preview(conn, %{"id" => template}) do
|
||||||
|
render(conn, "#{template |> to_string()}.html", @sample_assigns)
|
||||||
|
end
|
||||||
|
end
|
@ -114,5 +114,9 @@ defmodule CanneryWeb.Router do
|
|||||||
|
|
||||||
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
forward "/mailbox", Plug.Swoosh.MailboxPreview
|
||||||
end
|
end
|
||||||
|
|
||||||
|
scope "/dev" do
|
||||||
|
get "/preview/:id", CanneryWeb.EmailController, :preview
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
1
lib/cannery_web/templates/layout/empty.html.heex
Normal file
1
lib/cannery_web/templates/layout/empty.html.heex
Normal file
@ -0,0 +1 @@
|
|||||||
|
<%= @inner_content %>
|
Loading…
Reference in New Issue
Block a user