Four changes to the forms people write in. **The title is optional**, and says nothing about it: a field labelled «(opcional)» is a field asking to be filled in. An untitled post is «Sin Título» and the next is «Sin Título 2», so a list of them can still be told apart and linked to. apps/board/titles.py holds the rule. The numbering is done per place, against what is already there. The wall and the queue count every title in the table, deleted rows included — a number that comes back is a thread that looks like one somebody remembers reading. A public post counts the *filenames* in its folder instead, because that is what collides in a repository: two untitled posts on one day would both be `<fecha>-sin-titulo.es.md`, and the second would have failed as "somebody else saved this file while you were editing it", which is a message about a conflict that never happened. Clearing the title on an edit excludes the file being edited from its own check, so saving three times does not rename it three times. **The event box folds away.** Most posts are not events, and three date pickers between the title and the text are three fields most people scroll past. A <details>, like the account menu, so no script is involved; it opens by itself when the post already has a date. **The AI disclosure is a switch** rather than a checkbox — what it says is a statement about the text, not a detail of the form, and it should look like something that is on or off. Drawn entirely from the checkbox's own :checked state: under a policy with no 'unsafe-inline' a control that needs a script is a control that silently does nothing. The input stays in the tab order and keeps its label, so it works from a keyboard, and it is anchored inside its own label rather than left adrift over the page. **Cancelar is a button**, and Vista previa beside it is shaped the same: leaving is the other half of a decision and should be the same size as the half next to it. Quiet rather than filled, so the eye still knows which one publishes. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn
49 lines
2.5 KiB
HTML
49 lines
2.5 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"
|
|
value="{{ thread.title if thread else '' }}">
|
|
|
|
<label for="body">Mensaje</label>
|
|
<textarea id="body" data-markdown data-rich="full" name="body" rows="14" required
|
|
placeholder="Se puede usar Markdown: **negrita**, listas, enlaces.">{{ thread.body_md if thread else '' }}</textarea>
|
|
{#- The stored markdown, rendered by the server for the editor to adopt.
|
|
There is no markdown parser in the browser: this is how the box can
|
|
show the formatting without a second opinion about what somebody's
|
|
text means. Ignored entirely when scripting is off. -#}
|
|
<template data-rich-html="body">{{ to_html(thread.body_md if thread else '') }}</template>
|
|
|
|
{# 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>
|
|
{#- Beside the button that publishes, because that is the moment it is
|
|
answered. One line rather than a fieldset: it has to be seen, not
|
|
to take up the form. -#}
|
|
<label class="toggle">
|
|
<input type="checkbox" name="ai_generated" {{ 'checked' if (thread.ai_generated if thread else False) }}>
|
|
{#- The switch itself is drawn by board.css from the checkbox's own
|
|
state. No script: a control that needs one is a control that
|
|
does nothing under this Content-Security-Policy. -#}
|
|
<span class="toggle__track" aria-hidden="true"></span>
|
|
<span class="toggle__text">Contenido generado con IA</span>
|
|
</label>
|
|
|
|
<a class="btn btn--quiet" href="{{ url_for('board.thread', thread_id=thread.id) if thread else url_for('board.threads') }}">Cancelar</a>
|
|
</div>
|
|
</form>
|
|
{% endblock %}
|