chore: add docker infrastructure, gists feature, attachment system, and admin CLI tools

- Add .dockerignore, Dockerfile, and docker compose targets to Makefile for containerized deployment
- Implement gists router with CRUD operations, database schema, and polymorphic comment/vote reuse
- Create attachment upload system with thumbnail generation, MIME detection, and storage path management
- Add attachments_prune CLI command to clean orphaned attachment records and files
- Introduce rate limiting middleware with 60 requests per minute window
- Add custom 404 and 500 error handlers with SEO-optimized template responses
- Extend database initialization with gists and attachments indexes plus upload site settings defaults
- Update load_comments to include attachment mapping for comment resources
- Register gists and uploads routers in main application and update AGENTS.md documentation
This commit is contained in:
2026-05-12 13:07:34 +00:00
parent ff2585b098
commit aa88f18c03
69 changed files with 3069 additions and 450 deletions
+62
View File
@@ -0,0 +1,62 @@
{% extends "base.html" %}
{% block extra_head %}
<link rel="stylesheet" href="/static/css/gists.css">
<link rel="stylesheet" href="/static/css/post.css">
{% endblock %}
{% block content %}
<div class="gist-detail-page">
<a href="/gists" class="back-link">&larr; Back to Gists</a>
<article class="gist-detail">
<div class="gist-detail-header">
<h1 class="gist-detail-title">{{ gist['title'] }}</h1>
<span class="gist-language-badge">&#x1F4DD; {{ gist['language']|capitalize }}</span>
</div>
<div class="gist-detail-author">
{% set _size = 32 %}{% set _size_class = "sm" %}{% set _user = author %}{% include "_avatar_link.html" %}
<div>
<a href="/profile/{{ author['username'] if author else '#' }}">{{ author['username'] if author else 'Unknown' }}</a>
{% if author and author.get('role') %}
<span style="font-size: 0.75rem; color: var(--text-muted);">&middot; {{ author['role'] }}</span>
{% endif %}
<span style="font-size: 0.75rem; color: var(--text-muted); margin-left: 0.5rem;">&middot; {{ time_ago }}</span>
</div>
</div>
{% if gist.get('description') %}
<div class="gist-detail-desc rendered-content" data-render>{{ gist['description'] }}</div>
{% endif %}
{% if attachments %}
{% include "_attachment_display.html" %}
{% endif %}
<div class="gist-code-block">
<div class="gist-code-header">
<span class="gist-language-name">{{ gist['language']|capitalize }}</span>
<button type="button" class="gist-copy-btn" data-copy="gist-code-content">Copy</button>
</div>
<pre><code id="gist-code-content" class="language-{{ gist['language'] }}">{{ gist['source_code'] }}</code></pre>
</div>
<div class="gist-detail-actions">
{% if user %}
<form method="POST" action="/votes/gist/{{ gist['uid'] }}" style="display:inline;">
<input type="hidden" name="value" value="1">
<button type="submit" class="gist-star-btn">&#x2606; {{ star_count }}</button>
</form>
{% endif %}
{% if is_owner %}
<form method="POST" action="/gists/delete/{{ gist['slug'] or gist['uid'] }}" style="display:inline;">
<button type="submit" class="gist-star-btn" data-confirm="Delete this gist?"><span class="icon">&#x1F5D1;&#xFE0F;</span>Delete</button>
</form>
{% endif %}
</div>
</article>
{% with target_uid=gist['uid'], target_type="gist" %}
{% include "_comment_section.html" %}
{% endwith %}
</div>
{% endblock %}