burst of energy

This commit is contained in:
Inhji 2023-09-09 16:08:30 +02:00
parent d822f6ecb2
commit 58f5bd364c
22 changed files with 202 additions and 40 deletions

View file

@ -4,6 +4,7 @@
@import "./lightbox.css";
@import "./tablesort.css";
@import "./tokyo-night-dark.css";
/*
The base layer is for things like reset rules or default styles applied to plain HTML elements.
@ -110,11 +111,29 @@
.dot {
@apply before:content-['·']
}
.pagination {
@apply flex justify-between mt-6;
& .pagination-previous, & .pagination-next {
@apply block py-2 px-3 bg-slate-700 text-white rounded;
}
& .pagination-previous.disabled, & .pagination-next.disabled {
@apply bg-slate-500;
}
& .pagination-list {
@apply hidden;
}
}
}
/*
The utilities layer is for small, single-purpose classes that should always take precedence over any other styles.
*/
@layer utilities {
.hljs {
background: transparent !important;
}
}

View file

@ -0,0 +1,117 @@
/*!
Theme: Tokyo-night-Dark
origin: https://github.com/enkia/tokyo-night-vscode-theme
Description: Original highlight.js style
Author: (c) Henri Vandersleyen <hvandersleyen@gmail.com>
License: see project LICENSE
Touched: 2022
*/
/* Comment */
.hljs-meta,
.hljs-comment {
color: #565f89;
}
/* Red */
/*INFO: This keyword, HTML elements, Regex group symbol, CSS units, Terminal Red */
.hljs-tag,
.hljs-doctag,
.hljs-selector-id,
.hljs-selector-class,
.hljs-regexp,
.hljs-template-tag,
.hljs-selector-pseudo,
.hljs-selector-attr,
.hljs-variable.language_,
.hljs-deletion {
color: #f7768e;
}
/*Orange */
/*INFO: Number and Boolean constants, Language support constants */
.hljs-variable,
.hljs-template-variable,
.hljs-number,
.hljs-literal,
.hljs-type,
.hljs-params,
.hljs-link {
color: #ff9e64;
}
/* Yellow */
/* INFO: Function parameters, Regex character sets, Terminal Yellow */
.hljs-built_in,
.hljs-attribute {
color: #e0af68;
}
/* cyan */
/* INFO: Language support functions, CSS HTML elements */
.hljs-selector-tag {
color: #2ac3de;
}
/* light blue */
/* INFO: Object properties, Regex quantifiers and flags, Markdown headings, Terminal Cyan, Markdown code, Import/export keywords */
.hljs-keyword,
.hljs-title.function_,
.hljs-title,
.hljs-title.class_,
.hljs-title.class_.inherited__,
.hljs-subst,
.hljs-property {color: #7dcfff;}
/*Green*/
/* INFO: Object literal keys, Markdown links, Terminal Green */
.hljs-selector-tag { color: #73daca;}
/*Green(er) */
/* INFO: Strings, CSS class names */
.hljs-quote,
.hljs-string,
.hljs-symbol,
.hljs-bullet,
.hljs-addition {
color: #9ece6a;
}
/* Blue */
/* INFO: Function names, CSS property names, Terminal Blue */
.hljs-code,
.hljs-formula,
.hljs-section {
color: #7aa2f7;
}
/* Magenta */
/*INFO: Control Keywords, Storage Types, Regex symbols and operators, HTML Attributes, Terminal Magenta */
.hljs-name,
.hljs-keyword,
.hljs-operator,
.hljs-keyword,
.hljs-char.escape_,
.hljs-attr {
color: #bb9af7;
}
/* white*/
/* INFO: Variables, Class names, Terminal White */
.hljs-punctuation {color: #c0caf5}
.hljs {
background: #1a1b26;
color: #9aa5ce;
}
.hljs-emphasis {
font-style: italic;
}
.hljs-strong {
font-weight: bold;
}

View file

@ -59,7 +59,7 @@ config :chiya, ChiyaWeb.Endpoint,
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/chiya_web/(controllers|live|components)/.*(ex|heex)$"
],
]
]
# Enable dev routes for dashboard and mailbox

View file

@ -39,6 +39,19 @@ defmodule Chiya.Notes do
|> Repo.preload(@preloads)
end
def list_home_notes(channel, params) do
q =
list_notes_by_channel_query(channel)
|> where([n], not is_nil(n.published_at))
|> order_by([n], desc: n.updated_at, desc: n.published_at)
|> preload(^@preloads)
Flop.validate_and_run(q, params,
for: Chiya.Notes.Note,
repo: Chiya.Repo
)
end
def list_notes_by_channel(%Chiya.Channels.Channel{} = channel) do
list_notes_by_channel_query(channel)
|> order_by([n], desc: n.updated_at, desc: n.published_at)

View file

@ -11,6 +11,10 @@ defmodule Chiya.Notes.Note do
@reserved_slugs ~w(user admin dev api)
@note_url_regex ~r/\/note\/([a-z0-9-]+)/
@derive {
Flop.Schema,
filterable: [:name, :kind], sortable: [:name], default_limit: 10, max_limit: 100
}
@derive {Jason.Encoder, only: [:id, :name, :content, :slug, :channels, :tags]}
schema "notes" do
field :content, :string

View file

@ -98,7 +98,7 @@
</div>
</nav>
</aside>
<section id="content-wrapper">
<%= @inner_content %>
</section>

View file

@ -58,16 +58,13 @@ defmodule ChiyaWeb.PublicComponents do
<h1 class={["text-3xl leading-10 font-bold text-theme-base1", @class_title]}>
<%= render_slot(@inner_block) %>
</h1>
<p
:if={@subtitle != []}
class={["mt-4 leading-7 text-theme-base", @class_subtitle]}
>
<p :if={@subtitle != []} class={["mt-4 leading-7 text-theme-base", @class_subtitle]}>
<%= render_slot(@subtitle) %>
</p>
</header>
"""
end
attr :note, :map, required: true
def featured_images(assigns) do

View file

@ -4,17 +4,24 @@ defmodule ChiyaWeb.PageController do
plug :put_layout, html: {ChiyaWeb.Layouts, :public}
def home(conn, _params) do
def home(conn, params) do
settings = conn.assigns.settings
channel =
{channel, notes, meta} =
case settings.home_channel_id do
nil -> nil
id -> Channels.get_channel!(id) |> Channels.preload_channel_public()
nil ->
nil
id ->
channel = Channels.get_channel!(id)
{:ok, {notes, meta}} = Chiya.Notes.list_home_notes(channel, params)
{channel, notes, meta}
end
render(conn, :home,
channel: channel,
notes: notes,
meta: meta,
page_title: "Home"
)
end
@ -81,7 +88,7 @@ defmodule ChiyaWeb.PageController do
)
else
render_error(conn, :not_found)
end
end
end
def bookmarks(conn, _params) do
@ -96,6 +103,6 @@ defmodule ChiyaWeb.PageController do
)
else
render_error(conn, :not_found)
end
end
end
end

View file

@ -6,7 +6,7 @@ defmodule ChiyaWeb.PageHTML do
embed_templates "page_html/*"
attr :notes, :list, required: true
attr :layout, :atom, default: :default
attr :layout, :atom, default: :default
attr :show_content, :boolean, default: true
def note_list(assigns)

View file

@ -11,4 +11,3 @@
<.tag_bar notes={@notes} />
</aside>
</section>

View file

@ -1,3 +1,3 @@
<%= if @channel do %>
<.note_list notes={@channel.notes} layout={@channel.layout} />
<% end %>
<.note_list notes={@notes} layout={@channel.layout} />
<Flop.Phoenix.pagination meta={@meta} path={~p"/"} />

View file

@ -57,7 +57,6 @@
<% end %>
</section>
</article>
</section>
<aside class="prose max-w-none">
@ -78,14 +77,16 @@
<strong>Published</strong>
<% else %>
<strong>Unpublished</strong>
<% end %> <time class="dt-published"><%= pretty_date(@note.published_at) %></time>
<% end %>
<time class="dt-published"><%= pretty_date(@note.published_at) %></time>
</li>
<li>
<strong>Last updated</strong> <time class="dt-published"><%= pretty_date(@note.published_at) %></time>
<strong>Last updated</strong>
<time class="dt-published"><%= pretty_date(@note.published_at) %></time>
</li>
<li><strong>Tags</strong> <.tag_list note={@note} /></li>
<li><strong>Kind</strong> <%= @note.kind %></li>
</ul>
</ul>
</section>
<h3>Admin</h3>
@ -106,4 +107,3 @@
</section>
</aside>
</section>

View file

@ -1,9 +1,9 @@
<%= if @layout == :default do %>
<.note_list_default notes={@notes} show_content={@show_content}/>
<.note_list_default notes={@notes} show_content={@show_content} />
<% end %>
<%= if @layout == :gallery do %>
<.note_list_gallery notes={@notes} show_content={@show_content}/>
<.note_list_gallery notes={@notes} show_content={@show_content} />
<% end %>
<%= if @layout == :microblog do %>
<.note_list_microblog notes={@notes} show_content={@show_content}/>
<.note_list_microblog notes={@notes} show_content={@show_content} />
<% end %>

View file

@ -1,10 +1,7 @@
<section class="note-list default stack">
<%= for note <- assigns.notes do %>
<article>
<a
href={~p"/note/#{note.slug}"}
class="block"
>
<a href={~p"/note/#{note.slug}"} class="block">
<header class="flex flex-row items-center gap-1">
<span class="text-theme-primary text-lg font-semibold leading-8 flex-1">
<%= note.name %>
@ -28,4 +25,4 @@
</a>
</article>
<% end %>
</section>
</section>

View file

@ -11,4 +11,4 @@
<section>
<.tag_bar notes={@tag.notes} />
</section>
</section>
</section>

View file

@ -10,9 +10,12 @@
href={~p"/tagged-with/#{tag.slug}"}
class="border border-theme-background1 rounded font-sm px-2 py-1 inline-block mb-2 hover:bg-theme-background1 transition"
>
<%= tag.name %> <span class="text-theme-base text-xs font-mono bg-theme-primary/25 rounded-full py-0.5 px-1 align-middle"><%= Enum.count(tag.notes) %></span>
<%= tag.name %>
<span class="text-theme-base text-xs font-mono bg-theme-primary/25 rounded-full py-0.5 px-1 align-middle">
<%= Enum.count(tag.notes) %>
</span>
</a>
<% end %>
</li>
<% end %>
</ul>
</ul>

View file

@ -3,7 +3,7 @@
<%= if @linked do %>
<a class="tag | flex gap-0" href={~p"/tagged-with/#{tag.slug}"}>
<span>#</span>
<span class="p-category" >
<span class="p-category">
<%= tag.name %>
</span>
</a>
@ -17,4 +17,4 @@
<% end %>
<span class="dot last:hidden" />
<% end %>
</span>
</span>

View file

@ -11,4 +11,4 @@
<aside>
<.tag_bar notes={@notes} />
</aside>
</section>
</section>

View file

@ -58,4 +58,4 @@ defmodule ChiyaWeb.Plugs.PlugMicropub.HandlerBehaviour do
@callback handle_media(file :: Plug.Upload.t(), access_token) ::
{:ok, url :: String.t()} | handler_error
end
end

View file

@ -40,6 +40,8 @@ defmodule Chiya.MixProject do
{:ecto_sql, "~> 3.6"},
{:finch, "~> 0.16"},
{:floki, ">= 0.30.0", only: :test},
{:flop, "~> 0.22.1"},
{:flop_phoenix, "~> 0.21.1"},
{:gettext, "~> 0.23"},
{:jason, "~> 1.2"},
{:oban, "~> 2.14"},

View file

@ -20,6 +20,8 @@
"file_system": {:hex, :file_system, "0.2.10", "fb082005a9cd1711c05b5248710f8826b02d7d1784e7c3451f9c1231d4fc162d", [:mix], [], "hexpm", "41195edbfb562a593726eda3b3e8b103a309b733ad25f3d642ba49696bf715dc"},
"finch": {:hex, :finch, "0.16.0", "40733f02c89f94a112518071c0a91fe86069560f5dbdb39f9150042f44dcfb1a", [:mix], [{:castore, "~> 0.1 or ~> 1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:mint, "~> 1.3", [hex: :mint, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.4 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:nimble_pool, "~> 0.2.6 or ~> 1.0", [hex: :nimble_pool, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "f660174c4d519e5fec629016054d60edd822cdfe2b7270836739ac2f97735ec5"},
"floki": {:hex, :floki, "0.34.3", "5e2dcaec5d7c228ce5b1d3501502e308b2d79eb655e4191751a1fe491c37feac", [:mix], [], "hexpm", "9577440eea5b97924b4bf3c7ea55f7b8b6dce589f9b28b096cc294a8dc342341"},
"flop": {:hex, :flop, "0.22.1", "4eb5dc1c159845e31d33cd8e73e249b84d013d3b9b1fb17619e70d55fbd2b025", [:mix], [{:ecto, "~> 3.10.3", [hex: :ecto, repo: "hexpm", optional: false]}, {:nimble_options, "~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}], "hexpm", "2f212238d92a8fcc2adadf20dcd875c6f8b4e1ce38ca6bc3f805918a5be567e4"},
"flop_phoenix": {:hex, :flop_phoenix, "0.21.1", "7b7c143e751f985a94624461a25916d1c604a8a3913253f9a38ae619577853d7", [:mix], [{:flop, "~> 0.22.0", [hex: :flop, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.6.0 or ~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "c44ccdda6d8b8dba4b7c885b7173150dc7388e1f5d63bd834d136fbd538f7b4b"},
"gettext": {:hex, :gettext, "0.23.1", "821e619a240e6000db2fc16a574ef68b3bd7fe0167ccc264a81563cc93e67a31", [:mix], [{:expo, "~> 0.4.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "19d744a36b809d810d610b57c27b934425859d158ebd56561bc41f7eeb8795db"},
"hackney": {:hex, :hackney, "1.18.2", "d7ff544ddae5e1cb49e9cf7fa4e356d7f41b283989a1c304bfc47a8cc1cf966f", [:rebar3], [{:certifi, "~> 2.12.0", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "~> 6.1.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "~> 1.0.0", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~> 1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:parse_trans, "3.4.1", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "~> 1.1.0", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}, {:unicode_util_compat, "~> 0.7.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "af94d5c9f97857db257090a4a10e5426ecb6f4918aa5cc666798566ae14b65fd"},
"hpax": {:hex, :hpax, "0.1.2", "09a75600d9d8bbd064cdd741f21fc06fc1f4cf3d0fcc335e5aa19be1a7235c84", [:mix], [], "hexpm", "2c87843d5a23f5f16748ebe77969880e29809580efdaccd615cd3bed628a8c13"},
@ -48,6 +50,8 @@
"poison": {:hex, :poison, "4.0.1", "bcb755a16fac91cad79bfe9fc3585bb07b9331e50cfe3420a24bcc2d735709ae", [:mix], [], "hexpm", "ba8836feea4b394bb718a161fc59a288fe0109b5006d6bdf97b6badfcf6f0f25"},
"postgrex": {:hex, :postgrex, "0.17.3", "c92cda8de2033a7585dae8c61b1d420a1a1322421df84da9a82a6764580c503d", [:mix], [{:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "946cf46935a4fdca7a81448be76ba3503cff082df42c6ec1ff16a4bdfbfb098d"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"scrivener": {:hex, :scrivener, "2.7.2", "1d913c965ec352650a7f864ad7fd8d80462f76a32f33d57d1e48bc5e9d40aba2", [:mix], [], "hexpm", "7866a0ec4d40274efbee1db8bead13a995ea4926ecd8203345af8f90d2b620d9"},
"scrivener_html": {:git, "https://github.com/workshops-de/scrivener_html", "80752fe8fcb7cd616adf6b5e78c226f158013ddf", []},
"slugger": {:hex, :slugger, "0.3.0", "efc667ab99eee19a48913ccf3d038b1fb9f165fa4fbf093be898b8099e61b6ed", [:mix], [], "hexpm", "20d0ded0e712605d1eae6c5b4889581c3460d92623a930ddda91e0e609b5afba"},
"slugify": {:hex, :slugify, "1.3.1", "0d3b8b7e5c1eeaa960e44dce94382bee34a39b3ea239293e457a9c5b47cc6fd3", [:mix], [], "hexpm", "cb090bbeb056b312da3125e681d98933a360a70d327820e4b7f91645c4d8be76"},
"ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.7", "354c321cf377240c7b8716899e182ce4890c5938111a1296add3ec74cf1715df", [:make, :mix, :rebar3], [], "hexpm", "fe4c190e8f37401d30167c8c405eda19469f34577987c76dde613e838bbc67f8"},

View file

@ -48,7 +48,7 @@ defmodule ChiyaWeb.MicropubTest do
assert {:ok, %Note{} = note} =
Micropub.update_note(note, %{"category" => ["foo", "bar"]}, %{}, %{})
IO.inspect(note)
IO.inspect(note)
assert Enum.empty?(note.tags) == false
end