chiya/lib/chiya_web/controllers/page_html/note.html.heex

86 lines
2.8 KiB
Text
Raw Normal View History

2023-04-03 22:22:02 +02:00
<div class="mx-auto max-w-xl mx-4 lg:mx-0">
<header>
<h1 class="mt-16 text-3xl font-semibold leading-8 text-theme-heading font-serif">
2023-04-03 22:22:02 +02:00
<%= @note.name %>
</h1>
2023-04-06 15:21:03 +02:00
<p class="mt-2 text-sm leading-6 text-theme-base">
2023-04-30 11:56:45 +02:00
<%= if @note.published_at do %>
2023-05-07 10:32:26 +02:00
<span>Published</span>
2023-04-30 11:56:45 +02:00
<% else %>
2023-05-07 10:32:26 +02:00
<span>Unpublished</span>
2023-04-30 11:56:45 +02:00
<% end %>
2023-04-10 12:08:19 +02:00
<time class="text-theme-primary font-semibold"><%= pretty_date(@note.published_at) %></time>
2023-04-06 15:21:03 +02:00
<span>·</span>
2023-04-10 12:08:19 +02:00
<span>Last Updated</span>
<time class="text-theme-primary font-semibold"><%= pretty_date(@note.updated_at) %></time>
2023-04-10 19:18:27 +02:00
<span>·</span>
<span>Tags</span>
<span class="text-theme-primary font-semibold">
<%= for tag <- @note.tags do %>
<a href={~p"/t/#{tag.slug}"}><%= tag.name %></a>
<% end %>
</span>
2023-04-09 13:43:54 +02:00
<%= if @current_user do %>
2023-04-10 12:08:19 +02:00
<span>·</span>
<a href={~p"/admin/notes/#{@note}/edit"} class="text-theme-primary font-semibold">Edit</a>
2023-04-09 13:43:54 +02:00
<% end %>
2023-04-03 22:22:02 +02:00
</p>
</header>
2023-04-03 22:22:02 +02:00
<section class="prose mt-8">
<%= Markdown.render(@note.content) |> raw %>
</section>
2023-03-13 03:26:39 +01:00
2023-04-03 22:22:02 +02:00
<%= if !Enum.empty?(@note.images) do %>
<.line />
2023-03-13 05:59:40 +01:00
2023-04-06 14:21:59 +02:00
<div class="flex flex-wrap gap-3">
2023-04-03 22:22:02 +02:00
<%= for image <- @note.images do %>
2023-04-10 12:08:19 +02:00
<a
href={ChiyaWeb.Uploaders.NoteImage.url({image.path, image}, :full_dithered)}
class="lightbox | w-28"
data-gallery="note"
data-description={ChiyaWeb.Markdown.render(image.content)}
>
<img
src={ChiyaWeb.Uploaders.NoteImage.url({image.path, image}, :thumb_dithered)}
class="rounded"
/>
2023-04-06 14:21:59 +02:00
</a>
2023-04-03 22:22:02 +02:00
<% end %>
</div>
<% end %>
2023-04-30 13:35:22 +02:00
<%= if not Enum.empty?(@note.comments) do %>
<.line />
<h2 class="mb-6 text-theme-base"><%= Enum.count(@note.comments) %> Comments</h2>
2023-05-07 10:32:26 +02:00
2023-04-30 13:35:22 +02:00
<aside id="comments" class="flex flex-col gap-6">
<%= for comment <- @note.comments do %>
2023-05-07 10:32:26 +02:00
<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>
2023-04-30 13:35:22 +02:00
<% end %>
</aside>
<% end %>
2023-05-07 10:32:26 +02:00
2023-04-30 13:35:22 +02:00
<.line />
<.simple_form :let={f} for={@changeset} action={~p"/#{@note.slug}/comment"}>
<.error :if={@changeset.action}>
Oops, something went wrong! Please check the errors below.
</.error>
<.input field={f[:author_name]} type="text" placeholder="Name" />
2023-05-07 10:32:26 +02:00
<.input field={f[:content]} type="textarea" placeholder="Content" rows="3" />
2023-04-30 13:35:22 +02:00
<.input field={f[:note_id]} type="hidden" />
<:actions>
<.button>Submit Comment</.button>
</:actions>
</.simple_form>
2023-04-10 12:08:19 +02:00
</div>