From 1a394277d25a90bd64e36c0eba07ada55f8b8b3e Mon Sep 17 00:00:00 2001 From: Ivan Reshetnikov Date: Tue, 9 Jul 2024 21:21:17 +0500 Subject: [PATCH] feat: add controllers and views for other pages --- assets/css/app.css | 2 +- lib/comfycamp_web/components/layouts/app.html.heex | 3 ++- lib/comfycamp_web/controllers/cinema_controller.ex | 8 ++++++++ lib/comfycamp_web/controllers/cinema_html.ex | 8 ++++++++ .../controllers/cinema_html/index.html.heex | 1 + lib/comfycamp_web/controllers/main_controller.ex | 7 +++++++ lib/comfycamp_web/controllers/main_html.ex | 8 ++++++++ .../home.html.heex => main_html/index.html.heex} | 1 - lib/comfycamp_web/controllers/page_controller.ex | 7 ------- lib/comfycamp_web/controllers/page_html.ex | 10 ---------- lib/comfycamp_web/controllers/services_controller.ex | 7 +++++++ lib/comfycamp_web/controllers/services_html.ex | 8 ++++++++ .../controllers/services_html/index.html.heex | 1 + lib/comfycamp_web/router.ex | 4 +++- 14 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 lib/comfycamp_web/controllers/cinema_controller.ex create mode 100644 lib/comfycamp_web/controllers/cinema_html.ex create mode 100644 lib/comfycamp_web/controllers/cinema_html/index.html.heex create mode 100644 lib/comfycamp_web/controllers/main_controller.ex create mode 100644 lib/comfycamp_web/controllers/main_html.ex rename lib/comfycamp_web/controllers/{page_html/home.html.heex => main_html/index.html.heex} (91%) delete mode 100644 lib/comfycamp_web/controllers/page_controller.ex delete mode 100644 lib/comfycamp_web/controllers/page_html.ex create mode 100644 lib/comfycamp_web/controllers/services_controller.ex create mode 100644 lib/comfycamp_web/controllers/services_html.ex create mode 100644 lib/comfycamp_web/controllers/services_html/index.html.heex diff --git a/assets/css/app.css b/assets/css/app.css index 035dc40..4fcb28b 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -8,7 +8,6 @@ html { font-family: Georgia, serif; background-color: var(--bg); - background-size: 224px; color: white; font-size: 16px; } @@ -41,6 +40,7 @@ main, footer { justify-content: center; } + .limiter { max-width: 800px; width: 100%; diff --git a/lib/comfycamp_web/components/layouts/app.html.heex b/lib/comfycamp_web/components/layouts/app.html.heex index b24cd51..5beff2b 100644 --- a/lib/comfycamp_web/components/layouts/app.html.heex +++ b/lib/comfycamp_web/components/layouts/app.html.heex @@ -6,9 +6,10 @@ +<.flash_group flash={@flash} /> +
- <.flash_group flash={@flash} /> <%= @inner_content %>
diff --git a/lib/comfycamp_web/controllers/cinema_controller.ex b/lib/comfycamp_web/controllers/cinema_controller.ex new file mode 100644 index 0000000..5a7cda3 --- /dev/null +++ b/lib/comfycamp_web/controllers/cinema_controller.ex @@ -0,0 +1,8 @@ +defmodule ComfycampWeb.CinemaController do + use ComfycampWeb, :controller + + def index(conn, _params) do + conn + |> render(:index, page_title: "Кинотеатр") + end +end diff --git a/lib/comfycamp_web/controllers/cinema_html.ex b/lib/comfycamp_web/controllers/cinema_html.ex new file mode 100644 index 0000000..9ad57c0 --- /dev/null +++ b/lib/comfycamp_web/controllers/cinema_html.ex @@ -0,0 +1,8 @@ +defmodule ComfycampWeb.CinemaHTML do + @moduledoc """ + This module contains pages rendered by CinemaController. + """ + use ComfycampWeb, :html + + embed_templates "cinema_html/*" +end diff --git a/lib/comfycamp_web/controllers/cinema_html/index.html.heex b/lib/comfycamp_web/controllers/cinema_html/index.html.heex new file mode 100644 index 0000000..f00e694 --- /dev/null +++ b/lib/comfycamp_web/controllers/cinema_html/index.html.heex @@ -0,0 +1 @@ +

Кинотеатр

diff --git a/lib/comfycamp_web/controllers/main_controller.ex b/lib/comfycamp_web/controllers/main_controller.ex new file mode 100644 index 0000000..2b3badb --- /dev/null +++ b/lib/comfycamp_web/controllers/main_controller.ex @@ -0,0 +1,7 @@ +defmodule ComfycampWeb.MainController do + use ComfycampWeb, :controller + + def index(conn, _params) do + render(conn, :index, page_title: "Главная") + end +end diff --git a/lib/comfycamp_web/controllers/main_html.ex b/lib/comfycamp_web/controllers/main_html.ex new file mode 100644 index 0000000..8a009c7 --- /dev/null +++ b/lib/comfycamp_web/controllers/main_html.ex @@ -0,0 +1,8 @@ +defmodule ComfycampWeb.MainHTML do + @moduledoc """ + This module contains pages rendered by ServicesController. + """ + use ComfycampWeb, :html + + embed_templates "main_html/*" +end diff --git a/lib/comfycamp_web/controllers/page_html/home.html.heex b/lib/comfycamp_web/controllers/main_html/index.html.heex similarity index 91% rename from lib/comfycamp_web/controllers/page_html/home.html.heex rename to lib/comfycamp_web/controllers/main_html/index.html.heex index 8e732f7..b3af2a2 100644 --- a/lib/comfycamp_web/controllers/page_html/home.html.heex +++ b/lib/comfycamp_web/controllers/main_html/index.html.heex @@ -1,4 +1,3 @@ -<.flash_group flash={@flash} />

Уютный домик

diff --git a/lib/comfycamp_web/controllers/page_controller.ex b/lib/comfycamp_web/controllers/page_controller.ex deleted file mode 100644 index 60aedff..0000000 --- a/lib/comfycamp_web/controllers/page_controller.ex +++ /dev/null @@ -1,7 +0,0 @@ -defmodule ComfycampWeb.PageController do - use ComfycampWeb, :controller - - def home(conn, _params) do - render(conn, :home, page_title: "Главная") - end -end diff --git a/lib/comfycamp_web/controllers/page_html.ex b/lib/comfycamp_web/controllers/page_html.ex deleted file mode 100644 index 673c119..0000000 --- a/lib/comfycamp_web/controllers/page_html.ex +++ /dev/null @@ -1,10 +0,0 @@ -defmodule ComfycampWeb.PageHTML do - @moduledoc """ - This module contains pages rendered by PageController. - - See the `page_html` directory for all templates available. - """ - use ComfycampWeb, :html - - embed_templates "page_html/*" -end diff --git a/lib/comfycamp_web/controllers/services_controller.ex b/lib/comfycamp_web/controllers/services_controller.ex new file mode 100644 index 0000000..b6ccd68 --- /dev/null +++ b/lib/comfycamp_web/controllers/services_controller.ex @@ -0,0 +1,7 @@ +defmodule ComfycampWeb.ServicesController do + use ComfycampWeb, :controller + + def index(conn, _params) do + render(conn, :index, page_title: "Сервисы") + end +end diff --git a/lib/comfycamp_web/controllers/services_html.ex b/lib/comfycamp_web/controllers/services_html.ex new file mode 100644 index 0000000..ad86981 --- /dev/null +++ b/lib/comfycamp_web/controllers/services_html.ex @@ -0,0 +1,8 @@ +defmodule ComfycampWeb.ServicesHTML do + @moduledoc """ + This module contains pages rendered by ServicesController. + """ + use ComfycampWeb, :html + + embed_templates "services_html/*" +end diff --git a/lib/comfycamp_web/controllers/services_html/index.html.heex b/lib/comfycamp_web/controllers/services_html/index.html.heex new file mode 100644 index 0000000..d55f134 --- /dev/null +++ b/lib/comfycamp_web/controllers/services_html/index.html.heex @@ -0,0 +1 @@ +

Сервисы

diff --git a/lib/comfycamp_web/router.ex b/lib/comfycamp_web/router.ex index 6e3428a..5b606de 100644 --- a/lib/comfycamp_web/router.ex +++ b/lib/comfycamp_web/router.ex @@ -17,7 +17,9 @@ defmodule ComfycampWeb.Router do scope "/", ComfycampWeb do pipe_through :browser - get "/", PageController, :home + get "/", MainController, :index + get "/services", ServicesController, :index + get "/cinema", CinemaController, :index end # Other scopes may use custom stacks.