some simple UI to make it work

This commit is contained in:
Priec
2026-05-17 17:46:04 +02:00
parent 0a36e8839c
commit 1d51a23bfb
10 changed files with 333 additions and 148 deletions

View File

@@ -3,34 +3,61 @@
{% block title %}Blog Articles{% endblock title %}
{% block content %}
<h1>Blog Articles</h1>
<p><a href="/admin/blog/articles/new">New article</a></p>
<div class="space-y-2">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<h1 class="text-2xl font-bold">Blog Articles</h1>
<p class="text-sm opacity-70">Create, edit, and remove blog posts.</p>
</div>
<a href="/admin/blog/articles/new" class="btn btn-neutral btn-sm">New article</a>
</div>
{% if articles | length > 0 %}
<table>
<thead>
<tr>
<th>Title</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for article in articles %}
<tr>
<td>{{ article.title }}</td>
<td>{% if article.published %}Published{% else %}Draft{% endif %}</td>
<td>
<a href="/admin/blog/articles/{{ article.id }}/edit">Edit</a>
<form method="post" action="/admin/blog/articles/{{ article.id }}/delete">
<button type="submit">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>No articles yet.</p>
{% endif %}
<div class="card border border-base-300 bg-base-100 shadow-sm">
<div class="card-body">
{% if articles | length > 0 %}
<div class="overflow-x-auto">
<table class="table">
<thead>
<tr>
<th>Title</th>
<th>Status</th>
<th class="text-right">Actions</th>
</tr>
</thead>
<tbody>
{% for article in articles %}
<tr>
<td class="font-medium">{{ article.title }}</td>
<td>
{% if article.published %}
<span class="badge">Published</span>
{% else %}
<span class="badge opacity-70">Draft</span>
{% endif %}
</td>
<td>
<div class="flex gap-2">
<a href="/admin/blog/articles/{{ article.id }}/edit" class="btn btn-ghost btn-sm">Edit</a>
<form method="post" action="/admin/blog/articles/{{ article.id }}/delete">
<button type="submit" class="btn btn-ghost btn-sm">Delete</button>
</form>
</div>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="text-center">
<p class="font-medium">No articles yet.</p>
<p class="text-sm opacity-70">Create the first blog post.</p>
<div class="pt-2">
<a href="/admin/blog/articles/new" class="btn btn-neutral btn-sm">New article</a>
</div>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock content %}

View File

@@ -3,29 +3,49 @@
{% block title %}New Article{% endblock title %}
{% block content %}
<h1>New Article</h1>
<div class="space-y-2">
<div class="flex flex-wrap items-center justify-between gap-3">
<div>
<h1 class="text-2xl font-bold">New Article</h1>
<p class="text-sm opacity-70">Create a blog post for the public site.</p>
</div>
<a href="/admin/blog/articles" class="btn btn-ghost btn-sm">Back to articles</a>
</div>
<form method="post" action="/admin/blog/articles">
<label>
Title
<input type="text" name="title" required>
</label>
<label>
Excerpt
<textarea name="excerpt" rows="4"></textarea>
</label>
<label>
Content
<textarea name="content" rows="18" required></textarea>
</label>
<label>
Featured image id
<input type="text" name="featured_image_id">
</label>
<label>
<input type="checkbox" name="published">
Published
</label>
<button type="submit">Create</button>
</form>
<div class="card border border-base-300 bg-base-100 shadow-sm">
<div class="card-body">
<form method="post" action="/admin/blog/articles" class="space-y-2">
<div class="form-control">
<label class="label"><span class="label-text">Title</span></label>
<input type="text" name="title" required class="input input-bordered w-full">
</div>
<div class="form-control">
<label class="label"><span class="label-text">Excerpt</span></label>
<textarea name="excerpt" rows="4" class="textarea textarea-bordered w-full"></textarea>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Content</span></label>
<textarea name="content" rows="18" required class="textarea textarea-bordered w-full"></textarea>
</div>
<div class="form-control">
<label class="label"><span class="label-text">Featured image id</span></label>
<input type="text" name="featured_image_id" class="input input-bordered w-full">
</div>
<label class="label cursor-pointer justify-start gap-2">
<input type="checkbox" name="published" class="checkbox checkbox-sm">
<span class="label-text">Published</span>
</label>
<div class="flex flex-wrap gap-2 pt-2">
<button type="submit" class="btn btn-neutral btn-sm">Create</button>
<a href="/admin/blog/articles" class="btn btn-ghost btn-sm">Cancel</a>
</div>
</form>
</div>
</div>
</div>
{% endblock content %}