feat: Implement blog post management including database schema, models, handlers, and UI.

This commit is contained in:
2026-03-03 16:34:38 +00:00
parent aee36fa70d
commit ef068f7dfa
7 changed files with 415 additions and 0 deletions

65
templates/post_edit.html Normal file
View 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 %}