From 5f07bf6e1fe8656979c19e4e0c89a3468b8b2db7 Mon Sep 17 00:00:00 2001 From: Inhji Date: Fri, 2 Jun 2023 07:07:22 +0200 Subject: [PATCH] meaningful urls --- lib/chiya/notes/references.ex | 3 ++- lib/chiya_web/components/layouts/root_public.html.heex | 2 +- lib/chiya_web/components/public_components.ex | 6 +++--- lib/chiya_web/controllers/channel_html/show.html.heex | 2 +- lib/chiya_web/controllers/comment_controller.ex | 6 +++--- lib/chiya_web/controllers/page_html/home.html.heex | 2 +- lib/chiya_web/controllers/page_html/note.html.heex | 6 ++++-- lib/chiya_web/controllers/page_html/tag.html.heex | 2 +- lib/chiya_web/live/note_show_live.ex | 4 ++-- lib/chiya_web/router.ex | 8 ++++---- 10 files changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/chiya/notes/references.ex b/lib/chiya/notes/references.ex index 4729795..9b8cf8d 100644 --- a/lib/chiya/notes/references.ex +++ b/lib/chiya/notes/references.ex @@ -153,7 +153,8 @@ defmodule Chiya.Notes.References do target_id: linked_id } - defp get_link(slug, title, valid), do: "[#{title}](#{~p"/#{slug}"})#{get_link_class(valid)}" + defp get_link(slug, title, valid), + do: "[#{title}](#{~p"/note/#{slug}"})#{get_link_class(valid)}" defp get_link_class(false), do: "{:.invalid}" defp get_link_class(_), do: "" diff --git a/lib/chiya_web/components/layouts/root_public.html.heex b/lib/chiya_web/components/layouts/root_public.html.heex index a2577ef..4030e2e 100644 --- a/lib/chiya_web/components/layouts/root_public.html.heex +++ b/lib/chiya_web/components/layouts/root_public.html.heex @@ -68,7 +68,7 @@ <%= identity.name %> <.dot /> <% end %> - About + About <.dot /> Admin

diff --git a/lib/chiya_web/components/public_components.ex b/lib/chiya_web/components/public_components.ex index 0477d71..cdb2ff0 100644 --- a/lib/chiya_web/components/public_components.ex +++ b/lib/chiya_web/components/public_components.ex @@ -85,7 +85,7 @@ defmodule ChiyaWeb.PublicComponents do <% end %> <%= note.name %> @@ -113,7 +113,7 @@ defmodule ChiyaWeb.PublicComponents do <%= pretty_datetime(note.published_at) %> <.dot /> - Permalink + Permalink <%= if not Enum.empty?(note.images) do %> <.dot /> <.icon name="hero-photo" /> @@ -130,7 +130,7 @@ defmodule ChiyaWeb.PublicComponents do
<%= for note <- assigns.notes do %> diff --git a/lib/chiya_web/controllers/channel_html/show.html.heex b/lib/chiya_web/controllers/channel_html/show.html.heex index 7955474..b106dbc 100644 --- a/lib/chiya_web/controllers/channel_html/show.html.heex +++ b/lib/chiya_web/controllers/channel_html/show.html.heex @@ -5,7 +5,7 @@ <.link href={~p"/admin/channels/#{@channel}/edit"}> <.button>Edit channel - <.link href={~p"/c/#{@channel.slug}"}> + <.link href={~p"/channel/#{@channel.slug}"}> <.button>Preview diff --git a/lib/chiya_web/controllers/comment_controller.ex b/lib/chiya_web/controllers/comment_controller.ex index 0fbbb8b..0e2a162 100644 --- a/lib/chiya_web/controllers/comment_controller.ex +++ b/lib/chiya_web/controllers/comment_controller.ex @@ -12,14 +12,14 @@ defmodule ChiyaWeb.CommentController do end def create(conn, %{"slug" => note_slug, "note_comment" => comment_params}) do - note = Chiya.Notes.get_note_by_slug_preloaded!(note_slug) + _note = Chiya.Notes.get_note_by_slug_preloaded!(note_slug) case Chiya.Notes.create_note_comment(comment_params) do {:ok, _comment} -> - redirect(conn, to: ~p"/#{note_slug}?error=0") + redirect(conn, to: ~p"/note/#{note_slug}?error=0") {:error, changeset} -> - redirect(conn, to: ~p"/#{note_slug}?error=1") + redirect(conn, to: ~p"/note/#{note_slug}?error=1") end end end diff --git a/lib/chiya_web/controllers/page_html/home.html.heex b/lib/chiya_web/controllers/page_html/home.html.heex index 49c616d..a2cd1c1 100644 --- a/lib/chiya_web/controllers/page_html/home.html.heex +++ b/lib/chiya_web/controllers/page_html/home.html.heex @@ -20,7 +20,7 @@ <%= for channel <- @channels do %>
  • <%= channel.name %> diff --git a/lib/chiya_web/controllers/page_html/note.html.heex b/lib/chiya_web/controllers/page_html/note.html.heex index ae58b25..473742d 100644 --- a/lib/chiya_web/controllers/page_html/note.html.heex +++ b/lib/chiya_web/controllers/page_html/note.html.heex @@ -18,7 +18,9 @@ Tags <%= for tag <- @note.tags do %> - <%= tag.name %> + + <%= tag.name %> + <% end %> <% end %> @@ -83,7 +85,7 @@ <.simple_form :let={f} for={@changeset} - action={~p"/#{@note.slug}/comment"} + action={~p"/note/#{@note.slug}/comment"} class="bg-theme-background -m-3" > <.error :if={@changeset.action}> diff --git a/lib/chiya_web/controllers/page_html/tag.html.heex b/lib/chiya_web/controllers/page_html/tag.html.heex index 3ddfd15..14e5abd 100644 --- a/lib/chiya_web/controllers/page_html/tag.html.heex +++ b/lib/chiya_web/controllers/page_html/tag.html.heex @@ -9,7 +9,7 @@