108 lines
6.7 KiB
HTML
108 lines
6.7 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}{{ post.title }}{% endblock %}
|
|
{% block content %}
|
|
<div class="max-w-3xl mx-auto">
|
|
<article>
|
|
<header class="mb-4">
|
|
<h1 class="text-4xl font-bold text-gray-900 mb-4 leading-tight">{{ post.title }}</h1>
|
|
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between text-sm text-gray-600">
|
|
<div class="flex items-center space-x-4">
|
|
<div class="flex items-center">
|
|
<div class="w-8 h-8 bg-blue-100 rounded-full flex items-center justify-center mr-2">
|
|
<svg class="w-4 h-4 text-blue-600"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
|
|
</svg>
|
|
</div>
|
|
<a href="/users/{{ post.author }}"
|
|
class="hover:text-blue-600 hover:underline font-medium">{{ post.author }}</a>
|
|
</div>
|
|
<div class="flex items-center">
|
|
<svg class="w-4 h-4 mr-1 text-gray-400"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
|
|
</svg>
|
|
<time datetime="{{ post.published_at }}">
|
|
{{ post.formatted_date() }}
|
|
</time>
|
|
</div>
|
|
</div>
|
|
{% if session_username.as_deref() == Some(post.author) %}
|
|
<div class="mt-4 sm:mt-0">
|
|
<button onclick="document.getElementById('edit-form').classList.toggle('hidden')"
|
|
class="inline-flex items-center px-3 py-1.5 bg-blue-600 hover:bg-blue-700 text-white text-sm font-medium rounded-md transition-colors">
|
|
<svg class="w-4 h-4 mr-1"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z" />
|
|
</svg>
|
|
Edit
|
|
</button>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</header>
|
|
{% if session_username.as_deref() == Some(post.author) %}
|
|
<div id="edit-form"
|
|
class="hidden bg-gray-50 border border-gray-200 rounded-lg p-6">
|
|
<h2 class="text-xl font-bold text-gray-900 mb-4">Edit post</h2>
|
|
<form hx-put="/posts/{{ post.post_id }}"
|
|
hx-target="#edit-messages"
|
|
hx-swap="innerHTML">
|
|
<div class="mb-4">
|
|
<label for="title" class="block text-sm font-medium text-gray-700 mb-2">Title</label>
|
|
<input type="text"
|
|
id="title"
|
|
name="title"
|
|
value="{{ post.title }}"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500">
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="content" class="block text-sm font-medium text-gray-700 mb-2">Content (markdown)</label>
|
|
<textarea id="content"
|
|
name="content"
|
|
rows="12"
|
|
required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 font-mono text-sm">{{ post.content }}</textarea>
|
|
</div>
|
|
<div class="flex items-center space-x-3">
|
|
<button type="submit"
|
|
class="inline-flex items-center px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-md transition-colors">
|
|
<svg class="w-4 h-4 mr-2"
|
|
fill="none"
|
|
viewBox="0 0 24 24"
|
|
stroke="currentColor">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7" />
|
|
</svg>
|
|
Save changes
|
|
</button>
|
|
<button type="button"
|
|
onclick="document.getElementById('edit-form').classList.add('hidden')"
|
|
class="inline-flex items-center px-4 py-2 bg-gray-200 hover:bg-gray-300 text-gray-700 font-medium rounded-md transition-colors">
|
|
Cancel
|
|
</button>
|
|
</div>
|
|
</form>
|
|
<div id="edit-messages" class="mt-6"></div>
|
|
</div>
|
|
{% endif %}
|
|
<div id="content-display" class="prose-compact">{{ post_html | safe }}</div>
|
|
</article>
|
|
<div class="mt-8">{% include "posts/comments/list.html" %}</div>
|
|
<div class="mt-8 bg-gradient-to-r from-blue-600 to-indigo-700 rounded-lg shadow-lg text-white p-8 text-center">
|
|
<h3 class="text-2xl font-bold mb-2">Enjoyed this post?</h3>
|
|
<p class="text-blue-100 mb-4">Subscribe to my newsletter for more insights on Rust backend development.</p>
|
|
<a href="/#newsletter-signup"
|
|
class="inline-block bg-white text-blue-600 hover:bg-gray-100 font-semibold py-3 px-6 rounded-md transition-colors">
|
|
Subscribe
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|