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
|
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(false), do: "{:.invalid}"
|
||||||
defp get_link_class(_), do: ""
|
defp get_link_class(_), do: ""
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
<span><a href={identity.url}><%= identity.name %></a></span>
|
<span><a href={identity.url}><%= identity.name %></a></span>
|
||||||
<.dot />
|
<.dot />
|
||||||
<% end %>
|
<% end %>
|
||||||
<span><a href={~p"/about"}>About</a></span>
|
<span><a href={~p"/note/about"}>About</a></span>
|
||||||
<.dot />
|
<.dot />
|
||||||
<span><a href={~p"/admin"}>Admin</a></span>
|
<span><a href={~p"/admin"}>Admin</a></span>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -85,7 +85,7 @@ defmodule ChiyaWeb.PublicComponents do
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
<a
|
<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"
|
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 %>
|
<%= note.name %>
|
||||||
|
@ -113,7 +113,7 @@ defmodule ChiyaWeb.PublicComponents do
|
||||||
<%= pretty_datetime(note.published_at) %>
|
<%= pretty_datetime(note.published_at) %>
|
||||||
</time>
|
</time>
|
||||||
<.dot />
|
<.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 %>
|
<%= if not Enum.empty?(note.images) do %>
|
||||||
<.dot />
|
<.dot />
|
||||||
<.icon name="hero-photo" />
|
<.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">
|
<section class="note-list default | mt-6 sm:w-auto flex flex-col gap-1.5">
|
||||||
<%= for note <- assigns.notes do %>
|
<%= for note <- assigns.notes do %>
|
||||||
<a
|
<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"
|
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">
|
<span class="text-theme-secondary text-lg font-semibold leading-8">
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<.link href={~p"/admin/channels/#{@channel}/edit"}>
|
<.link href={~p"/admin/channels/#{@channel}/edit"}>
|
||||||
<.button>Edit channel</.button>
|
<.button>Edit channel</.button>
|
||||||
</.link>
|
</.link>
|
||||||
<.link href={~p"/c/#{@channel.slug}"}>
|
<.link href={~p"/channel/#{@channel.slug}"}>
|
||||||
<.button>Preview</.button>
|
<.button>Preview</.button>
|
||||||
</.link>
|
</.link>
|
||||||
</:actions>
|
</:actions>
|
||||||
|
|
|
@ -12,14 +12,14 @@ defmodule ChiyaWeb.CommentController do
|
||||||
end
|
end
|
||||||
|
|
||||||
def create(conn, %{"slug" => note_slug, "note_comment" => comment_params}) do
|
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
|
case Chiya.Notes.create_note_comment(comment_params) do
|
||||||
{:ok, _comment} ->
|
{:ok, _comment} ->
|
||||||
redirect(conn, to: ~p"/#{note_slug}?error=0")
|
redirect(conn, to: ~p"/note/#{note_slug}?error=0")
|
||||||
|
|
||||||
{:error, changeset} ->
|
{:error, changeset} ->
|
||||||
redirect(conn, to: ~p"/#{note_slug}?error=1")
|
redirect(conn, to: ~p"/note/#{note_slug}?error=1")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
<%= for channel <- @channels do %>
|
<%= for channel <- @channels do %>
|
||||||
<li>
|
<li>
|
||||||
<a
|
<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"
|
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 %>
|
<%= channel.name %>
|
||||||
|
|
|
@ -18,7 +18,9 @@
|
||||||
<span>Tags</span>
|
<span>Tags</span>
|
||||||
<span>
|
<span>
|
||||||
<%= for tag <- @note.tags do %>
|
<%= 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 %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
@ -83,7 +85,7 @@
|
||||||
<.simple_form
|
<.simple_form
|
||||||
:let={f}
|
:let={f}
|
||||||
for={@changeset}
|
for={@changeset}
|
||||||
action={~p"/#{@note.slug}/comment"}
|
action={~p"/note/#{@note.slug}/comment"}
|
||||||
class="bg-theme-background -m-3"
|
class="bg-theme-background -m-3"
|
||||||
>
|
>
|
||||||
<.error :if={@changeset.action}>
|
<.error :if={@changeset.action}>
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="w-full mt-6 sm:w-auto flex flex-col gap-1.5">
|
<div class="w-full mt-6 sm:w-auto flex flex-col gap-1.5">
|
||||||
<%= for note <- @tag.notes do %>
|
<%= for note <- @tag.notes do %>
|
||||||
<a
|
<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"
|
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>
|
<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"}>
|
<.link href={~p"/admin/notes/#{@note}/edit"}>
|
||||||
<.button>Edit</.button>
|
<.button>Edit</.button>
|
||||||
</.link>
|
</.link>
|
||||||
<.link href={~p"/#{@note.slug}"}>
|
<.link href={~p"/note/#{@note.slug}"}>
|
||||||
<.button>Preview</.button>
|
<.button>Preview</.button>
|
||||||
</.link>
|
</.link>
|
||||||
<.link href={~p"/admin/notes/#{@note}/raw"}>
|
<.link href={~p"/admin/notes/#{@note}/raw"}>
|
||||||
|
@ -27,7 +27,7 @@ defmodule ChiyaWeb.NoteShowLive do
|
||||||
<.button>Publish</.button>
|
<.button>Publish</.button>
|
||||||
</.link>
|
</.link>
|
||||||
<% else %>
|
<% else %>
|
||||||
<.link href={~p"/amdin/notes/#{@note}/unpublish"}>
|
<.link href={~p"/admin/notes/#{@note}/unpublish"}>
|
||||||
<.button>Un-Publish</.button>
|
<.button>Un-Publish</.button>
|
||||||
</.link>
|
</.link>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -130,11 +130,11 @@ defmodule ChiyaWeb.Router do
|
||||||
scope "/", ChiyaWeb do
|
scope "/", ChiyaWeb do
|
||||||
pipe_through [:browser, :public]
|
pipe_through [:browser, :public]
|
||||||
|
|
||||||
get "/:slug", PageController, :note
|
get "/note/:slug", PageController, :note
|
||||||
get "/c/:slug", PageController, :channel
|
get "/channel/:slug", PageController, :channel
|
||||||
get "/t/:slug", PageController, :tag
|
get "/tagged-with/:slug", PageController, :tag
|
||||||
get "/", PageController, :home
|
get "/", PageController, :home
|
||||||
|
|
||||||
post "/:slug/comment", CommentController, :create
|
post "/note/:slug/comment", CommentController, :create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue