feat: Implement blog post management including database schema, models, handlers, and UI.
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
</form>
|
||||
<br><br>
|
||||
|
||||
<b>Features</b><br>
|
||||
<ul>
|
||||
<li><a href="/__dungeon/posts">Manage Blog Posts</a></li>
|
||||
</ul>
|
||||
<br>
|
||||
|
||||
<b>System Users</b><br>
|
||||
{% if let Some(err) = error %}
|
||||
<font color="red"><b>{{ err }}</b></font><br>
|
||||
|
||||
65
templates/post_edit.html
Normal file
65
templates/post_edit.html
Normal file
@@ -0,0 +1,65 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}
|
||||
{% if post.is_some() %}Edit Post{% else %}New Post{% endif %}
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<h2>{% if post.is_some() %}Edit Post{% else %}New Post{% endif %}</h2>
|
||||
|
||||
<a href="/__dungeon/posts">Back to Posts</a>
|
||||
<br><br>
|
||||
|
||||
{% if let Some(err) = error %}
|
||||
<font color="red"><b>{{ err }}</b></font><br><br>
|
||||
{% endif %}
|
||||
|
||||
{% if let Some(p) = post %}
|
||||
<form method="POST" action="/__dungeon/posts/edit/{{ p.id }}">
|
||||
{% else %}
|
||||
<form method="POST" action="/__dungeon/posts/new">
|
||||
{% endif %}
|
||||
|
||||
<b>Title:</b><br>
|
||||
<input type="text" name="title" size="50" required
|
||||
value="{% if let Some(p) = post %}{{ p.title }}{% endif %}"><br><br>
|
||||
|
||||
<b>Content (Plain Text):</b><br>
|
||||
<textarea name="content" rows="15" cols="80"
|
||||
required>{% if let Some(p) = post %}{{ p.content }}{% endif %}</textarea><br><br>
|
||||
|
||||
<b>Tags (comma separated):</b><br>
|
||||
<input type="text" name="tags" size="50" value="{% if let Some(p) = post %}{{ p.tags }}{% endif %}"><br><br>
|
||||
|
||||
<b>Categories (comma separated):</b><br>
|
||||
<input type="text" name="categories" size="50"
|
||||
value="{% if let Some(p) = post %}{{ p.categories }}{% endif %}"><br><br>
|
||||
|
||||
<b>Visibility:</b><br>
|
||||
<select name="visibility">
|
||||
<option value="public" {% if let Some(p)=post %}{% if p.visibility=="public" %}selected{% endif %}{% endif
|
||||
%}>
|
||||
Public
|
||||
</option>
|
||||
<option value="private" {% if let Some(p)=post %}{% if p.visibility=="private" %}selected{% endif %}{% endif
|
||||
%}>
|
||||
Private (Requires Login)
|
||||
</option>
|
||||
<option value="password_protected" {% if let Some(p)=post %}{% if p.visibility=="password_protected"
|
||||
%}selected{% endif %}{% endif %}>
|
||||
Password Protected
|
||||
</option>
|
||||
</select><br><br>
|
||||
|
||||
<b>Password (only used if Visibility is Password Protected):</b><br>
|
||||
<input type="text" name="password" size="20" placeholder="Optional">
|
||||
{% if let Some(p) = post %}
|
||||
{% if p.visibility == "password_protected" %}
|
||||
<i>(Leave blank to keep existing password)</i>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<br><br>
|
||||
|
||||
<input type="submit" value="Save Post">
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
||||
42
templates/posts_list.html
Normal file
42
templates/posts_list.html
Normal file
@@ -0,0 +1,42 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Manage Blog Posts{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<h2>Manage Blog Posts</h2>
|
||||
|
||||
<a href="/__dungeon">Back to Dashboard</a> | <a href="/__dungeon/posts/new">Create New Post</a>
|
||||
<br><br>
|
||||
|
||||
{% if let Some(err) = error %}
|
||||
<font color="red"><b>{{ err }}</b></font><br><br>
|
||||
{% endif %}
|
||||
|
||||
{% if posts.is_empty() %}
|
||||
<i>No posts found.</i>
|
||||
{% else %}
|
||||
<table border="1" cellpadding="5" cellspacing="0">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Title</th>
|
||||
<th>Visibility</th>
|
||||
<th>Created At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
{% for post in posts %}
|
||||
<tr>
|
||||
<td>{{ post.id }}</td>
|
||||
<td>{{ post.title }}</td>
|
||||
<td>{{ post.visibility }}</td>
|
||||
<td>{{ post.created_at }}</td>
|
||||
<td>
|
||||
<a href="/__dungeon/posts/edit/{{ post.id }}">Edit</a> |
|
||||
<form method="POST" action="/__dungeon/posts/delete/{{ post.id }}" style="display:inline;">
|
||||
<input type="submit" value="Delete">
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user