devel #223

Merged
inhji merged 4 commits from devel into main 2023-07-20 20:40:11 +02:00
11 changed files with 46 additions and 32 deletions

View file

@ -140,7 +140,7 @@
.footnote:before { content: '{'; } .footnote:before { content: '{'; }
.footnote:after { content: '}'; } .footnote:after { content: '}'; }
body > header nav a { a.button {
@apply inline-block text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold; @apply inline-block text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold;
} }
} }

View file

@ -202,6 +202,8 @@ defmodule Chiya.Notes do
%Note{} %Note{}
|> Note.changeset(attrs) |> Note.changeset(attrs)
|> Repo.insert() |> Repo.insert()
|> Chiya.Tags.TagUpdater.update_tags(attrs)
|> Chiya.Notes.References.update_references(attrs)
end end
@doc """ @doc """

View file

@ -9,7 +9,9 @@ defmodule Chiya.Tags.TagUpdater do
alias Chiya.Notes.Note alias Chiya.Notes.Note
def update_tags({:ok, %Note{} = note}, attrs) do def update_tags({:ok, %Note{} = note}, attrs) do
update_tags(note, attrs) note
|> Notes.preload_note()
|> update_tags(attrs)
{:ok, note} {:ok, note}
end end

View file

@ -30,9 +30,10 @@ defmodule ChiyaWeb.CoreComponents do
""" """
end end
attr :class, :string, default: nil
def darkmode_toggle(assigns) do def darkmode_toggle(assigns) do
~H""" ~H"""
<.link href="#" id="dark-mode-toggle" class="text-sm leading-6"> <.link href="#" id="dark-mode-toggle" class={["text-sm leading-6", @class]}>
<span class="hidden dark:inline">🌙</span> <span class="hidden dark:inline">🌙</span>
<span class="inline dark:hidden"></span> <span class="inline dark:hidden"></span>
</.link> </.link>

View file

@ -42,30 +42,30 @@
<nav class="mx-auto max-w-2xl"> <nav class="mx-auto max-w-2xl">
<ul class="flex gap-3"> <ul class="flex gap-3">
<li> <li>
<a href="/"> <a href="/" class="button">
<.icon name="hero-home" /> Home <.icon name="hero-home" /> Home
</a> </a>
</li> </li>
<li> <li>
<a href="/about"> <a href="/about" class="button">
<.icon name="hero-face-smile" /> About <.icon name="hero-face-smile" /> About
</a> </a>
</li> </li>
<li> <li>
<a href="/wiki"> <a href="/wiki" class="button">
<.icon name="hero-paper-clip" /> Wiki <.icon name="hero-paper-clip" /> Wiki
</a> </a>
</li> </li>
<%= if @current_user do %> <%= if @current_user do %>
<li> <li>
<a href="/admin"> <a href="/admin" class="button">
<.icon name="hero-beaker" /> Admin <.icon name="hero-beaker" /> Admin
</a> </a>
</li> </li>
<% end %> <% end %>
<li class="flex-1"></li> <li class="flex-1"></li>
<li> <li>
<.darkmode_toggle /> <.darkmode_toggle class="button" />
</li> </li>
</ul> </ul>
</nav> </nav>

View file

@ -1,6 +1,10 @@
<.header> <.header>
Edit Note <%= @note.id %> Edit Note “<%= @note.name %>”
<:subtitle>Use this form to manage note records in your database.</:subtitle> <:actions>
<.link href={~p"/admin/notes/#{@note.id}"}>
<.button><.icon name="hero-arrow-left" /> Back to Note</.button>
</.link>
</:actions>
</.header> </.header>
<.note_form <.note_form
@ -9,6 +13,4 @@
channels={@channels} channels={@channels}
selected_channels={@selected_channels} selected_channels={@selected_channels}
tags={@tags} tags={@tags}
/> />
<.back navigate={~p"/admin/notes/#{@note.id}"}>Back to note</.back>

View file

@ -1,6 +1,11 @@
<.header> <.header>
New Note New Note
<:subtitle>Use this form to manage note records in your database.</:subtitle> <:subtitle>Use this form to manage note records in your database.</:subtitle>
<:actions>
<.link href={~p"/admin/notes"}>
<.button><.icon name="hero-arrow-left" /> Back to Notes</.button>
</.link>
</:actions>
</.header> </.header>
<.note_form <.note_form
@ -9,6 +14,4 @@
channels={@channels} channels={@channels}
tags={@tags} tags={@tags}
selected_channels={@selected_channels} selected_channels={@selected_channels}
/> />
<.back navigate={~p"/admin/notes"}>Back to notes</.back>

View file

@ -2,8 +2,14 @@
<.error :if={@changeset.action}> <.error :if={@changeset.action}>
Oops, something went wrong! Please check the errors below. Oops, something went wrong! Please check the errors below.
</.error> </.error>
<.input field={f[:name]} type="text" label="Name" />
<.input field={f[:content]} type="textarea" label="Content" rows="15" /> <.input field={f[:name]} type="text" />
<.input field={f[:content]}
type="textarea"
label="Content"
rows="15"
class="font-mono"
/>
<.input field={f[:slug]} type="text" label="Slug" /> <.input field={f[:slug]} type="text" label="Slug" />
<.input field={f[:published_at]} type="datetime-local" label="Published at" /> <.input field={f[:published_at]} type="datetime-local" label="Published at" />
<.input <.input

View file

@ -7,19 +7,13 @@
<section class="text-sm my-8"> <section class="text-sm my-8">
<ul class="flex flex-wrap gap-3"> <ul class="flex flex-wrap gap-3">
<li> <li>
<a <a href="#" class="button">
href="#"
class="inline-block text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold"
>
<.icon name="hero-megaphone" /> <.icon name="hero-megaphone" />
</a> </a>
</li> </li>
<%= for channel <- @channels do %> <%= for channel <- @channels do %>
<li> <li>
<a <a href={~p"/channel/#{channel.slug}"} class="button">
href={~p"/channel/#{channel.slug}"}
class="inline-block text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold"
>
<%= channel.name %> <%= channel.name %>
</a> </a>
</li> </li>

View file

@ -3,6 +3,16 @@
<%= @note.name %> <%= @note.name %>
</.header> </.header>
<%= if @current_user do %>
<section class="max-w-2xl mx-auto mt-8">
<ul class="flex gap-3">
<li><a href={~p"/admin/notes/#{@note}/edit"} class="button">
<.icon name="hero-pencil-square" /> Edit</a></li>
<li><a href={~p"/admin/notes/#{@note}"} class="button">Show in Admin</a></li>
</ul>
</section>
<% end %>
<%= if has_outline?(@note) do %> <%= if has_outline?(@note) do %>
<aside class="max-w-2xl mx-auto mt-8 prose prose-gruvbox"> <aside class="max-w-2xl mx-auto mt-8 prose prose-gruvbox">
<div class="bg-theme-background1 rounded p-2"> <div class="bg-theme-background1 rounded p-2">
@ -54,10 +64,6 @@
<.dot /> <.dot />
<span><%= @note.kind %></span> <span><%= @note.kind %></span>
<% end %> <% 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>

View file

@ -102,8 +102,6 @@ defmodule ChiyaWeb.NoteShowLive do
<.button phx-disable-with="Changing...">Add Images</.button> <.button phx-disable-with="Changing...">Add Images</.button>
</:actions> </:actions>
</.simple_form> </.simple_form>
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
""" """
end end