From 8b3a82c21d595dd1330f2df3672267dcaad7adac Mon Sep 17 00:00:00 2001 From: Cristen Jones Date: Wed, 13 Nov 2024 10:28:15 -0500 Subject: [PATCH] chore: remove StaticPageController (#2214) * location card was part of an older version of the stop page * chore(DotcomWeb): remove some unused things * chore: remove StaticPageController --- assets/css/_header.scss | 19 --- lib/dotcom_web.ex | 8 +- lib/dotcom_web/controllers/page_controller.ex | 5 + lib/dotcom_web/controllers/static_page.ex | 35 ----- .../controllers/static_page_controller.ex | 24 ---- lib/dotcom_web/router.ex | 8 +- .../templates/layout/_new_header.html.heex | 2 +- .../layout/_new_nav_desktop.html.eex | 2 +- .../layout/_new_nav_mobile.html.heex | 2 +- lib/dotcom_web/templates/page/menu.html.heex | 24 ++++ .../templates/static_page/_link.html.eex | 7 - .../templates/static_page/about.html.eex | 35 ----- .../static_page/getting_around.html.eex | 32 ----- .../templates/static_page/menu.html.eex | 20 --- lib/dotcom_web/views/fare_view.ex | 8 +- lib/dotcom_web/views/layout_view.ex | 10 +- lib/dotcom_web/views/partial/location_card.ex | 63 --------- lib/dotcom_web/views/static_page_view.ex | 3 - .../static_page_controller_test.exs | 27 ---- test/dotcom_web/views/fare_view_test.exs | 4 +- .../views/partial/location_card_test.exs | 133 ------------------ 21 files changed, 48 insertions(+), 423 deletions(-) delete mode 100644 lib/dotcom_web/controllers/static_page.ex delete mode 100644 lib/dotcom_web/controllers/static_page_controller.ex create mode 100644 lib/dotcom_web/templates/page/menu.html.heex delete mode 100644 lib/dotcom_web/templates/static_page/_link.html.eex delete mode 100644 lib/dotcom_web/templates/static_page/about.html.eex delete mode 100644 lib/dotcom_web/templates/static_page/getting_around.html.eex delete mode 100644 lib/dotcom_web/templates/static_page/menu.html.eex delete mode 100644 lib/dotcom_web/views/partial/location_card.ex delete mode 100644 lib/dotcom_web/views/static_page_view.ex delete mode 100644 test/dotcom_web/controllers/static_page_controller_test.exs delete mode 100644 test/dotcom_web/views/partial/location_card_test.exs diff --git a/assets/css/_header.scss b/assets/css/_header.scss index a7906a1f9e..ac4579e63b 100644 --- a/assets/css/_header.scss +++ b/assets/css/_header.scss @@ -430,22 +430,3 @@ nav.m-menu--mobile { padding: unset; width: 30px; } - -// /menu page -.m-menu--page { - margin-bottom: 4 * $base-spacing; - - .m-menu__link { - padding-left: 0; - } - - h3 { - line-height: 2; - margin-bottom: .5 * $base-spacing; - margin-top: $base-spacing; - } - - hr { - margin: 0; - } -} diff --git a/lib/dotcom_web.ex b/lib/dotcom_web.ex index a5898e6eee..fb1acaf672 100644 --- a/lib/dotcom_web.ex +++ b/lib/dotcom_web.ex @@ -18,12 +18,6 @@ defmodule DotcomWeb do def static_paths, do: ~w(css js fonts icon-svg images favicon robots.txt) - def model do - quote do - # Define common model functionality - end - end - def controller do quote do use Gettext, backend: DotcomWeb.Gettext @@ -135,7 +129,7 @@ defmodule DotcomWeb do use MbtaMetro import DotcomWeb.{Components, ErrorHelpers} - import Phoenix.{HTML, LiveView.Helpers, View} + import Phoenix.{HTML, LiveView.Helpers} import PhoenixHTMLHelpers.Form, except: [label: 1] import PhoenixHTMLHelpers.{Format, Link, Tag} diff --git a/lib/dotcom_web/controllers/page_controller.ex b/lib/dotcom_web/controllers/page_controller.ex index f08da10ff6..114dcc5e37 100644 --- a/lib/dotcom_web/controllers/page_controller.ex +++ b/lib/dotcom_web/controllers/page_controller.ex @@ -45,6 +45,11 @@ defmodule DotcomWeb.PageController do |> render("index.html") end + def menu(conn, _params) do + conn + |> render("menu.html") + end + @spec fares(map) :: Paragraph.t() | nil defp fares(query_params) do case Repo.get_paragraph("paragraphs/multi-column/homepage-fares", query_params) do diff --git a/lib/dotcom_web/controllers/static_page.ex b/lib/dotcom_web/controllers/static_page.ex deleted file mode 100644 index de1f8f0932..0000000000 --- a/lib/dotcom_web/controllers/static_page.ex +++ /dev/null @@ -1,35 +0,0 @@ -defmodule DotcomWeb.StaticPage do - @moduledoc """ - Logic for pages which simply render a static template with no additional logic. Separated into its - own module in order to allow use at compile time in other modules. - """ - - @static_pages [ - %{ - key: :about, - meta_description: - "Information about the Massachusetts Bay Transportation Authority (MBTA), " <> - "including leadership, business opportunities, projects and initiatives, and financials." - }, - %{ - key: :getting_around, - meta_description: - "Navigate public transit in the Greater Boston region. Routes, schedules, " <> - "trip planner, service alerts, real-time updates, and general information." - }, - %{ - key: :menu, - meta_description: "Browse the key areas of the MBTA website." - } - ] - - def static_pages, do: Enum.map(@static_pages, & &1.key) - - def meta_description(key), do: Enum.find(@static_pages, &(&1.key == key)).meta_description - - def convert_path(path) do - path - |> Atom.to_string() - |> String.replace("_", "-") - end -end diff --git a/lib/dotcom_web/controllers/static_page_controller.ex b/lib/dotcom_web/controllers/static_page_controller.ex deleted file mode 100644 index 4ffb772388..0000000000 --- a/lib/dotcom_web/controllers/static_page_controller.ex +++ /dev/null @@ -1,24 +0,0 @@ -defmodule DotcomWeb.StaticPageController do - @moduledoc "Controller for paths which just render a simple static page." - use DotcomWeb, :controller - alias DotcomWeb.StaticPage - - for page <- StaticPage.static_pages() do - def unquote(page)(conn, _params) do - conn - |> assign(:breadcrumbs, build_breadcrumb(unquote(page))) - |> assign(:meta_description, StaticPage.meta_description(unquote(page))) - |> render("#{unquote(page)}.html") - end - end - - @spec build_breadcrumb(atom) :: [Breadcrumb.t()] - def build_breadcrumb(page) do - page - |> Atom.to_string() - |> String.split("_") - |> Enum.map_join(" ", &String.capitalize/1) - |> Breadcrumb.build() - |> List.wrap() - end -end diff --git a/lib/dotcom_web/router.ex b/lib/dotcom_web/router.ex index 919868ebc6..4ccb500049 100644 --- a/lib/dotcom_web/router.ex +++ b/lib/dotcom_web/router.ex @@ -21,8 +21,6 @@ defmodule DotcomWeb.Router do end) end - alias DotcomWeb.StaticPage - pipeline :secure do if force_ssl = Application.compile_env(:dotcom, :secure_pipeline)[:force_ssl] do plug(Plug.SSL, force_ssl) @@ -144,6 +142,7 @@ defmodule DotcomWeb.Router do get("/schedules/70A/*path_params", Redirector, to: "/betterbus-61-70-70A") get("/", PageController, :index) + get("/menu", PageController, :menu) get("/events", EventController, :index) get("/events/icalendar/*path_params", EventController, :icalendar) @@ -234,11 +233,6 @@ defmodule DotcomWeb.Router do post("/search/query", SearchController, :query) post("/search/click", SearchController, :click) get("/bus-stop-changes", BusStopChangeController, :show) - - for static_page <- StaticPage.static_pages() do - get("/#{StaticPage.convert_path(static_page)}", StaticPageController, static_page) - end - get("/vote", VoteController, :show) end diff --git a/lib/dotcom_web/templates/layout/_new_header.html.heex b/lib/dotcom_web/templates/layout/_new_header.html.heex index fad0e31e73..071b6151e5 100644 --- a/lib/dotcom_web/templates/layout/_new_header.html.heex +++ b/lib/dotcom_web/templates/layout/_new_header.html.heex @@ -5,7 +5,7 @@ Menu diff --git a/lib/dotcom_web/templates/layout/_new_nav_desktop.html.eex b/lib/dotcom_web/templates/layout/_new_nav_desktop.html.eex index a7be403261..a902e06ed8 100644 --- a/lib/dotcom_web/templates/layout/_new_nav_desktop.html.eex +++ b/lib/dotcom_web/templates/layout/_new_nav_desktop.html.eex @@ -1,5 +1,5 @@