diff --git a/lib/who_need_help_web/components/layouts/root.html.heex b/lib/who_need_help_web/components/layouts/root.html.heex index 7645eed..ac223ef 100644 --- a/lib/who_need_help_web/components/layouts/root.html.heex +++ b/lib/who_need_help_web/components/layouts/root.html.heex @@ -17,7 +17,13 @@ "Who Need Help connects adults who need urgent local help with nearby volunteers." } /> - <.live_title default="Who Need Help" suffix=" · Who Need Help" phx-no-format>{assigns[:page_title]} + <.live_title + default="Who Need Help" + suffix={ + if assigns[:page_title] in [nil, "", "Who Need Help"], do: "", else: " · Who Need Help" + } + phx-no-format + >{assigns[:page_title]} diff --git a/lib/who_need_help_web/controllers/content_removal_controller.ex b/lib/who_need_help_web/controllers/content_removal_controller.ex index 8243e47..aff35dc 100644 --- a/lib/who_need_help_web/controllers/content_removal_controller.ex +++ b/lib/who_need_help_web/controllers/content_removal_controller.ex @@ -6,7 +6,11 @@ defmodule WhoNeedHelpWeb.ContentRemovalController do def index(conn, _params) do notices = ContentRemoval.list_for_user(conn.assigns.current_scope) - render(conn, :index, notices: notices) + + render(conn, :index, + notices: notices, + page_title: gettext("Your content-removal notices") + ) end def new(conn, params) do @@ -46,8 +50,14 @@ defmodule WhoNeedHelpWeb.ContentRemovalController do end case result do - {:ok, notice} -> render(conn, :show, notice: notice) - {:error, :not_found} -> send_resp(conn, :not_found, "Not found") + {:ok, notice} -> + render(conn, :show, + notice: notice, + page_title: gettext("Content-removal notice %{reference}", reference: notice.reference) + ) + + {:error, :not_found} -> + send_resp(conn, :not_found, "Not found") end end @@ -72,7 +82,10 @@ defmodule WhoNeedHelpWeb.ContentRemovalController do end def received(conn, %{"reference" => reference}) when is_binary(reference) do - render(conn, :received, reference: String.slice(reference, 0, 64)) + render(conn, :received, + reference: String.slice(reference, 0, 64), + page_title: gettext("Content-removal notice received") + ) end def received(conn, _params), do: redirect(conn, to: ~p"/legal/content-removal") @@ -80,7 +93,8 @@ defmodule WhoNeedHelpWeb.ContentRemovalController do defp render_form(conn, regime, %Ecto.Changeset{} = changeset, _attrs) do render(conn, form_template(regime), form: Phoenix.Component.to_form(changeset, as: :notice), - contact_email: current_email(conn) + contact_email: current_email(conn), + page_title: content_removal_page_title(regime) ) end @@ -94,6 +108,9 @@ defmodule WhoNeedHelpWeb.ContentRemovalController do defp form_template(:take_it_down), do: :take_it_down defp form_template(_regime), do: :new + defp content_removal_page_title(:take_it_down), do: gettext("TAKE IT DOWN request") + defp content_removal_page_title(_regime), do: gettext("Report content") + defp with_contact_email(conn, attrs) do case current_email(conn) do nil -> attrs diff --git a/lib/who_need_help_web/controllers/content_removal_html/new.html.heex b/lib/who_need_help_web/controllers/content_removal_html/new.html.heex index f0a9c7d..057a3da 100644 --- a/lib/who_need_help_web/controllers/content_removal_html/new.html.heex +++ b/lib/who_need_help_web/controllers/content_removal_html/new.html.heex @@ -12,6 +12,19 @@ "Provide exact Who Need Help URLs. Do not upload or paste intimate imagery, identity documents, passwords, access codes, or unnecessary medical information." )} +
+

+ {gettext("Reporting non-consensual intimate visual material?")} +

+

+ {gettext( + "Use the dedicated urgent process. Never upload or reproduce the image or video." + )} +

+ <.link navigate={~p"/legal/take-it-down"} class="btn btn-error btn-outline btn-sm mt-3"> + {gettext("Open TAKE IT DOWN request")} + +
<.link :if={@current_scope} navigate={~p"/legal/content-removal/requests"} diff --git a/lib/who_need_help_web/controllers/feedback_controller.ex b/lib/who_need_help_web/controllers/feedback_controller.ex index 235260d..bd69806 100644 --- a/lib/who_need_help_web/controllers/feedback_controller.ex +++ b/lib/who_need_help_web/controllers/feedback_controller.ex @@ -3,6 +3,7 @@ defmodule WhoNeedHelpWeb.FeedbackController do def show(conn, _params) do render(conn, :show, + page_title: gettext("Build feedback"), session_id: Application.get_env(:who_need_help, :codex_session_id, "not-configured") ) end diff --git a/lib/who_need_help_web/controllers/google_auth_controller.ex b/lib/who_need_help_web/controllers/google_auth_controller.ex index dcc8d0e..e88a552 100644 --- a/lib/who_need_help_web/controllers/google_auth_controller.ex +++ b/lib/who_need_help_web/controllers/google_auth_controller.ex @@ -74,7 +74,8 @@ defmodule WhoNeedHelpWeb.GoogleAuthController do existing_account -> render(conn, :complete, pending: pending, - existing_account: not is_nil(existing_account) + existing_account: not is_nil(existing_account), + page_title: gettext("Continue with Google") ) end diff --git a/lib/who_need_help_web/controllers/page_controller.ex b/lib/who_need_help_web/controllers/page_controller.ex index 14028c2..32864d8 100644 --- a/lib/who_need_help_web/controllers/page_controller.ex +++ b/lib/who_need_help_web/controllers/page_controller.ex @@ -17,7 +17,13 @@ defmodule WhoNeedHelpWeb.PageController do end def safety(conn, _params) do - render(conn, :safety) + render(conn, :safety, + page_title: gettext("Safety rules"), + page_description: + gettext( + "Safety guidance for voluntary help, medicine pickup, roadside requests, location sharing, and in-person activities." + ) + ) end def terms(conn, _params) do diff --git a/lib/who_need_help_web/controllers/support_controller.ex b/lib/who_need_help_web/controllers/support_controller.ex index 9f62dc5..995760c 100644 --- a/lib/who_need_help_web/controllers/support_controller.ex +++ b/lib/who_need_help_web/controllers/support_controller.ex @@ -11,7 +11,10 @@ defmodule WhoNeedHelpWeb.SupportController do scope -> Support.list_for_user(scope) end - render(conn, :index, requests: requests) + render(conn, :index, + requests: requests, + page_title: gettext("Your support requests") + ) end def new(conn, _params) do @@ -149,7 +152,10 @@ defmodule WhoNeedHelpWeb.SupportController do end def received(conn, %{"reference" => reference}) when is_binary(reference) do - render(conn, :received, reference: String.slice(reference, 0, 64)) + render(conn, :received, + reference: String.slice(reference, 0, 64), + page_title: gettext("Support request received") + ) end def received(conn, _params), do: redirect(conn, to: ~p"/support") @@ -171,7 +177,8 @@ defmodule WhoNeedHelpWeb.SupportController do defp render_form(conn, %Ecto.Changeset{} = changeset, _attrs, page) do render(conn, page, form: Phoenix.Component.to_form(changeset, as: :support_request), - contact_email: current_email(conn) + contact_email: current_email(conn), + page_title: support_page_title(page) ) end @@ -189,4 +196,7 @@ defmodule WhoNeedHelpWeb.SupportController do defp current_email(%{assigns: %{current_scope: %{user: %{email: email}}}}), do: email defp current_email(_conn), do: nil + + defp support_page_title(:delete_account), do: gettext("Request account deletion") + defp support_page_title(_page), do: gettext("Contact support") end diff --git a/lib/who_need_help_web/controllers/user_registration_controller.ex b/lib/who_need_help_web/controllers/user_registration_controller.ex index f9f16dd..0caddba 100644 --- a/lib/who_need_help_web/controllers/user_registration_controller.ex +++ b/lib/who_need_help_web/controllers/user_registration_controller.ex @@ -16,7 +16,13 @@ defmodule WhoNeedHelpWeb.UserRegistrationController do def sent(conn, params) do email_flow = if params["flow"] == "register", do: "register", else: "login" - render(conn, :sent, email_flow: email_flow) + + page_title = + if email_flow == "register", + do: gettext("Check your email to finish registration"), + else: gettext("Sign-in request processed") + + render(conn, :sent, email_flow: email_flow, page_title: page_title) end def create(conn, %{"user" => user_params}) when is_map(user_params) do @@ -131,7 +137,8 @@ defmodule WhoNeedHelpWeb.UserRegistrationController do defp render_registration(conn, changeset) do render(conn, :new, changeset: changeset, - google_auth_enabled: GoogleAuth.enabled?() + google_auth_enabled: GoogleAuth.enabled?(), + page_title: gettext("Register") ) end diff --git a/lib/who_need_help_web/controllers/user_session_controller.ex b/lib/who_need_help_web/controllers/user_session_controller.ex index 1ddda81..5b894ac 100644 --- a/lib/who_need_help_web/controllers/user_session_controller.ex +++ b/lib/who_need_help_web/controllers/user_session_controller.ex @@ -9,6 +9,7 @@ defmodule WhoNeedHelpWeb.UserSessionController do alias WhoNeedHelpWeb.{GoogleAuthPending, UserAuth} plug :assign_magic_link_form + plug :assign_page_title plug :put_no_store def new(conn, params) do @@ -206,4 +207,6 @@ defmodule WhoNeedHelpWeb.UserSessionController do end defp put_no_store(conn, _opts), do: put_resp_header(conn, "cache-control", "no-store") + + defp assign_page_title(conn, _opts), do: assign(conn, :page_title, gettext("Log in")) end diff --git a/lib/who_need_help_web/controllers/user_settings_controller.ex b/lib/who_need_help_web/controllers/user_settings_controller.ex index 3f95026..b8b0d17 100644 --- a/lib/who_need_help_web/controllers/user_settings_controller.ex +++ b/lib/who_need_help_web/controllers/user_settings_controller.ex @@ -11,6 +11,7 @@ defmodule WhoNeedHelpWeb.UserSettingsController do plug :require_sudo_mode when action in [:edit, :update] plug :assign_email_and_password_changesets when action in [:edit, :update] + plug :assign_page_title def edit(conn, _params) do render(conn, :edit) @@ -107,6 +108,15 @@ defmodule WhoNeedHelpWeb.UserSettingsController do |> assign(:google_auth_connected, Accounts.google_auth_connected?(user)) end + defp assign_page_title(conn, _opts) do + title = + if conn.private.phoenix_action == :confirm_email_page, + do: gettext("Confirm email change"), + else: gettext("Account settings") + + assign(conn, :page_title, title) + end + defp deliver_email_change_instructions(conn, user, changeset) do case Accounts.deliver_user_update_email_instructions( Ecto.Changeset.apply_action!(changeset, :insert), diff --git a/test/who_need_help_web/controllers/page_controller_test.exs b/test/who_need_help_web/controllers/page_controller_test.exs index b350048..4480a5a 100644 --- a/test/who_need_help_web/controllers/page_controller_test.exs +++ b/test/who_need_help_web/controllers/page_controller_test.exs @@ -16,6 +16,8 @@ defmodule WhoNeedHelpWeb.PageControllerTest do assert html =~ "You stay in control of the match" assert html =~ "Find company for coffee, cinema, a walk, or a hike" assert html =~ "Before you create a request" + assert html =~ ~r/]*>Who Need Help<\/title>/ + refute html =~ "Who Need Help · Who Need Help" assert content_security_policy =~ "default-src 'self'" assert content_security_policy =~ "script-src 'self'" refute content_security_policy =~ "script-src 'self' 'unsafe-inline'" @@ -153,8 +155,12 @@ defmodule WhoNeedHelpWeb.PageControllerTest do test "GET /safety", %{conn: conn} do conn = get(conn, ~p"/safety") - assert html_response(conn, 200) =~ "Safety rules" - assert html_response(conn, 200) =~ "Not for emergencies" + html = html_response(conn, 200) + + assert html =~ "Safety rules" + assert html =~ "Not for emergencies" + assert html =~ "Safety rules · Who Need Help" + assert html =~ "Safety guidance for voluntary help" end test "GET /privacy publishes the Google data disclosure and user controls", %{conn: conn} do diff --git a/test/who_need_help_web/controllers/support_controller_test.exs b/test/who_need_help_web/controllers/support_controller_test.exs index 7250f8a..15f9034 100644 --- a/test/who_need_help_web/controllers/support_controller_test.exs +++ b/test/who_need_help_web/controllers/support_controller_test.exs @@ -7,19 +7,26 @@ defmodule WhoNeedHelpWeb.SupportControllerTest do describe "public support and removal intake" do test "renders each public form", %{conn: conn} do - assert html_response(get(conn, ~p"/support"), 200) =~ "Contact Who Need Help" - assert html_response(get(conn, ~p"/account/delete"), 200) =~ "Request account deletion" + support = html_response(get(conn, ~p"/support"), 200) + deletion = html_response(get(conn, ~p"/account/delete"), 200) + removal = html_response(get(conn, ~p"/legal/content-removal"), 200) + take_it_down = html_response(get(conn, ~p"/legal/take-it-down"), 200) - assert html_response(get(conn, ~p"/legal/content-removal"), 200) =~ - "Report illegal or harmful content" + assert support =~ "Contact Who Need Help" + assert support =~ "Contact support · Who Need Help" + assert deletion =~ "Request account deletion" + assert deletion =~ "Request account deletion · Who Need Help" + assert removal =~ "Report illegal or harmful content" + assert removal =~ "Report content · Who Need Help" + assert removal =~ "Open TAKE IT DOWN request" + assert removal =~ ~s(href="/legal/take-it-down") + assert take_it_down =~ "Do not upload the image or video" + assert take_it_down =~ "TAKE IT DOWN request · Who Need Help" assert html_response( get(conn, ~p"/legal/content-removal?location=/requests/specific-id"), 200 ) =~ "/requests/specific-id" - - assert html_response(get(conn, ~p"/legal/take-it-down"), 200) =~ - "Do not upload the image or video" end test "creates support request without exposing its status token in the redirect", %{ diff --git a/test/who_need_help_web/controllers/user_registration_controller_test.exs b/test/who_need_help_web/controllers/user_registration_controller_test.exs index ce124b3..f2df96f 100644 --- a/test/who_need_help_web/controllers/user_registration_controller_test.exs +++ b/test/who_need_help_web/controllers/user_registration_controller_test.exs @@ -10,6 +10,7 @@ defmodule WhoNeedHelpWeb.UserRegistrationControllerTest do response = html_response(conn, 200) assert get_resp_header(conn, "cache-control") == ["no-store"] assert response =~ "Register" + assert response =~ "Register · Who Need Help" assert response =~ ~p"/users/log-in" assert response =~ ~p"/users/register" assert response =~ "A password is not required" @@ -35,6 +36,7 @@ defmodule WhoNeedHelpWeb.UserRegistrationControllerTest do assert get_resp_header(conn, "cache-control") == ["no-store"] assert response =~ "Sign-in request processed" + assert response =~ "Sign-in request processed · Who Need Help" assert response =~ "Signing in does not create a new account" assert response =~ "Sign-in request accepted" assert response =~ "cannot reveal whether an account exists" @@ -48,6 +50,7 @@ defmodule WhoNeedHelpWeb.UserRegistrationControllerTest do response = conn |> get(~p"/users/check-email?flow=register") |> html_response(200) assert response =~ "Check your email to finish registration" + assert response =~ "Check your email to finish registration · Who Need Help" assert response =~ "Registration request accepted" assert response =~ "You do not need to enter your address again" refute response =~ "cannot reveal whether an account exists" diff --git a/test/who_need_help_web/controllers/user_session_controller_test.exs b/test/who_need_help_web/controllers/user_session_controller_test.exs index 4668f7f..2b66817 100644 --- a/test/who_need_help_web/controllers/user_session_controller_test.exs +++ b/test/who_need_help_web/controllers/user_session_controller_test.exs @@ -15,6 +15,7 @@ defmodule WhoNeedHelpWeb.UserSessionControllerTest do response = html_response(conn, 200) assert get_resp_header(conn, "cache-control") == ["no-store"] assert response =~ "Log in" + assert response =~ "Log in · Who Need Help" assert response =~ ~p"/users/register" assert response =~ "Email me a sign-in link" assert response =~ "Continue with Google" diff --git a/test/who_need_help_web/controllers/user_settings_controller_test.exs b/test/who_need_help_web/controllers/user_settings_controller_test.exs index a2377de..9c9e7f4 100644 --- a/test/who_need_help_web/controllers/user_settings_controller_test.exs +++ b/test/who_need_help_web/controllers/user_settings_controller_test.exs @@ -12,6 +12,7 @@ defmodule WhoNeedHelpWeb.UserSettingsControllerTest do conn = get(conn, ~p"/users/settings") response = html_response(conn, 200) assert response =~ "Settings" + assert response =~ "Account settings · Who Need Help" assert response =~ ~s(id="update_password_username") assert response =~ ~s(autocomplete="username") assert response =~ "Google sign-in"