From 864d36bfb07dca2ef37c105f98810f94e5a00f19 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 20:41:13 +0000 Subject: [PATCH 1/2] vielac.at leads here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The second name redirects to vienalatina.com, both spellings in one block beside the www one it copies. 301 rather than 302, so a search engine folds the two names into one site instead of indexing them as duplicates, and {uri} so a link shared to vielac.at/page/agenda/ lands on the agenda rather than on the home page. The runbook gains §1.1: the two A records go in that domain's zone editor — not in Konsole H's nameserver fields, which hand the whole zone to another provider and turn off the editor you want — and they go in *before* Caddy is reloaded, because that is when Let's Encrypt is asked for the certificate. With `caddy validate` before every reload, which is the one command standing between a typo in that file and vienalatina.com going down with it. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn --- docs/server-setup.md | 45 +++++++++++++++++++++++++++++++++++++++++++ infra/caddy/Caddyfile | 16 +++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/docs/server-setup.md b/docs/server-setup.md index 2f1cbf4..896caf2 100644 --- a/docs/server-setup.md +++ b/docs/server-setup.md @@ -39,6 +39,51 @@ Check propagation (repeat until it prints the server IP): local$ dig +short git.vienalatina.com ``` +### 1.1 A second domain that leads here + +`vielac.at` is the second name, and it redirects: everything that arrives goes +to the same path on vienalatina.com. Two A records in that domain's **zone +editor**, both at the server: + +| Name | Type | Value | TTL | +|---|---|---|---| +| `@` | A | `` | 300 | +| `www` | A | `` | 300 | + +**Not the nameserver page.** On Hetzner's Konsole H those fields hand the whole +zone to another provider's DNS, which is a different thing entirely and turns +off the zone editor you want. *Standard Nameserver eintragen*, save, then edit +the zone. + +Then the block in `infra/caddy/Caddyfile`, which carries both spellings and +answers with a **301** — a permanent redirect is what folds the two names into +one site for a search engine rather than two copies of it, and `{uri}` keeps +the path so a shared link still lands where it was pointing. + +**Order matters, and it is the same order as the cutover above**: the A records +go in first, because Caddy asks Let's Encrypt for the certificate the first time +the name resolves to this server. A reload before DNS has propagated is not +harmful — nothing reaches the block — but it does not get a certificate either, +so reload again afterwards. + +```sh +sudo cp ~/vienalatina/infra/caddy/Caddyfile /etc/caddy/Caddyfile +sudo caddy validate --config /etc/caddy/Caddyfile +sudo systemctl reload caddy +``` + +`validate` before every `reload`, without exception: it is the one command +between a typo in that file and vienalatina.com going down with it. + +```sh +curl -sI https://vielac.at/ | head -3 # 301 → vienalatina.com +curl -sI https://www.vielac.at/page/agenda/ | grep -i location # the path survives +curl -sI https://vienalatina.com/ | head -1 # 200, unchanged +``` + +The third is the one that matters. A Caddyfile edit that breaks the site it was +meant to leave alone is the failure this ordering exists to prevent. + ## 2. First login + basic hardening ```sh diff --git a/infra/caddy/Caddyfile b/infra/caddy/Caddyfile index 5b87d62..62de8b9 100644 --- a/infra/caddy/Caddyfile +++ b/infra/caddy/Caddyfile @@ -21,6 +21,22 @@ www.vienalatina.com { redir https://vienalatina.com{uri} 301 } +# The second name, which leads here rather than somewhere else. +# +# Both spellings in one block, and 301 rather than 302: a permanent redirect is +# what makes a search engine fold the two names into one site instead of +# indexing them as duplicates of each other, and what makes a browser stop +# asking after the first visit. `{uri}` carries the path, so a link somebody +# shared to vielac.at/page/agenda/ lands on the agenda rather than on the home +# page. +# +# Caddy asks Let's Encrypt for this certificate the first time the name +# resolves to this server, so the A records go in before this file is reloaded. +# Until they do, the block is harmless: nothing reaches it. +vielac.at, www.vielac.at { + redir https://vienalatina.com{uri} 301 +} + vienalatina.com { root * /var/www/vienalatina.com encode zstd gzip From 3e610ac5d2903d14ebdc7d4ee7b349660d6458d8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 6 Oct 2026 20:58:33 +0000 Subject: [PATCH 2/2] A title nobody has to write, a fold, a switch and a button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 `-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
, 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 Claude-Session: https://claude.ai/code/session_01NizVpJ2dwzCbjCrTLCjeHn --- apps/board/board.py | 12 ++- apps/board/content.py | 41 ++++++- apps/board/static/board.css | 125 +++++++++++++++++++--- apps/board/submissions.py | 9 +- apps/board/templates/comment_form.html | 2 +- apps/board/templates/content_form.html | 26 +++-- apps/board/templates/event_form.html | 2 +- apps/board/templates/member_new.html | 2 +- apps/board/templates/recover.html | 2 +- apps/board/templates/submission_form.html | 22 ++-- apps/board/templates/thread_form.html | 12 ++- apps/board/tests/test_board.py | 59 ++++++++++ apps/board/tests/test_content.py | 60 +++++++++++ apps/board/tests/test_submissions.py | 16 +++ apps/board/titles.py | 46 ++++++++ docs/server-setup.md | 27 ++++- 16 files changed, 418 insertions(+), 45 deletions(-) create mode 100644 apps/board/titles.py diff --git a/apps/board/board.py b/apps/board/board.py index 5ea8dc9..469a689 100644 --- a/apps/board/board.py +++ b/apps/board/board.py @@ -20,6 +20,7 @@ from flask import (Blueprint, abort, current_app, flash, g, redirect, from . import auth, uploads from .db import get_db +from . import titles from .render import excerpt, to_html from .security import admin_required, is_at_least, login_required @@ -69,9 +70,16 @@ def cooldown_remaining() -> int: def _clean(title: str, body: str) -> tuple[str, str] | None: title = title.strip()[:TITLE_MAX] body = body.strip()[:BODY_MAX] - if not title or not body: - flash("El título y el mensaje no pueden estar vacíos.", "error") + if not body: + flash("El mensaje no puede estar vacío.", "error") return None + if not title: + # Counting the deleted ones too: a number that comes back is a thread + # that looks like one somebody remembers reading. See titles.py. + rows = get_db().execute( + "SELECT title FROM threads WHERE title LIKE ?", + (titles.UNTITLED + "%",)).fetchall() + title = titles.next_untitled(row["title"] for row in rows) return title, body diff --git a/apps/board/content.py b/apps/board/content.py index 160401d..5abb5fd 100644 --- a/apps/board/content.py +++ b/apps/board/content.py @@ -30,7 +30,7 @@ import yaml from flask import (Blueprint, abort, current_app, flash, g, redirect, render_template, request, url_for) -from . import gitea +from . import gitea, titles from .db import get_db from .render import to_html from .security import is_at_least, moderator_required @@ -99,6 +99,34 @@ def filename_for(collection: str, title: str, when: date_type | None) -> str: return f"{slug}.es.md" +def untitled_for(collection: str, when, skip: str = "") -> str: + """A name for a post nobody titled, free in the folder it is going into. + + Numbered against the *filenames* rather than against the titles, because in + a repository the filename is what collides: two «Sin Título» posts on one + day would both be `-sin-titulo.es.md`, and the second would come back + as "somebody else saved this file while you were editing it" — a message + about a conflict that never happened. + + A git server that cannot be reached gives the plain name. Publishing fails + in that case anyway, and the failure should say what it is rather than be a + naming error wearing its coat. + """ + try: + names = {entry["name"] for entry in gitea.list_directory( + COLLECTIONS[collection]["folder"], gitea.content_token())} + except gitea.GiteaError: + return titles.UNTITLED + names.discard(skip) # editing a post does not collide with itself + + number = 1 + while True: + title = titles.UNTITLED if number == 1 else f"{titles.UNTITLED} {number}" + if filename_for(collection, title, when) not in names: + return title + number += 1 + + def split_frontmatter(text: str) -> tuple[dict, str]: match = re.match(r"\A---\n(.*?)\n---\n?(.*)\Z", text, re.DOTALL) if not match: @@ -319,8 +347,8 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]: errors.append("La imagen no es válida.") image = "" - if not title: - errors.append("El título no puede estar vacío.") + # A title is not required. An untitled post is named when it is saved, by + # untitled_for() — see titles.py for why the form does not insist. if not body: errors.append("El cuerpo no puede estar vacío.") @@ -487,6 +515,8 @@ def publish(collection: str, fields: dict, body: str, author) -> str: approved submission keeps the member's name in git history. """ fields = dict(fields, **byline(author)) + if not fields.get("title"): + fields["title"] = untitled_for(collection, fields["date"]) name = filename_for(collection, fields["title"], fields["date"]) path = f"{COLLECTIONS[collection]['folder']}/{name}" document = build_document(frontmatter_for(collection, fields), body) @@ -601,6 +631,11 @@ def edit(collection: str, name: str): fields["image"] = picture # Deliberately not through publish(): that stamps the byline of whoever # is publishing, and an edit keeps the author the file already names. + if not fields.get("title"): + # `skip` is this post's own file: a title cleared on an edit must + # not count the thing being edited as the collision it has to + # avoid, or every save would walk the number up by one. + fields["title"] = untitled_for(collection, fields["date"], skip=name) document = build_document(frontmatter_for(collection, fields), body) gitea.write_file(path, document.encode("utf-8"), f"content: actualizar «{fields['title']}»", diff --git a/apps/board/static/board.css b/apps/board/static/board.css index 4bcfdd3..f7fe14b 100644 --- a/apps/board/static/board.css +++ b/apps/board/static/board.css @@ -249,6 +249,23 @@ textarea { resize: vertical; line-height: 1.55; } } .btn:hover { background: var(--brand-dark); } +/* The second button in a row of them — Cancelar, mostly. It was a link, which + made leaving look like a footnote next to a filled pill; it is the other + half of a decision and should be the same size and shape as the half beside + it. Quiet rather than loud: same geometry, no fill, so the eye still knows + which one publishes. */ +.btn--quiet { + background: var(--surface); + color: var(--muted); + border: 1px solid var(--border); + padding: calc(0.6rem - 1px) calc(1.4rem - 1px); /* the border, given back */ +} +.btn--quiet:hover { + background: var(--surface-soft); + color: var(--text); + border-color: var(--brand); +} + /* A button sitting straight in a card, rather than in an .actions row, still * needs air above it. Five of them did not have any — the one under the "escribir * a" picker was flush against the select — because the space every other form @@ -382,6 +399,33 @@ textarea { resize: vertical; line-height: 1.55; } .fieldset legend { padding: 0 0.4rem; font-weight: 600; font-size: 0.9rem; } .fieldset .check { margin: 0.35rem 0; } +/* The same box, folded shut. Most posts are not events, and three date + pickers between the title and the text are three fields most people scroll + past — the form should ask what it needs and keep the rest within reach + rather than in the way. A
, like the account menu: no script, and + it opens by itself when the post already has a date. */ +.fold { + border: 1px solid var(--border-light); + border-radius: var(--radius-md); + padding: 0 1rem; + margin: 1rem 0 0; + background: var(--surface); +} +.fold > summary { + cursor: pointer; + padding: 0.8rem 0; + font-weight: 600; + font-size: 0.9rem; + color: var(--muted); +} +.fold > summary:hover { color: var(--brand-dark); } +.fold[open] > summary { + color: var(--text); + border-bottom: 1px solid var(--border-light); + margin-bottom: 0.75rem; +} +.fold > :last-child { margin-bottom: 1rem; } + input[type="file"] { width: 100%; padding: 0.5rem 0; @@ -1021,8 +1065,10 @@ input[type="file"] { /* The disclosure switch: 16px of words and a 13px box before this. The checkbox itself grows too — a label you can hit around a box you cannot is a control that looks broken when it misses. */ - .switch { padding: 0.7rem 0; } - .switch input { width: 20px; height: 20px; } + /* The switch and its words, which were 16px of line box before this. The + track is already 22px tall and does not need to grow — the label around + it does, so the whole thing is one target. */ + .toggle { padding: 0.65rem 0; } .cal__add { display: inline-flex; @@ -1045,16 +1091,67 @@ input[type="file"] { border: 1px solid var(--border-light); } -/* The switch in the form's action row. A checkbox and its words on one line, - beside the button that publishes — visible at the moment of publishing, - which is when it is answered, and costing one line rather than a fieldset. */ -.switch { - display: inline-flex; - align-items: center; - gap: 0.45rem; - font-size: 0.9rem; - color: var(--muted); - cursor: pointer; +/* A real switch rather than a checkbox, because what it says is not a detail + * of the form — it is a statement about the text, made at the moment of + * publishing, and it should look like something that is on or off. + * + * Drawn entirely from the checkbox's own `:checked` state. There is no script + * anywhere near it: under a policy with no 'unsafe-inline' a control that + * needs one is a control that silently does nothing. The input is visually + * hidden but not `display: none` — it keeps its place in the tab order and is + * still announced with its label, so the switch works from a keyboard. + */ +.toggle { + display: inline-flex; + align-items: center; + gap: 0.55rem; + font-size: 0.9rem; + color: var(--muted); + cursor: pointer; + /* So the hidden input below is positioned against this label and not + against whatever happens to be the nearest positioned ancestor — a 1px + invisible control adrift somewhere else on the page is a thing that gets + clicked by accident exactly once and is never explained. */ + position: relative; +} +.toggle input { + position: absolute; + top: 0; + left: 0; + width: 1px; + height: 1px; + opacity: 0; +} +.toggle__track { + position: relative; + flex: none; + width: 40px; + height: 22px; + border-radius: 999px; + background: var(--border); + transition: background 140ms ease; +} +.toggle__track::after { + content: ""; + position: absolute; + top: 3px; + left: 3px; + width: 16px; + height: 16px; + border-radius: 50%; + background: #fff; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); + transition: transform 140ms ease; +} +.toggle input:checked + .toggle__track { background: var(--brand); } +.toggle input:checked + .toggle__track::after { transform: translateX(18px); } +/* Focus has to land somewhere visible: the thing with the outline is hidden. */ +.toggle input:focus-visible + .toggle__track { + outline: 2px solid var(--brand-dark); + outline-offset: 2px; +} +.toggle input:checked ~ .toggle__text { color: var(--brand-dark); font-weight: 600; } + +@media (prefers-reduced-motion: reduce) { + .toggle__track, .toggle__track::after { transition: none; } } -.switch input { margin: 0; } -.switch:has(input:checked) { color: var(--brand-dark); font-weight: 600; } diff --git a/apps/board/submissions.py b/apps/board/submissions.py index ab62781..8ba1941 100644 --- a/apps/board/submissions.py +++ b/apps/board/submissions.py @@ -30,7 +30,7 @@ from datetime import date as date_type from flask import (Blueprint, abort, current_app, flash, g, redirect, render_template, request, send_from_directory, url_for) -from . import activity, content, gitea, uploads +from . import activity, content, gitea, titles, uploads from .db import get_db from .render import excerpt, to_html from .security import is_at_least, login_required, moderator_required @@ -107,7 +107,12 @@ def _read_proposal() -> tuple[dict, list[str]]: **content.read_event_fields(request.form, errors), } if not fields["title"]: - errors.append("El título no puede estar vacío.") + # Not an error: a proposal without a headline is named when it is sent, + # the same way a thread is. See titles.py. + rows = get_db().execute( + "SELECT title FROM submissions WHERE title LIKE ?", + (titles.UNTITLED + "%",)).fetchall() + fields["title"] = titles.next_untitled(row["title"] for row in rows) if not fields["body"]: errors.append("El texto no puede estar vacío.") return fields, errors diff --git a/apps/board/templates/comment_form.html b/apps/board/templates/comment_form.html index d5c9542..2fcc736 100644 --- a/apps/board/templates/comment_form.html +++ b/apps/board/templates/comment_form.html @@ -16,7 +16,7 @@
- Cancelar + Cancelar
{% endblock %} diff --git a/apps/board/templates/content_form.html b/apps/board/templates/content_form.html index 2dceabb..10f4e3a 100644 --- a/apps/board/templates/content_form.html +++ b/apps/board/templates/content_form.html @@ -30,7 +30,7 @@

{{ ('Editar ' ~ meta.singular|lower) if item else meta.new_label }}

- + {% if meta.dated %} @@ -69,8 +69,12 @@ {# An event's own date, which is not the day the post goes up. The date is also what makes this post an event: there is nothing to tick first, so there is no way to say "this is an event" and then not say when. #} -
- Si es un evento + {#- A fold rather than a fieldset: most posts are not events, and six + inches of date pickers between the title and the text is six inches + most people scroll past. Open by itself when the post already has a + date, so editing an event does not hide the thing being edited. -#} +
+ Si es un evento (fecha, hora, lugar)

Pon la fecha y será un evento: aparecerá en la agenda del sitio, con el día y el lugar destacados, y se podrá añadir al calendario del móvil. @@ -88,7 +92,7 @@

Dónde es: el sitio, la calle, el barrio.

-
+
@@ -141,16 +145,22 @@ {#- 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. -#} -