From 1a78e88b34c9fdb749e47cf7b03b84e66821b2d2 Mon Sep 17 00:00:00 2001 From: shibao Date: Sun, 20 Feb 2022 20:39:21 -0500 Subject: [PATCH] add page titles to registration and setting pages --- CHANGELOG.md | 4 ++++ .../controllers/user_confirmation_controller.ex | 3 ++- .../controllers/user_registration_controller.ex | 7 +++++-- .../controllers/user_reset_password_controller.ex | 7 +++++-- lib/cannery_web/controllers/user_session_controller.ex | 2 +- lib/cannery_web/controllers/user_settings_controller.ex | 4 ++-- lib/cannery_web/templates/layout/root.html.heex | 7 ++----- 7 files changed, 21 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 655a6786..c5473fe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# v0.2.3 +- Fix modals with overflowing forms +- Add page titles to registration and setting pages + # v0.2.2 - Fix loading and reconnecting pages not being fixed - Fix closing modal in some cases not triggering a page reload diff --git a/lib/cannery_web/controllers/user_confirmation_controller.ex b/lib/cannery_web/controllers/user_confirmation_controller.ex index 954ae5ee..d33cfd73 100644 --- a/lib/cannery_web/controllers/user_confirmation_controller.ex +++ b/lib/cannery_web/controllers/user_confirmation_controller.ex @@ -1,10 +1,11 @@ defmodule CanneryWeb.UserConfirmationController do use CanneryWeb, :controller + import CanneryWeb.Gettext alias Cannery.Accounts def new(conn, _params) do - render(conn, "new.html") + render(conn, "new.html", page_title: gettext("Confirm your account")) end def create(conn, %{"user" => %{"email" => email}}) do diff --git a/lib/cannery_web/controllers/user_registration_controller.ex b/lib/cannery_web/controllers/user_registration_controller.ex index 6c10f268..614362e4 100644 --- a/lib/cannery_web/controllers/user_registration_controller.ex +++ b/lib/cannery_web/controllers/user_registration_controller.ex @@ -29,8 +29,11 @@ defmodule CanneryWeb.UserRegistrationController do # renders new user registration page defp render_new(conn, invite \\ nil) do - changeset = Accounts.change_user_registration(%User{}) - conn |> render("new.html", changeset: changeset, invite: invite) + render(conn, "new.html", + changeset: Accounts.change_user_registration(%User{}), + invite: invite, + page_title: gettext("Register") + ) end def create(conn, %{"user" => %{"invite_token" => invite_token}} = attrs) do diff --git a/lib/cannery_web/controllers/user_reset_password_controller.ex b/lib/cannery_web/controllers/user_reset_password_controller.ex index 3bc79a9e..9f2242f4 100644 --- a/lib/cannery_web/controllers/user_reset_password_controller.ex +++ b/lib/cannery_web/controllers/user_reset_password_controller.ex @@ -6,7 +6,7 @@ defmodule CanneryWeb.UserResetPasswordController do plug :get_user_by_reset_password_token when action in [:edit, :update] def new(conn, _params) do - render(conn, "new.html") + render(conn, "new.html", page_title: gettext("Forgot your password?")) end def create(conn, %{"user" => %{"email" => email}}) do @@ -31,7 +31,10 @@ defmodule CanneryWeb.UserResetPasswordController do end 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 # Do not log in the user after reset password to avoid a diff --git a/lib/cannery_web/controllers/user_session_controller.ex b/lib/cannery_web/controllers/user_session_controller.ex index 774ec01f..dbb901b2 100644 --- a/lib/cannery_web/controllers/user_session_controller.ex +++ b/lib/cannery_web/controllers/user_session_controller.ex @@ -5,7 +5,7 @@ defmodule CanneryWeb.UserSessionController do alias CanneryWeb.UserAuth 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 def create(conn, %{"user" => user_params}) do diff --git a/lib/cannery_web/controllers/user_settings_controller.ex b/lib/cannery_web/controllers/user_settings_controller.ex index e3d3ffb6..312a03bb 100644 --- a/lib/cannery_web/controllers/user_settings_controller.ex +++ b/lib/cannery_web/controllers/user_settings_controller.ex @@ -1,13 +1,13 @@ defmodule CanneryWeb.UserSettingsController do use CanneryWeb, :controller - + import CanneryWeb.Gettext alias Cannery.Accounts alias CanneryWeb.{HomeLive, UserAuth} plug :assign_email_and_password_changesets def edit(conn, _params) do - render(conn, "edit.html") + render(conn, "edit.html", page_title: gettext("Settings")) end def update(conn, %{"action" => "update_email"} = params) do diff --git a/lib/cannery_web/templates/layout/root.html.heex b/lib/cannery_web/templates/layout/root.html.heex index c45c333c..43fe71e9 100644 --- a/lib/cannery_web/templates/layout/root.html.heex +++ b/lib/cannery_web/templates/layout/root.html.heex @@ -5,11 +5,8 @@ <%= csrf_meta_tag() %> - <%= if(assigns |> Map.has_key?(:page_title), - do: "#{assigns.page_title} | Cannery", - else: "Cannery" - ) - |> live_title_tag(suffix: "") %> + <%= if(assigns |> Map.has_key?(:page_title), do: @page_title, else: "Cannery") + |> live_title_tag(suffix: " | Cannery") %>