2023-03-05 16:07:40 +01:00
|
|
|
defmodule ChiyaWeb.PageHTML do
|
2023-03-31 17:00:09 +02:00
|
|
|
use ChiyaWeb, :html_public
|
2023-09-13 20:59:15 +02:00
|
|
|
import ChiyaWeb.Format, only: [pretty_datetime: 1, pretty_date: 1]
|
2023-03-05 16:07:40 +01:00
|
|
|
|
|
|
|
embed_templates "page_html/*"
|
2023-04-10 19:18:27 +02:00
|
|
|
|
2023-09-09 10:24:22 +02:00
|
|
|
attr :notes, :list, required: true
|
2023-09-09 16:08:30 +02:00
|
|
|
attr :layout, :atom, default: :default
|
2023-09-09 10:24:22 +02:00
|
|
|
attr :show_content, :boolean, default: true
|
|
|
|
def note_list(assigns)
|
|
|
|
|
2023-09-05 21:59:37 +02:00
|
|
|
attr :notes, :list, required: true
|
2023-09-08 12:44:57 +02:00
|
|
|
attr :show_content, :boolean, default: true
|
2023-09-05 21:59:37 +02:00
|
|
|
def note_list_default(assigns)
|
|
|
|
|
2023-09-08 12:46:19 +02:00
|
|
|
attr :notes, :list, required: true
|
2023-09-08 23:01:39 +02:00
|
|
|
attr :show_content, :boolean, default: true
|
2023-09-08 12:46:19 +02:00
|
|
|
def note_list_microblog(assigns)
|
|
|
|
|
|
|
|
attr :notes, :list, required: true
|
2023-09-08 23:01:39 +02:00
|
|
|
attr :show_content, :boolean, default: true
|
2023-09-08 12:46:19 +02:00
|
|
|
def note_list_gallery(assigns)
|
|
|
|
|
2023-09-09 15:06:16 +02:00
|
|
|
attr :note, :map, required: true
|
|
|
|
attr :linked, :boolean, default: true
|
|
|
|
def tag_list(assigns)
|
2023-07-11 07:23:07 +02:00
|
|
|
|
|
|
|
def render_outline(note) do
|
2023-09-09 23:46:37 +02:00
|
|
|
ChiyaWeb.OutlineRenderer.render_outline(note.content)
|
2023-07-11 07:23:07 +02:00
|
|
|
end
|
|
|
|
|
2023-07-19 22:40:32 +02:00
|
|
|
def has_outline?(note) do
|
2023-09-09 23:46:37 +02:00
|
|
|
ChiyaWeb.OutlineRenderer.has_outline?(note.content)
|
2023-07-11 07:23:07 +02:00
|
|
|
end
|
2023-09-09 10:24:22 +02:00
|
|
|
|
|
|
|
def group_tags(notes) do
|
|
|
|
Enum.reduce(notes, [], fn n, acc ->
|
|
|
|
acc ++ n.tags
|
|
|
|
end)
|
|
|
|
|> Enum.uniq_by(fn t -> t.id end)
|
|
|
|
|> Enum.sort_by(fn t -> t.slug end, :asc)
|
|
|
|
|> Enum.group_by(
|
|
|
|
fn n -> String.first(n.name) end,
|
|
|
|
fn n -> n end
|
|
|
|
)
|
|
|
|
end
|
2023-03-05 16:07:40 +01:00
|
|
|
end
|