From d97be57871084fb7e02a8833bb13d35644eaf464 Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 30 Mar 2023 22:54:03 +0200 Subject: [PATCH 1/7] order admin notes --- lib/chiya/notes.ex | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/chiya/notes.ex b/lib/chiya/notes.ex index 0ff5da3..ab8b783 100644 --- a/lib/chiya/notes.ex +++ b/lib/chiya/notes.ex @@ -20,7 +20,10 @@ defmodule Chiya.Notes do """ def list_notes do - Repo.all(Note) |> Repo.preload(@preloads) + Note + |> order_by([n], [desc: n.updated_at, desc: n.published_at]) + |> Repo.all() + |> Repo.preload(@preloads) end @doc """ From 671049b4fc7f9f446100590dcb5370e7eaa411a7 Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 30 Mar 2023 22:54:15 +0200 Subject: [PATCH 2/7] add default value for note kind --- lib/chiya/notes/note.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chiya/notes/note.ex b/lib/chiya/notes/note.ex index 27c0e8a..6a49a82 100644 --- a/lib/chiya/notes/note.ex +++ b/lib/chiya/notes/note.ex @@ -5,7 +5,7 @@ defmodule Chiya.Notes.Note do @derive {Jason.Encoder, only: [:id, :name, :content, :slug, :channels]} schema "notes" do field :content, :string - field :kind, Ecto.Enum, values: [:post, :bookmark] + field :kind, Ecto.Enum, values: [:post, :bookmark], default: :post field :name, :string field :published_at, :naive_datetime field :slug, :string From 7e0f009a5845b47a9909c3ad8a2ab719e53b19d5 Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 30 Mar 2023 22:55:24 +0200 Subject: [PATCH 3/7] add class to input component --- lib/chiya_web/components/core_components.ex | 4 ++++ lib/chiya_web/controllers/setting_html/setting_form.html.heex | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/chiya_web/components/core_components.ex b/lib/chiya_web/components/core_components.ex index fdae68c..a17cf83 100644 --- a/lib/chiya_web/components/core_components.ex +++ b/lib/chiya_web/components/core_components.ex @@ -305,6 +305,8 @@ defmodule ChiyaWeb.CoreComponents do <.input name="my-input" errors={["oh no!"]} /> """ attr :id, :any, default: nil + attr :class, :string, default: nil + attr :name, :any attr :label, :string, default: nil attr :value, :any @@ -391,6 +393,7 @@ defmodule ChiyaWeb.CoreComponents do "phx-no-feedback:border-gray-300 phx-no-feedback:focus:border-gray-400 phx-no-feedback:focus:ring-gray-800/5", "border-gray-300 focus:border-gray-400 focus:ring-gray-800/5", "dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700 dark:focus:border-gray-400", + @class, @errors != [] && "border-rose-400 focus:border-rose-400 focus:ring-rose-400/10" ]} {@rest} @@ -415,6 +418,7 @@ defmodule ChiyaWeb.CoreComponents do "phx-no-feedback:border-gray-300 phx-no-feedback:focus:border-gray-400 phx-no-feedback:focus:ring-gray-800/5", "border-gray-300 focus:border-gray-400 focus:ring-gray-800/5", "dark:bg-gray-800 dark:text-gray-300 dark:border-gray-700 dark:focus:border-gray-400", + @class, @errors != [] && "border-rose-400 focus:border-rose-400 focus:ring-rose-400/10" ]} {@rest} diff --git a/lib/chiya_web/controllers/setting_html/setting_form.html.heex b/lib/chiya_web/controllers/setting_html/setting_form.html.heex index 1c3bc45..9ddd482 100644 --- a/lib/chiya_web/controllers/setting_html/setting_form.html.heex +++ b/lib/chiya_web/controllers/setting_html/setting_form.html.heex @@ -12,8 +12,8 @@ options={Ecto.Enum.values(Chiya.Site.Setting, :theme)} /> <.input field={f[:user_agent]} type="text" label="User agent" /> - <.input field={f[:custom_css]} type="textarea" label="Custom css" /> - <.input field={f[:custom_html]} type="textarea" label="Custom html" /> + <.input field={f[:custom_css]} type="textarea" label="Custom css" class="font-mono" /> + <.input field={f[:custom_html]} type="textarea" label="Custom html" class="font-mono" /> <.input field={f[:home_channel_id]} type="select" label="Home Channel" options={@channels} /> <:actions> <.button>Save Setting From 82d2aeebaf53ec8c66c01c3f508eab5cfc4cdc29 Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 30 Mar 2023 22:56:06 +0200 Subject: [PATCH 4/7] improve menus --- lib/chiya_web/components/admin_components.ex | 17 +++++++++++++---- lib/chiya_web/components/layouts/app.html.heex | 8 +------- .../components/layouts/public.html.heex | 6 ++---- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/lib/chiya_web/components/admin_components.ex b/lib/chiya_web/components/admin_components.ex index 4731b5a..1e5fb41 100644 --- a/lib/chiya_web/components/admin_components.ex +++ b/lib/chiya_web/components/admin_components.ex @@ -65,11 +65,20 @@ defmodule ChiyaWeb.AdminComponents do def admin_bar(assigns) do ~H""" -
    +
      +
    • + <.link + href={~p"/"} + class="flex gap-3 text-sm leading-6 text-gray-100 font-semibold hover:text-gray-300" + > + Chiya +

      + v<%= Application.spec(:chiya, :vsn) %> +

      + +
    • +
    • <%= if @current_user do %> -
    • - <%= @current_user.email %> -
    • <.link href="#" diff --git a/lib/chiya_web/components/layouts/app.html.heex b/lib/chiya_web/components/layouts/app.html.heex index f6f9915..7dd5e54 100644 --- a/lib/chiya_web/components/layouts/app.html.heex +++ b/lib/chiya_web/components/layouts/app.html.heex @@ -1,11 +1,5 @@
      -
      -
      - Chiya -

      - v<%= Application.spec(:chiya, :vsn) %> -

      -
      +
      <.link href={~p"/admin/notes"} diff --git a/lib/chiya_web/components/layouts/public.html.heex b/lib/chiya_web/components/layouts/public.html.heex index 34dbe38..584b614 100644 --- a/lib/chiya_web/components/layouts/public.html.heex +++ b/lib/chiya_web/components/layouts/public.html.heex @@ -1,8 +1,5 @@
      -
      -
      - Chiya -
      +
      <.link href={~p"/n/about"} @@ -13,6 +10,7 @@
      +
      <.flash_group flash={@flash} /> From b815344885e2df0638bb4d4004ad9efe1b9f309e Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 30 Mar 2023 22:56:47 +0200 Subject: [PATCH 5/7] improve links on home, adjust to themes --- lib/chiya_web/controllers/page_html/home.html.heex | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/chiya_web/controllers/page_html/home.html.heex b/lib/chiya_web/controllers/page_html/home.html.heex index d4f14a7..4d3682e 100644 --- a/lib/chiya_web/controllers/page_html/home.html.heex +++ b/lib/chiya_web/controllers/page_html/home.html.heex @@ -15,7 +15,7 @@ rel={identity.rel} href={identity.url} target="_blank" - class="group -mx-2 -my-0.5 inline-flex items-center gap-3 rounded-lg px-2 py-0.5 hover:bg-theme-dim" + class="group -mx-2 -my-0.5 inline-flex items-center gap-3 rounded-lg px-2 py-0.5 hover:bg-theme-primary/10 transition" > <%= raw identity.icon %> <%= identity.name %> @@ -27,9 +27,9 @@ <%= if @channel do %> From a429629b7925c3d5a590f79afc02b9fab13f5f5a Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 30 Mar 2023 22:56:58 +0200 Subject: [PATCH 6/7] show updated at in admin notes --- lib/chiya_web/controllers/note_html/index.html.heex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/chiya_web/controllers/note_html/index.html.heex b/lib/chiya_web/controllers/note_html/index.html.heex index 4fd190c..814b11f 100644 --- a/lib/chiya_web/controllers/note_html/index.html.heex +++ b/lib/chiya_web/controllers/note_html/index.html.heex @@ -9,8 +9,8 @@ <.table id="notes" rows={@notes} row_click={&JS.navigate(~p"/admin/notes/#{&1}")}> <:col :let={note} label="Name"><%= note.name %> + <:col :let={note} label="Updated at"><%= from_now(note.updated_at) %> <:col :let={note} label="Published at"><%= from_now(note.published_at) %> - <:col :let={note} label="Kind"><%= note.kind %> <:action :let={note}>
      <.link navigate={~p"/admin/notes/#{note}"}>Show From 54dea4e2a2b8a881b0ba709fff3d32cca5c2ca4f Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 30 Mar 2023 23:09:39 +0200 Subject: [PATCH 7/7] make link color and version badge primary --- assets/css/app.css | 4 ++++ lib/chiya_web/components/admin_components.ex | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/assets/css/app.css b/assets/css/app.css index dd07431..c526f3e 100644 --- a/assets/css/app.css +++ b/assets/css/app.css @@ -50,6 +50,10 @@ @apply prose-invert; } +.prose :where(a):not(:where([class~="not-prose"] *)) { + @apply underline decoration-2 decoration-theme-primary; +} + /* Set width and color for identity icons */ a[rel] svg { width: 1em; diff --git a/lib/chiya_web/components/admin_components.ex b/lib/chiya_web/components/admin_components.ex index 1e5fb41..cd71075 100644 --- a/lib/chiya_web/components/admin_components.ex +++ b/lib/chiya_web/components/admin_components.ex @@ -72,7 +72,7 @@ defmodule ChiyaWeb.AdminComponents do class="flex gap-3 text-sm leading-6 text-gray-100 font-semibold hover:text-gray-300" > Chiya -

      +

      v<%= Application.spec(:chiya, :vsn) %>