diff --git a/lib/comfycamp_web.ex b/lib/comfycamp_web.ex index 6fe74a0..61f4c25 100644 --- a/lib/comfycamp_web.ex +++ b/lib/comfycamp_web.ex @@ -89,7 +89,6 @@ defmodule ComfycampWeb do import ComfycampWeb.Flash import ComfycampWeb.Gettext import ComfycampWeb.NavBar - import ComfycampWeb.Home # Shortcut for generating JS commands alias Phoenix.LiveView.JS diff --git a/lib/comfycamp_web/components/home.ex b/lib/comfycamp_web/components/home.ex deleted file mode 100644 index 8013253..0000000 --- a/lib/comfycamp_web/components/home.ex +++ /dev/null @@ -1,37 +0,0 @@ -defmodule ComfycampWeb.Home do - @moduledoc """ - Components for the home page. - """ - use Phoenix.Component - import ComfycampWeb.Icons - - @doc """ - A component representing one service, like mastodon or nextcloud. - """ - attr :name, :string, required: true - attr :domain, :string, required: true - attr :description, :string, required: true - attr :enable_link, :boolean, required: false, default: true - attr :learn_more_url, :string, required: false - - def service(assigns) do - ~H""" -
-

<%= @name %>

- <%= if @enable_link do %> - @domain} target="_blank"> - <%= @domain %> <.arrow_top_right_on_square_icon /> - - <% else %> - <%= @domain %> - <% end %> -

- <%= @description %> - <%= if assigns[:learn_more_url] do %> - <.link href={@learn_more_url}>Узнать больше - <% end %> -

-
- """ - end -end diff --git a/lib/comfycamp_web/controllers/cinema_html.ex b/lib/comfycamp_web/controllers/cinema_html.ex index 9ad57c0..f376336 100644 --- a/lib/comfycamp_web/controllers/cinema_html.ex +++ b/lib/comfycamp_web/controllers/cinema_html.ex @@ -4,5 +4,9 @@ defmodule ComfycampWeb.CinemaHTML do """ use ComfycampWeb, :html - embed_templates "cinema_html/*" + def index(assigns) do + ~H""" +

Кинотеатр

+ """ + end end diff --git a/lib/comfycamp_web/controllers/cinema_html/index.html.heex b/lib/comfycamp_web/controllers/cinema_html/index.html.heex deleted file mode 100644 index f00e694..0000000 --- a/lib/comfycamp_web/controllers/cinema_html/index.html.heex +++ /dev/null @@ -1 +0,0 @@ -

Кинотеатр

diff --git a/lib/comfycamp_web/controllers/home_html.ex b/lib/comfycamp_web/controllers/home_html.ex index bcc20ae..d1098e9 100644 --- a/lib/comfycamp_web/controllers/home_html.ex +++ b/lib/comfycamp_web/controllers/home_html.ex @@ -3,6 +3,7 @@ defmodule ComfycampWeb.HomeHTML do This module contains pages rendered by HomeController. """ use ComfycampWeb, :html + import ComfycampWeb.Icons def index(assigns) do ~H""" @@ -70,6 +71,36 @@ defmodule ComfycampWeb.HomeHTML do """ end + @doc """ + A component representing one service, like mastodon or nextcloud. + """ + attr :name, :string, required: true + attr :domain, :string, required: true + attr :description, :string, required: true + attr :enable_link, :boolean, required: false, default: true + attr :learn_more_url, :string, required: false + + def service(assigns) do + ~H""" +
+

<%= @name %>

+ <%= if @enable_link do %> + @domain} target="_blank"> + <%= @domain %> <.arrow_top_right_on_square_icon /> + + <% else %> + <%= @domain %> + <% end %> +

+ <%= @description %> + <%= if assigns[:learn_more_url] do %> + <.link href={@learn_more_url}>Узнать больше + <% end %> +

+
+ """ + end + def mastodon(assigns) do ~H"""

Mastodon

diff --git a/lib/comfycamp_web/controllers/notes_editor_html.ex b/lib/comfycamp_web/controllers/notes_editor_html.ex index ddb05f9..21ff6e4 100644 --- a/lib/comfycamp_web/controllers/notes_editor_html.ex +++ b/lib/comfycamp_web/controllers/notes_editor_html.ex @@ -1,5 +1,84 @@ defmodule ComfycampWeb.NotesEditorHTML do use ComfycampWeb, :html - embed_templates "notes_editor_html/*" + def index(assigns) do + ~H""" +
+ <.link href={~p"/admin/notes/new"}> + Создать заметку + + + +
+ """ + end + + def show(assigns) do + ~H""" +
+ <.back navigate={~p"/admin/notes"}>Назад +

<%= @note.title %>

+ + <.link href={~p"/admin/notes/#{@note}/edit"}> + Редактировать + + +

Создана: <%= @note.inserted_at %>

+

Обновлена: <%= @note.updated_at %>

+ +
<%= @note.markdown %>
+
+ """ + end + + def new(assigns) do + ~H""" +
+

Новая заметка

+ <.note_form changeset={@changeset} action={~p"/admin/notes"} /> +
+ """ + end + + def edit(assigns) do + ~H""" +
+

Редактировать заметку

+ <.note_form changeset={@changeset} action={~p"/admin/notes/#{@changeset.data.id}"} /> +
+ """ + end + + def note_form(assigns) do + ~H""" + <.simple_form :let={f} for={@changeset} action={@action}> + <.input field={f[:title]} type="text" label="Заголовок" /> + <.input field={f[:markdown]} type="textarea" label="Содержание (markdown)" /> + + <:actions> + <.button>Сохранить + + + + <%= if @changeset.data.id do %> + <.link + href={~p"/admin/notes/#{@changeset.data}"} + method="DELETE" + data-confirm="Вы уверены?" + > + Удалить + + <% end %> + """ + end end diff --git a/lib/comfycamp_web/controllers/notes_editor_html/edit.html.heex b/lib/comfycamp_web/controllers/notes_editor_html/edit.html.heex deleted file mode 100644 index 42601b8..0000000 --- a/lib/comfycamp_web/controllers/notes_editor_html/edit.html.heex +++ /dev/null @@ -1,4 +0,0 @@ -
-

Редактировать заметку

- <.note_form changeset={@changeset} action={~p"/admin/notes/#{@changeset.data.id}"} /> -
diff --git a/lib/comfycamp_web/controllers/notes_editor_html/index.html.heex b/lib/comfycamp_web/controllers/notes_editor_html/index.html.heex deleted file mode 100644 index 2fefb6d..0000000 --- a/lib/comfycamp_web/controllers/notes_editor_html/index.html.heex +++ /dev/null @@ -1,17 +0,0 @@ -
- <.link href={~p"/admin/notes/new"}> - Создать заметку - - - -
diff --git a/lib/comfycamp_web/controllers/notes_editor_html/new.html.heex b/lib/comfycamp_web/controllers/notes_editor_html/new.html.heex deleted file mode 100644 index a56a22b..0000000 --- a/lib/comfycamp_web/controllers/notes_editor_html/new.html.heex +++ /dev/null @@ -1,4 +0,0 @@ -
-

Новая заметка

- <.note_form changeset={@changeset} action={~p"/admin/notes"} /> -
diff --git a/lib/comfycamp_web/controllers/notes_editor_html/note_form.html.heex b/lib/comfycamp_web/controllers/notes_editor_html/note_form.html.heex deleted file mode 100644 index 35d5c83..0000000 --- a/lib/comfycamp_web/controllers/notes_editor_html/note_form.html.heex +++ /dev/null @@ -1,18 +0,0 @@ -<.simple_form :let={f} for={@changeset} action={@action}> - <.input field={f[:title]} type="text" label="Заголовок" /> - <.input field={f[:markdown]} type="textarea" label="Содержание (markdown)" /> - - <:actions> - <.button>Сохранить - - - -<%= if @changeset.data.id do %> - <.link - href={~p"/admin/notes/#{@changeset.data}"} - method="DELETE" - data-confirm="Вы уверены?" - > - Удалить - -<% end %> diff --git a/lib/comfycamp_web/controllers/notes_editor_html/show.html.heex b/lib/comfycamp_web/controllers/notes_editor_html/show.html.heex deleted file mode 100644 index bba0bdf..0000000 --- a/lib/comfycamp_web/controllers/notes_editor_html/show.html.heex +++ /dev/null @@ -1,13 +0,0 @@ -
- <.back navigate={~p"/admin/notes"}>Назад -

<%= @note.title %>

- - <.link href={~p"/admin/notes/#{@note}/edit"}> - Редактировать - - -

Создана: <%= @note.inserted_at %>

-

Обновлена: <%= @note.updated_at %>

- -
<%= @note.markdown %>
-
diff --git a/lib/comfycamp_web/controllers/notes_html.ex b/lib/comfycamp_web/controllers/notes_html.ex index ead327c..8daa3fd 100644 --- a/lib/comfycamp_web/controllers/notes_html.ex +++ b/lib/comfycamp_web/controllers/notes_html.ex @@ -1,8 +1,38 @@ defmodule ComfycampWeb.NotesHTML do @moduledoc """ - This module contains pages rendered by BlogController. + This module contains pages rendered by NotesController. """ use ComfycampWeb, :html - embed_templates "notes_html/*" + def index(assigns) do + ~H""" +
+

Заметки

+ + <%= for note <- @notes do %> +
+ <.link href={~p"/notes/#{note}"}> +

<%= note.title %>

+ + <%= note.inserted_at %> +
+ <% end %> +
+ """ + end + + def show(assigns) do + ~H""" +
+

<%= @note.title %>

+ + <.back navigate={~p"/notes"}>К списку заметок + +

Создана: <%= @note.inserted_at %>

+

Обновлена: <%= @note.updated_at %>

+ + <%= raw(@note_body) %> +
+ """ + end end diff --git a/lib/comfycamp_web/controllers/notes_html/index.html.heex b/lib/comfycamp_web/controllers/notes_html/index.html.heex deleted file mode 100644 index eac862f..0000000 --- a/lib/comfycamp_web/controllers/notes_html/index.html.heex +++ /dev/null @@ -1,12 +0,0 @@ -
-

Заметки

- - <%= for note <- @notes do %> -
- <.link href={~p"/notes/#{note}"}> -

<%= note.title %>

- - <%= note.inserted_at %> -
- <% end %> -
diff --git a/lib/comfycamp_web/controllers/notes_html/show.html.heex b/lib/comfycamp_web/controllers/notes_html/show.html.heex deleted file mode 100644 index a602eb5..0000000 --- a/lib/comfycamp_web/controllers/notes_html/show.html.heex +++ /dev/null @@ -1,10 +0,0 @@ -
-

<%= @note.title %>

- - <.back navigate={~p"/notes"}>К списку заметок - -

Создана: <%= @note.inserted_at %>

-

Обновлена: <%= @note.updated_at %>

- - <%= raw(@note_body) %> -