feat: Implement basic markdown rendering for post content and user-based visibility for private posts.

This commit is contained in:
2026-03-03 18:19:42 +00:00
parent 82f7e006cf
commit 347ac8af55
7 changed files with 247 additions and 33 deletions

View File

@@ -12,17 +12,30 @@
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<div style="text-align: right;">
{% if let Some(u) = user %}
Logged in as: <b>{{ u.username }}</b> | <form action="/__dungeon/logout" method="post" style="display: inline;">
<input type="submit" value="Logout">
</form>
{% else %}
Not logged in | <a href="/__dungeon/login">Login</a>
{% endif %}
</div>
<h1>blog</h1>
<p>Welcome to my corner of the web.</p>
<hr size="1">
<h2>Public Posts</h2>
<h2>Posts</h2>
{% if posts.is_empty() %}
<p>No public posts available yet.</p>
<p>No posts available yet.</p>
{% else %}
{% for (post, author) in posts %}
<p>
<b><a href="/post/{{ post.id }}">{{ post.title }}</a></b><br>
<b><a href="/post/{{ post.id }}">{{ post.title }}</a></b>
{% if post.visibility == "private" %}
<span style="background-color: #ffff00; color: #000000; padding: 0 4px; font-size: 0.8em;">PRIVATE</span>
{% endif %}
<br>
<i>Posted by {{ author }} on {{ post.formatted_created_at() }}</i><br>
{% if !post.categories.is_empty() %}
Categories: {{ post.categories }}<br>

View File

@@ -8,10 +8,41 @@
* {
font-family: monospace !important;
}
code {
background-color: #f0f0f0;
padding: 2px 4px;
border-radius: 3px;
}
pre {
background-color: #f8f8f8;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
overflow-x: auto;
display: block;
margin: 1em 0;
}
pre code {
background-color: transparent;
padding: 0;
border-radius: 0;
}
</style>
</head>
<body bgcolor="#FFFFFF" text="#000000" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<div style="text-align: right;">
{% if let Some(u) = user %}
Logged in as: <b>{{ u.username }}</b> | <form action="/__dungeon/logout" method="post" style="display: inline;">
<input type="submit" value="Logout">
</form>
{% else %}
Not logged in | <a href="/__dungeon/login">Login</a>
{% endif %}
</div>
<p><a href="/">[Back to Home]</a></p>
<hr size="1">
@@ -28,15 +59,12 @@
{% 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" %}
{% else if post.visibility == "private" && user.is_none() %}
<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>
{{ post.rendered_content()|safe }}
<hr size="1">
{% endif %}