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
47 lines
1.7 KiB
Python
47 lines
1.7 KiB
Python
"""The name a post gets when nobody gives it one.
|
|
|
|
A title is not required anywhere a member writes. Most things people post have
|
|
one, and the ones that do not are usually the best writing on a wall: somebody
|
|
answering a question, somebody saying a thing happened. Demanding a headline
|
|
first is how a form stops a person mid-sentence.
|
|
|
|
So an untitled post is called «Sin Título», and the second one is «Sin Título
|
|
2». The number is there to keep them apart — in a list of twenty threads, three
|
|
rows reading the same four characters are three rows nobody can tell apart or
|
|
link to with any confidence.
|
|
|
|
Numbers are never reused. A deleted thread keeps its title in the database, and
|
|
counting it is what stops a new post inheriting the name of one somebody
|
|
remembers reading.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import re
|
|
from typing import Iterable
|
|
|
|
UNTITLED = "Sin Título"
|
|
|
|
# «Sin Título», «Sin Título 2». Anchored, so a post somebody deliberately
|
|
# called «Sin Título ni ganas» is not read as a number and does not take one.
|
|
NUMBERED = re.compile(r"^Sin Título(?:\s+(\d+))?$")
|
|
|
|
|
|
def next_untitled(taken: Iterable[str]) -> str:
|
|
"""The first «Sin Título» name not in `taken`.
|
|
|
|
`taken` is every title already in that place — the wall's threads, the
|
|
queue's proposals — including deleted ones, because a number that comes
|
|
back is a post that looks like a different post.
|
|
"""
|
|
used = set()
|
|
for title in taken:
|
|
match = NUMBERED.match((title or "").strip())
|
|
if match:
|
|
used.add(int(match.group(1) or 1))
|
|
|
|
number = 1
|
|
while number in used:
|
|
number += 1
|
|
return UNTITLED if number == 1 else f"{UNTITLED} {number}"
|