devel #196

Merged
inhji merged 4 commits from devel into main 2023-07-07 14:31:30 +02:00
3 changed files with 55 additions and 54 deletions

View file

@ -49,6 +49,7 @@ defmodule Chiya.Notes do
def list_notes_by_channel_published(%Chiya.Channels.Channel{} = channel) do def list_notes_by_channel_published(%Chiya.Channels.Channel{} = channel) do
list_notes_by_channel_query(channel) list_notes_by_channel_query(channel)
|> order_by([n], desc: n.published_at) |> order_by([n], desc: n.published_at)
|> where([n], not is_nil(n.published_at))
|> Repo.all() |> Repo.all()
|> Repo.preload(@preloads) |> Repo.preload(@preloads)
end end
@ -56,6 +57,7 @@ defmodule Chiya.Notes do
def list_notes_by_channel_updated(%Chiya.Channels.Channel{} = channel) do def list_notes_by_channel_updated(%Chiya.Channels.Channel{} = channel) do
list_notes_by_channel_query(channel) list_notes_by_channel_query(channel)
|> order_by([n], desc: n.published_at) |> order_by([n], desc: n.published_at)
|> where([n], not is_nil(n.published_at))
|> Repo.all() |> Repo.all()
|> Repo.preload(@preloads) |> Repo.preload(@preloads)
end end

View file

@ -1,59 +1,58 @@
<section class="max-w-2xl mx-auto"> <article class="h-entry hentry">
<article class="h-entry hentry"> <.header class_title="max-w-2xl mx-auto | p-name">
<.header class_title="p-name"> <:title><%= @note.name %></:title>
<:title><%= @note.name %></:title> </.header>
</.header>
<section class="mt-8 prose prose-gruvbox md:prose-lg lg:prose-xl | p-summary e-content"> <section class="mt-8 prose prose-gruvbox md:prose-lg lg:prose-xl | p-summary e-content">
<%= Markdown.render(@note.content) |> raw %> <%= Markdown.render(@note.content) |> raw %>
</section> </section>
<footer class="mt-8 text-theme-base"> <footer class="max-w-2xl mx-auto mt-8 text-theme-base">
<%= if @note.published_at do %> <%= if @note.published_at do %>
<span>Published</span> <span>Published</span>
<% else %> <% else %>
<span>Unpublished</span> <span>Unpublished</span>
<% end %> <% end %>
<time class="font-semibold | dt-published"><%= pretty_date(@note.published_at) %></time> <time class="font-semibold | dt-published"><%= pretty_date(@note.published_at) %></time>
<.dot />
<span>Last Updated</span>
<time class="font-semibold" datetime={datetime(@note.updated_at)}>
<%= pretty_date(@note.updated_at) %>
</time>
<%= if not Enum.empty?(@note.tags) do %>
<.dot /> <.dot />
<span>Last Updated</span> <span>Tags</span>
<time class="font-semibold" datetime={datetime(@note.updated_at)}> <.tags note={@note} />
<%= pretty_date(@note.updated_at) %> <% end %>
</time> <%= if @current_user do %>
<%= if not Enum.empty?(@note.tags) do %> <.dot />
<.dot /> <a href={~p"/admin/notes/#{@note}"} class="underline-link font-semibold">Show in Admin</a>
<span>Tags</span> <% end %>
<.tags note={@note} />
<% end %>
<%= if @current_user do %>
<.dot />
<a href={~p"/admin/notes/#{@note}"} class="underline-link font-semibold">Show in Admin</a>
<% end %>
<a href={~p"/"} class="hidden | h-card u-author">Inhji</a> <a href={~p"/"} class="hidden | h-card u-author">Inhji</a>
<a href={~p"/note/#{@note.slug}"} class="hidden | u-url u-uid"><%= @note.name %></a> <a href={~p"/note/#{@note.slug}"} class="hidden | u-url u-uid"><%= @note.name %></a>
</footer> </footer>
<section class="mt-8"> <section class="max-w-2xl mx-auto mt-8">
<%= if !Enum.empty?(@note.images) do %> <%= if !Enum.empty?(@note.images) do %>
<.line /> <.line />
<div class="flex flex-wrap gap-3">
<%= for image <- @note.images do %>
<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"
/>
</a>
<% end %>
</div>
<% end %>
</section>
</article>
<div class="flex flex-wrap gap-3">
<%= for image <- @note.images do %>
<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"
/>
</a>
<% end %>
</div>
<% end %>
</section>
</article>
</section>

View file

@ -1,6 +1,6 @@
<section class="mx-auto max-w-2xl"> <section class="mx-auto max-w-2xl">
<.header> <.header>
<:title>Wiki</:title> <:title><%= @channel.name %></:title>
</.header> </.header>
<section class="prose prose-gruvbox mt-6"> <section class="prose prose-gruvbox mt-6">