Phase B. Images on threads and comments, stored in /data/uploads — inside the volume that already holds board.db, so there is one directory to back up rather than two and no second mount to remember. Not in the site repository, which is the distinction that matters: the content editor uploads by committing, and a private photo committed there would go through the build pipeline and out onto vienalatina.com. The type is decided by the first bytes, not the filename. content.py trusts the extension, which is tolerable where Hugo serves the result; here we serve it back, so an HTML file called gato.png would be a script running on our own origin. Five magic-number checks, no new dependency. The uploaded name is kept only as text to show a person; the name on disk is generated. Staging is separate from saving so a refused picture cannot leave a half-made thread behind. Threads and comments are soft-deleted, so the serving route checks the parent is still live. Without it, taking a post down leaves its photo readable by anyone who noted the URL. And the hole this phase existed to close: backup-board.sh archived board.db and nothing else, so the first upload would have made the nightly backup silently incomplete while still reporting success. It now archives the uploads directory too, verifies the archive, and names the directory when it is empty rather than passing over it in silence. Tested by restoring: destroyed the directory, restored from the archive, compared bytes. IMAGE_EXTENSIONS moves to uploads.py and content.py imports it, so the editor and the board cannot drift apart about what counts as a picture. 46 new tests, 176 in total. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
32 lines
1.4 KiB
HTML
32 lines
1.4 KiB
HTML
{% extends "base.html" %}
|
|
{% block title %}{{ 'Editar tema' if thread else 'Escribir' }}{% endblock %}
|
|
|
|
{% block main %}
|
|
<form class="card" method="post" enctype="multipart/form-data"
|
|
action="{{ url_for('board.edit_thread', thread_id=thread.id) if thread else url_for('board.new_thread') }}">
|
|
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
|
<h1>{{ 'Editar tema' if thread else 'Nuevo tema' }}</h1>
|
|
|
|
<label for="title">Título</label>
|
|
<input id="title" name="title" maxlength="140" required
|
|
value="{{ thread.title if thread else '' }}">
|
|
|
|
<label for="body">Mensaje</label>
|
|
<textarea id="body" name="body" rows="14" required
|
|
placeholder="Se puede usar Markdown: **negrita**, listas, enlaces.">{{ thread.body_md if thread else '' }}</textarea>
|
|
|
|
{# Only when writing, not when editing: the edit route does not read files,
|
|
and an input that silently does nothing is worse than no input. Photos
|
|
already attached survive an edit — they are separate rows. #}
|
|
{% if not thread %}
|
|
<label for="pictures">Imágenes <span class="muted small">(opcional)</span></label>
|
|
<input id="pictures" name="pictures" type="file" multiple accept="image/*">
|
|
{% endif %}
|
|
|
|
<div class="actions">
|
|
<button class="btn" type="submit">{{ 'Guardar' if thread else 'Publicar' }}</button>
|
|
<a class="linkish" href="{{ url_for('board.thread', thread_id=thread.id) if thread else url_for('board.threads') }}">Cancelar</a>
|
|
</div>
|
|
</form>
|
|
{% endblock %}
|