remove public comments for now
This commit is contained in:
parent
1959773113
commit
3f5a4ab56f
5 changed files with 67 additions and 61 deletions
|
@ -164,6 +164,64 @@ defmodule ChiyaWeb.PublicComponents do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def comment_form(assigns) do
|
||||||
|
~H"""
|
||||||
|
<.simple_form
|
||||||
|
:let={f}
|
||||||
|
for={@changeset}
|
||||||
|
action={~p"/note/#{assigns.note.slug}/comment"}
|
||||||
|
class="bg-theme-background -m-3"
|
||||||
|
>
|
||||||
|
<.error :if={@changeset.action}>
|
||||||
|
Oops, something went wrong! Please check the errors below.
|
||||||
|
</.error>
|
||||||
|
<.input
|
||||||
|
field={f[:author_name]}
|
||||||
|
type="text"
|
||||||
|
placeholder="Name"
|
||||||
|
class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/40 dark:placeholder-theme-base/60 dark:focus:border-theme-base/60 dark:focus:border-theme-base/60"
|
||||||
|
/>
|
||||||
|
<.input
|
||||||
|
field={f[:content]}
|
||||||
|
type="textarea"
|
||||||
|
placeholder="Content"
|
||||||
|
rows="3"
|
||||||
|
class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/60 dark:placeholder-theme-base/60 focus:border-theme-base/60 dark:focus:border-theme-base/60"
|
||||||
|
/>
|
||||||
|
<.input field={f[:note_id]} type="hidden" />
|
||||||
|
<:actions>
|
||||||
|
<.button>Submit Comment</.button>
|
||||||
|
</:actions>
|
||||||
|
</.simple_form>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
|
def comment_list(assigns) do
|
||||||
|
~H"""
|
||||||
|
<%= if not Enum.empty?(assigns.note.comments) do %>
|
||||||
|
<.line />
|
||||||
|
|
||||||
|
<h2 class="mb-6 text-theme-base"><%= Enum.count(assigns.note.comments) %> Comments</h2>
|
||||||
|
|
||||||
|
<aside id="comments" class="flex flex-col gap-6">
|
||||||
|
<%= for comment <- assigns.note.comments do %>
|
||||||
|
<article class="text-theme-base bg-theme-base/10 p-1">
|
||||||
|
<header class="flex flex-row justify-between">
|
||||||
|
<strong class="text-theme-primary"><%= comment.author_name %></strong>
|
||||||
|
<span class="text-theme-dim"><%= from_now(comment.inserted_at) %></span>
|
||||||
|
</header>
|
||||||
|
<p><%= comment.content %></p>
|
||||||
|
</article>
|
||||||
|
<% end %>
|
||||||
|
</aside>
|
||||||
|
<% else %>
|
||||||
|
<.line />
|
||||||
|
|
||||||
|
<h2 class="mb-6 text-theme-base">No comments yet.</h2>
|
||||||
|
<% end %>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
defp gallery_name(note), do: "gallery-#{note.id}"
|
defp gallery_name(note), do: "gallery-#{note.id}"
|
||||||
|
|
||||||
defp main_image(note),
|
defp main_image(note),
|
||||||
|
|
|
@ -12,14 +12,14 @@
|
||||||
<.link navigate={~p"/admin/comments/#{comment}"}>Show</.link>
|
<.link navigate={~p"/admin/comments/#{comment}"}>Show</.link>
|
||||||
</div>
|
</div>
|
||||||
</:action>
|
</:action>
|
||||||
<:action :let={comment}>
|
<:action :let={_comment}>
|
||||||
<.link href={~p"/admin/comments/#{comment}"} method="delete" data-confirm="Are you sure?">
|
<.link href="#" method="delete" data-confirm="Are you sure?">
|
||||||
Delete
|
Delete
|
||||||
</.link>
|
</.link>
|
||||||
</:action>
|
</:action>
|
||||||
<:action :let={comment}>
|
<:action :let={_comment}>
|
||||||
<div class="sr-only">
|
<div class="sr-only">
|
||||||
<.link navigate={~p"/admin/comments/#{comment}/approve"}>Approve</.link>
|
<.link href="#">Approve</.link>
|
||||||
</div>
|
</div>
|
||||||
</:action>
|
</:action>
|
||||||
</.table>
|
</.table>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Comment <%= @comment.id %>
|
Comment <%= @comment.id %>
|
||||||
<:subtitle>This is a comment record from your database.</:subtitle>
|
<:subtitle>This is a comment record from your database.</:subtitle>
|
||||||
<:actions>
|
<:actions>
|
||||||
<.link href={~p"/admin/notes/#{@comment}/approve"}>
|
<.link href="#">
|
||||||
<.button>Approve note</.button>
|
<.button>Approve note</.button>
|
||||||
</.link>
|
</.link>
|
||||||
</:actions>
|
</:actions>
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<:item title="Approved at"><%= @comment.approved_at %></:item>
|
<:item title="Approved at"><%= @comment.approved_at %></:item>
|
||||||
<:item title="Kind"><%= @comment.kind %></:item>
|
<:item title="Kind"><%= @comment.kind %></:item>
|
||||||
<:item title="Note">
|
<:item title="Note">
|
||||||
<a href={"/admin/notes/#{@comment.note.id}"}><%= @comment.note.name %></a>
|
<a href="#"><%= @comment.note.name %></a>
|
||||||
</:item>
|
</:item>
|
||||||
</.list>
|
</.list>
|
||||||
|
|
||||||
|
|
|
@ -56,58 +56,4 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="mt-8 mx-auto max-w-xl">
|
|
||||||
<%= if not Enum.empty?(@note.comments) do %>
|
|
||||||
<.line />
|
|
||||||
|
|
||||||
<h2 class="mb-6 text-theme-base"><%= Enum.count(@note.comments) %> Comments</h2>
|
|
||||||
|
|
||||||
<aside id="comments" class="flex flex-col gap-6">
|
|
||||||
<%= for comment <- @note.comments do %>
|
|
||||||
<article class="text-theme-base bg-theme-base/10 p-1">
|
|
||||||
<header class="flex flex-row justify-between">
|
|
||||||
<strong class="text-theme-primary"><%= comment.author_name %></strong>
|
|
||||||
<span class="text-theme-dim"><%= from_now(comment.inserted_at) %></span>
|
|
||||||
</header>
|
|
||||||
<p><%= comment.content %></p>
|
|
||||||
</article>
|
|
||||||
<% end %>
|
|
||||||
</aside>
|
|
||||||
<% else %>
|
|
||||||
<.line />
|
|
||||||
|
|
||||||
<h2 class="mb-6 text-theme-base">No comments yet.</h2>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<.line />
|
|
||||||
|
|
||||||
<.simple_form
|
|
||||||
:let={f}
|
|
||||||
for={@changeset}
|
|
||||||
action={~p"/note/#{@note.slug}/comment"}
|
|
||||||
class="bg-theme-background -m-3"
|
|
||||||
>
|
|
||||||
<.error :if={@changeset.action}>
|
|
||||||
Oops, something went wrong! Please check the errors below.
|
|
||||||
</.error>
|
|
||||||
<.input
|
|
||||||
field={f[:author_name]}
|
|
||||||
type="text"
|
|
||||||
placeholder="Name"
|
|
||||||
class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/40 dark:placeholder-theme-base/60 dark:focus:border-theme-base/60 dark:focus:border-theme-base/60"
|
|
||||||
/>
|
|
||||||
<.input
|
|
||||||
field={f[:content]}
|
|
||||||
type="textarea"
|
|
||||||
placeholder="Content"
|
|
||||||
rows="3"
|
|
||||||
class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/60 dark:placeholder-theme-base/60 focus:border-theme-base/60 dark:focus:border-theme-base/60"
|
|
||||||
/>
|
|
||||||
<.input field={f[:note_id]} type="hidden" />
|
|
||||||
<:actions>
|
|
||||||
<.button>Submit Comment</.button>
|
|
||||||
</:actions>
|
|
||||||
</.simple_form>
|
|
||||||
</section>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -138,6 +138,8 @@ defmodule ChiyaWeb.Router do
|
||||||
|
|
||||||
get "/about", PageController, :about
|
get "/about", PageController, :about
|
||||||
|
|
||||||
post "/note/:slug/comment", CommentController, :create
|
# TODO: Comments are disabled for now
|
||||||
|
# and need a better submit/approve flow
|
||||||
|
# post "/note/:slug/comment", CommentController, :create
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue