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: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;
}
}

View file

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

View file

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

View file

@ -30,9 +30,10 @@ defmodule ChiyaWeb.CoreComponents do
"""
end
attr :class, :string, default: nil
def darkmode_toggle(assigns) do
~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="inline dark:hidden"></span>
</.link>

View file

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

View file

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

View file

@ -1,6 +1,11 @@
<.header>
New Note
<: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>
<.note_form
@ -9,6 +14,4 @@
channels={@channels}
tags={@tags}
selected_channels={@selected_channels}
/>
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
/>

View file

@ -2,8 +2,14 @@
<.error :if={@changeset.action}>
Oops, something went wrong! Please check the errors below.
</.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[:published_at]} type="datetime-local" label="Published at" />
<.input

View file

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

View file

@ -3,6 +3,16 @@
<%= @note.name %>
</.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 %>
<aside class="max-w-2xl mx-auto mt-8 prose prose-gruvbox">
<div class="bg-theme-background1 rounded p-2">
@ -54,10 +64,6 @@
<.dot />
<span><%= @note.kind %></span>
<% 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"/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>
</:actions>
</.simple_form>
<.back navigate={~p"/admin/notes"}>Back to notes</.back>
"""
end