add page titles to registration and setting pages

This commit is contained in:
shibao 2022-02-20 20:39:21 -05:00
parent 968abd04ee
commit 1a78e88b34
7 changed files with 21 additions and 13 deletions

View File

@ -1,3 +1,7 @@
# v0.2.3
- Fix modals with overflowing forms
- Add page titles to registration and setting pages
# v0.2.2 # v0.2.2
- Fix loading and reconnecting pages not being fixed - Fix loading and reconnecting pages not being fixed
- Fix closing modal in some cases not triggering a page reload - Fix closing modal in some cases not triggering a page reload

View File

@ -1,10 +1,11 @@
defmodule CanneryWeb.UserConfirmationController do defmodule CanneryWeb.UserConfirmationController do
use CanneryWeb, :controller use CanneryWeb, :controller
import CanneryWeb.Gettext
alias Cannery.Accounts alias Cannery.Accounts
def new(conn, _params) do def new(conn, _params) do
render(conn, "new.html") render(conn, "new.html", page_title: gettext("Confirm your account"))
end end
def create(conn, %{"user" => %{"email" => email}}) do def create(conn, %{"user" => %{"email" => email}}) do

View File

@ -29,8 +29,11 @@ defmodule CanneryWeb.UserRegistrationController do
# renders new user registration page # renders new user registration page
defp render_new(conn, invite \\ nil) do defp render_new(conn, invite \\ nil) do
changeset = Accounts.change_user_registration(%User{}) render(conn, "new.html",
conn |> render("new.html", changeset: changeset, invite: invite) changeset: Accounts.change_user_registration(%User{}),
invite: invite,
page_title: gettext("Register")
)
end end
def create(conn, %{"user" => %{"invite_token" => invite_token}} = attrs) do def create(conn, %{"user" => %{"invite_token" => invite_token}} = attrs) do

View File

@ -6,7 +6,7 @@ defmodule CanneryWeb.UserResetPasswordController do
plug :get_user_by_reset_password_token when action in [:edit, :update] plug :get_user_by_reset_password_token when action in [:edit, :update]
def new(conn, _params) do def new(conn, _params) do
render(conn, "new.html") render(conn, "new.html", page_title: gettext("Forgot your password?"))
end end
def create(conn, %{"user" => %{"email" => email}}) do def create(conn, %{"user" => %{"email" => email}}) do
@ -31,7 +31,10 @@ defmodule CanneryWeb.UserResetPasswordController do
end end
def edit(conn, _params) do def edit(conn, _params) do
render(conn, "edit.html", changeset: Accounts.change_user_password(conn.assigns.user)) render(conn, "edit.html",
changeset: Accounts.change_user_password(conn.assigns.user),
page_title: gettext("Reset your password")
)
end end
# Do not log in the user after reset password to avoid a # Do not log in the user after reset password to avoid a

View File

@ -5,7 +5,7 @@ defmodule CanneryWeb.UserSessionController do
alias CanneryWeb.UserAuth alias CanneryWeb.UserAuth
def new(conn, _params) do def new(conn, _params) do
render(conn, "new.html", error_message: nil) render(conn, "new.html", error_message: nil, page_title: gettext("Log in"))
end end
def create(conn, %{"user" => user_params}) do def create(conn, %{"user" => user_params}) do

View File

@ -1,13 +1,13 @@
defmodule CanneryWeb.UserSettingsController do defmodule CanneryWeb.UserSettingsController do
use CanneryWeb, :controller use CanneryWeb, :controller
import CanneryWeb.Gettext
alias Cannery.Accounts alias Cannery.Accounts
alias CanneryWeb.{HomeLive, UserAuth} alias CanneryWeb.{HomeLive, UserAuth}
plug :assign_email_and_password_changesets plug :assign_email_and_password_changesets
def edit(conn, _params) do def edit(conn, _params) do
render(conn, "edit.html") render(conn, "edit.html", page_title: gettext("Settings"))
end end
def update(conn, %{"action" => "update_email"} = params) do def update(conn, %{"action" => "update_email"} = params) do

View File

@ -5,11 +5,8 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<%= csrf_meta_tag() %> <%= csrf_meta_tag() %>
<%= if(assigns |> Map.has_key?(:page_title), <%= if(assigns |> Map.has_key?(:page_title), do: @page_title, else: "Cannery")
do: "#{assigns.page_title} | Cannery", |> live_title_tag(suffix: " | Cannery") %>
else: "Cannery"
)
|> live_title_tag(suffix: "") %>
<link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")} /> <link phx-track-static rel="stylesheet" href={Routes.static_path(@conn, "/css/app.css")} />
<script <script
defer defer