meaningful urls in micropub
This commit is contained in:
parent
5f07bf6e1f
commit
0d4fb07759
2 changed files with 8 additions and 2 deletions
|
@ -3,6 +3,11 @@ defmodule Chiya.Notes.Note do
|
||||||
import Ecto.Changeset
|
import Ecto.Changeset
|
||||||
alias Chiya.Notes.{Note, NoteSlug, NoteNote, NoteTag}
|
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)
|
@reserved_slugs ~w(user admin dev api)
|
||||||
|
|
||||||
@derive {Jason.Encoder, only: [:id, :name, :content, :slug, :channels]}
|
@derive {Jason.Encoder, only: [:id, :name, :content, :slug, :channels]}
|
||||||
|
@ -46,7 +51,8 @@ defmodule Chiya.Notes.Note do
|
||||||
end
|
end
|
||||||
|
|
||||||
def note_url(note) do
|
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
|
end
|
||||||
|
|
||||||
@doc false
|
@doc false
|
||||||
|
|
|
@ -18,7 +18,7 @@ defmodule ChiyaWeb.CommentController do
|
||||||
{:ok, _comment} ->
|
{:ok, _comment} ->
|
||||||
redirect(conn, to: ~p"/note/#{note_slug}?error=0")
|
redirect(conn, to: ~p"/note/#{note_slug}?error=0")
|
||||||
|
|
||||||
{:error, changeset} ->
|
{:error, _changeset} ->
|
||||||
redirect(conn, to: ~p"/note/#{note_slug}?error=1")
|
redirect(conn, to: ~p"/note/#{note_slug}?error=1")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue