diff --git a/lib/chiya/notes/note.ex b/lib/chiya/notes/note.ex index fa1e65b..c906081 100644 --- a/lib/chiya/notes/note.ex +++ b/lib/chiya/notes/note.ex @@ -3,6 +3,11 @@ defmodule Chiya.Notes.Note do import Ecto.Changeset alias Chiya.Notes.{Note, NoteSlug, NoteNote, NoteTag} + use Phoenix.VerifiedRoutes, + endpoint: ChiyaWeb.Endpoint, + router: ChiyaWeb.Router, + statics: ChiyaWeb.static_paths() + @reserved_slugs ~w(user admin dev api) @derive {Jason.Encoder, only: [:id, :name, :content, :slug, :channels]} @@ -46,7 +51,8 @@ defmodule Chiya.Notes.Note do end def note_url(note) do - URI.merge(ChiyaWeb.Endpoint.url(), note.slug) |> to_string() + URI.merge(ChiyaWeb.Endpoint.url(), ~p"/note/#{note.slug}") + |> to_string() end @doc false 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..585a47c 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") + {:error, _changeset} -> + 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 @@