meaningful urls
This commit is contained in:
parent
ca014512a7
commit
5f07bf6e1f
10 changed files with 22 additions and 19 deletions
|
@ -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: ""
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
<span><a href={identity.url}><%= identity.name %></a></span>
|
||||
<.dot />
|
||||
<% end %>
|
||||
<span><a href={~p"/about"}>About</a></span>
|
||||
<span><a href={~p"/note/about"}>About</a></span>
|
||||
<.dot />
|
||||
<span><a href={~p"/admin"}>Admin</a></span>
|
||||
</p>
|
||||
|
|
|
@ -85,7 +85,7 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
<% end %>
|
||||
</section>
|
||||
<a
|
||||
href={~p"/#{note.slug}"}
|
||||
href={~p"/note/#{note.slug}"}
|
||||
class="text-theme-secondary text-lg/10 font-semibold rounded-lg -mx-2 -my-0.5 px-2 py-0.5 hover:bg-theme-secondary/10 transition"
|
||||
>
|
||||
<%= note.name %>
|
||||
|
@ -113,7 +113,7 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
<%= pretty_datetime(note.published_at) %>
|
||||
</time>
|
||||
<.dot />
|
||||
<a href={~p"/#{note.slug}"} class="text-theme-base/75">Permalink</a>
|
||||
<a href={~p"/note/#{note.slug}"} class="text-theme-base/75">Permalink</a>
|
||||
<%= if not Enum.empty?(note.images) do %>
|
||||
<.dot />
|
||||
<.icon name="hero-photo" />
|
||||
|
@ -130,7 +130,7 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
<section class="note-list default | mt-6 sm:w-auto flex flex-col gap-1.5">
|
||||
<%= for note <- assigns.notes do %>
|
||||
<a
|
||||
href={~p"/#{note.slug}"}
|
||||
href={~p"/note/#{note.slug}"}
|
||||
class="rounded-lg -mx-2 -my-0.5 px-2 py-0.5 hover:bg-theme-secondary/10 transition"
|
||||
>
|
||||
<span class="text-theme-secondary text-lg font-semibold leading-8">
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<.link href={~p"/admin/channels/#{@channel}/edit"}>
|
||||
<.button>Edit channel</.button>
|
||||
</.link>
|
||||
<.link href={~p"/c/#{@channel.slug}"}>
|
||||
<.link href={~p"/channel/#{@channel.slug}"}>
|
||||
<.button>Preview</.button>
|
||||
</.link>
|
||||
</:actions>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
<%= for channel <- @channels do %>
|
||||
<li>
|
||||
<a
|
||||
href={~p"/c/#{channel.slug}"}
|
||||
href={~p"/channel/#{channel.slug}"}
|
||||
class="inline-block text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold"
|
||||
>
|
||||
<%= channel.name %>
|
||||
|
|
|
@ -18,7 +18,9 @@
|
|||
<span>Tags</span>
|
||||
<span>
|
||||
<%= for tag <- @note.tags do %>
|
||||
<a href={~p"/t/#{tag.slug}"} class="underline-link font-semibold"><%= tag.name %></a>
|
||||
<a href={~p"/tagged-with/#{tag.slug}"} class="underline-link font-semibold">
|
||||
<%= tag.name %>
|
||||
</a>
|
||||
<% end %>
|
||||
</span>
|
||||
<% 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}>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<div class="w-full mt-6 sm:w-auto flex flex-col gap-1.5">
|
||||
<%= for note <- @tag.notes do %>
|
||||
<a
|
||||
href={~p"/#{note.slug}"}
|
||||
href={~p"/note/#{note.slug}"}
|
||||
class="rounded -mx-2 -my-0.5 px-2 py-0.5 hover:bg-theme-primary/10 transition"
|
||||
>
|
||||
<span class="text-theme-primary text-lg font-semibold leading-8"><%= note.name %></span>
|
||||
|
|
|
@ -16,7 +16,7 @@ defmodule ChiyaWeb.NoteShowLive do
|
|||
<.link href={~p"/admin/notes/#{@note}/edit"}>
|
||||
<.button>Edit</.button>
|
||||
</.link>
|
||||
<.link href={~p"/#{@note.slug}"}>
|
||||
<.link href={~p"/note/#{@note.slug}"}>
|
||||
<.button>Preview</.button>
|
||||
</.link>
|
||||
<.link href={~p"/admin/notes/#{@note}/raw"}>
|
||||
|
@ -27,7 +27,7 @@ defmodule ChiyaWeb.NoteShowLive do
|
|||
<.button>Publish</.button>
|
||||
</.link>
|
||||
<% else %>
|
||||
<.link href={~p"/amdin/notes/#{@note}/unpublish"}>
|
||||
<.link href={~p"/admin/notes/#{@note}/unpublish"}>
|
||||
<.button>Un-Publish</.button>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
|
|
@ -130,11 +130,11 @@ defmodule ChiyaWeb.Router do
|
|||
scope "/", ChiyaWeb do
|
||||
pipe_through [:browser, :public]
|
||||
|
||||
get "/:slug", PageController, :note
|
||||
get "/c/:slug", PageController, :channel
|
||||
get "/t/:slug", PageController, :tag
|
||||
get "/note/:slug", PageController, :note
|
||||
get "/channel/:slug", PageController, :channel
|
||||
get "/tagged-with/:slug", PageController, :tag
|
||||
get "/", PageController, :home
|
||||
|
||||
post "/:slug/comment", CommentController, :create
|
||||
post "/note/:slug/comment", CommentController, :create
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue