feat: Implement public blog post listing and individual post viewing with new public handlers and templates, adding chrono for date formatting.

This commit is contained in:
2026-03-03 17:11:26 +00:00
parent ef068f7dfa
commit 57f2610164
10 changed files with 303 additions and 24 deletions

View File

@@ -3,7 +3,7 @@
<head>
<meta charset="UTF-8">
<title>{{ title }}</title>
<title>blog</title>
<style>
* {
font-family: monospace !important;
@@ -12,8 +12,29 @@
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<h1>{{ title }}</h1>
<p>We are working hard to build something amazing.</p>
<h1>blog</h1>
<p>Welcome to my corner of the web.</p>
<hr size="1">
<h2>Public Posts</h2>
{% if posts.is_empty() %}
<p>No public posts available yet.</p>
{% else %}
{% for (post, author) in posts %}
<p>
<b><a href="/post/{{ post.id }}">{{ post.title }}</a></b><br>
<i>Posted by {{ author }} on {{ post.formatted_created_at() }}</i><br>
{% if !post.categories.is_empty() %}
Categories: {{ post.categories }}<br>
{% endif %}
{% if !post.tags.is_empty() %}
Tags: {{ post.tags }}<br>
{% endif %}
</p>
<br>
{% endfor %}
{% endif %}
</body>
</html>

46
templates/post.html Normal file
View File

@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>{{ post.title }} - Blog</title>
<style>
* {
font-family: monospace !important;
}
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<p><a href="/">[Back to Home]</a></p>
<hr size="1">
<h1>{{ post.title }}</h1>
<p><i>Posted by {{ author_username }} on {{ post.formatted_created_at() }}</i></p>
{% if !post.categories.is_empty() %}
<p>Categories: {{ post.categories }}</p>
{% endif %}
{% if !post.tags.is_empty() %}
<p>Tags: {{ post.tags }}</p>
{% endif %}
{% if post.visibility == "password_protected" %}
<p><b>[This post is password protected. In a full implementation, you'd enter a password here.]</b></p>
<hr size="1">
{% else if post.visibility == "private" %}
<p><b>[This post is private and only visible to authorized users.]</b></p>
<hr size="1">
{% else %}
<hr size="1">
<!-- Assuming content is plain text with newlines -->
<p>
<pre>{{ post.content|safe }}</pre>
</p>
<hr size="1">
{% endif %}
<p><a href="/">[Back to Home]</a></p>
</body>
</html>

View File

@@ -27,7 +27,7 @@
<td>{{ post.id }}</td>
<td>{{ post.title }}</td>
<td>{{ post.visibility }}</td>
<td>{{ post.created_at }}</td>
<td>{{ post.formatted_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;">