Compare commits
No commits in common. "6bfdf6a89dfe485b3b02da24eb08b67ecee3d1c3" and "0ffb885e30d51b034eda257dc23f01145ca0d5c7" have entirely different histories.
6bfdf6a89d
...
0ffb885e30
@ -22,8 +22,7 @@ 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,
|
||||
moderator_required)
|
||||
from .security import admin_required, is_at_least, login_required
|
||||
|
||||
bp = Blueprint("board", __name__)
|
||||
|
||||
@ -36,13 +35,6 @@ def is_admin() -> bool:
|
||||
return is_at_least(g.member["role"], "admin")
|
||||
|
||||
|
||||
def may_pin() -> bool:
|
||||
"""Deciding what the association reads first is curation, which is a
|
||||
moderator's whole job. Locking a thread is not, and asks for an admin —
|
||||
see `set_state`."""
|
||||
return is_at_least(g.member["role"], "moderator")
|
||||
|
||||
|
||||
def may_delete(row) -> bool:
|
||||
return is_admin() or row["author_id"] == g.member["id"]
|
||||
|
||||
@ -155,13 +147,7 @@ def threads():
|
||||
WHERE c.thread_id = t.id AND c.deleted_at IS NULL) AS replies
|
||||
FROM threads t JOIN members m ON m.id = t.author_id
|
||||
WHERE t.deleted_at IS NULL
|
||||
-- `id` last, and it is not decoration. `created_at` is
|
||||
-- `datetime('now')`, which has one-second resolution, so two
|
||||
-- threads written in the same second compared equal and SQLite was
|
||||
-- free to return them in either order — and did, differently on
|
||||
-- different pages of the same list. Every ordering in this app now
|
||||
-- ends in the primary key for that reason.
|
||||
ORDER BY t.pinned DESC, t.pinned_at DESC, t.created_at DESC, t.id DESC
|
||||
ORDER BY t.pinned DESC, t.created_at DESC
|
||||
LIMIT ? OFFSET ?""",
|
||||
(PER_PAGE + 1, (page - 1) * PER_PAGE),
|
||||
).fetchall()
|
||||
@ -171,7 +157,6 @@ def threads():
|
||||
shown = rows[:PER_PAGE]
|
||||
return render_template("threads.html", threads=shown, page=page,
|
||||
has_next=has_next, excerpt=excerpt,
|
||||
may_pin=may_pin(),
|
||||
reactions=reactions_for_threads([t["id"] for t in shown]))
|
||||
|
||||
|
||||
@ -189,13 +174,13 @@ def thread(thread_id: int):
|
||||
m.gitea_login AS author_login, m.profile_published AS author_published
|
||||
FROM comments c JOIN members m ON m.id = c.author_id
|
||||
WHERE c.thread_id = ? AND c.deleted_at IS NULL
|
||||
ORDER BY c.created_at, c.id""",
|
||||
ORDER BY c.created_at""",
|
||||
(thread_id,),
|
||||
).fetchall()
|
||||
return render_template("thread.html", thread=row, author=author,
|
||||
comments=comments, body_html=to_html(row["body_md"]),
|
||||
to_html=to_html, may_edit=may_edit, may_delete=may_delete,
|
||||
is_admin=is_admin(), may_pin=may_pin(),
|
||||
is_admin=is_admin(),
|
||||
thread_images=uploads.for_threads([thread_id]).get(thread_id, []),
|
||||
comment_images=uploads.for_comments([c["id"] for c in comments]),
|
||||
reactions=reactions_for_threads([thread_id]),
|
||||
@ -379,36 +364,14 @@ def react():
|
||||
|
||||
|
||||
@bp.route("/tema/<int:thread_id>/estado", methods=["POST"])
|
||||
@moderator_required
|
||||
@admin_required
|
||||
def set_state(thread_id: int):
|
||||
"""Pinning and locking, which are not the same authority.
|
||||
|
||||
A moderator decides what the association reads first — that is curation,
|
||||
and it is the whole of their job. Closing a conversation is not: it stops
|
||||
named people saying anything more to each other, which is power over
|
||||
people, and this codebase keeps those two apart everywhere else (see
|
||||
`security.py`'s ladder). So the decorator admits a moderator and locking
|
||||
asks again.
|
||||
"""
|
||||
_thread_or_404(thread_id)
|
||||
field = request.form.get("field")
|
||||
if field not in ("pinned", "locked"):
|
||||
abort(400, "Campo desconocido.")
|
||||
if field == "locked" and not is_admin():
|
||||
abort(403)
|
||||
value = 1 if request.form.get("value") == "1" else 0
|
||||
# `field` is checked against a fixed pair above, so it never carries
|
||||
# anything a member typed into the statement.
|
||||
get_db().execute(f"UPDATE threads SET {field} = ? WHERE id = ?", (value, thread_id))
|
||||
if field == "pinned":
|
||||
# When, not only whether: several threads can be pinned and the newest
|
||||
# pin goes on top, so the moment is the order. Cleared on unpinning so
|
||||
# that pinning again puts it where a new pin belongs rather than where
|
||||
# the old one was.
|
||||
get_db().execute(
|
||||
"UPDATE threads SET pinned_at = CASE WHEN ? THEN datetime('now') END"
|
||||
" WHERE id = ?", (value, thread_id))
|
||||
# Back where it was pressed — the wall as well as the thread page now —
|
||||
# through the same open-redirect check the login form's `next` gets.
|
||||
return redirect(auth.safe_next(request.form.get("back") or
|
||||
url_for("board.thread", thread_id=thread_id)))
|
||||
return redirect(url_for("board.thread", thread_id=thread_id))
|
||||
|
||||
@ -25,7 +25,6 @@ import secrets
|
||||
import unicodedata
|
||||
from datetime import date as date_type
|
||||
from datetime import datetime
|
||||
from datetime import time as time_type
|
||||
|
||||
import yaml
|
||||
from flask import (Blueprint, abort, current_app, flash, g, redirect,
|
||||
@ -143,61 +142,10 @@ def build_document(fields: dict, body: str) -> str:
|
||||
return f"---\n{front}---\n\n{body.strip()}\n"
|
||||
|
||||
|
||||
def as_datetime(value):
|
||||
"""Whatever a `date:` turned out to be — a date, a datetime, a string —
|
||||
as a datetime, or None if it is none of those."""
|
||||
if isinstance(value, datetime):
|
||||
return value
|
||||
if isinstance(value, date_type):
|
||||
return datetime.combine(value, time_type())
|
||||
try:
|
||||
return datetime.fromisoformat(str(value).strip())
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def date_input(value) -> str:
|
||||
"""The `YYYY-MM-DD` an `<input type="date">` accepts. A datetime handed to
|
||||
one straight is not a value it understands, and the browser answers by
|
||||
showing an empty field — silently, which is the failure this exists to
|
||||
stop."""
|
||||
moment = as_datetime(value)
|
||||
return f"{moment:%Y-%m-%d}" if moment else ""
|
||||
|
||||
|
||||
def stamp(when, original=None) -> datetime:
|
||||
"""The post's date, with the clock attached.
|
||||
|
||||
Hugo sorts the blog by this field and a bare `date: 2026-07-31` makes every
|
||||
post published that day byte-identical in it — so Hugo falls through to its
|
||||
next key, the title, and the day comes out alphabetised. Permanently: a
|
||||
rebuild does not change it, because nothing about the files changed. That
|
||||
is the whole of "the posts are not in the order they were written".
|
||||
|
||||
The day is still the one whoever is publishing chose, and the URL still
|
||||
carries only the day. The time is the tiebreak, which is why it is the
|
||||
clock at the moment of publication rather than anything cleverer.
|
||||
|
||||
`original` is what the file already said. An edit keeps it verbatim as long
|
||||
as the day has not moved — otherwise correcting a typo would carry a
|
||||
year-old post to the top of the home page.
|
||||
"""
|
||||
chosen = as_datetime(when) or datetime.now()
|
||||
before = as_datetime(original)
|
||||
if before and before.date() == chosen.date() and before.time() != time_type():
|
||||
return before
|
||||
now = datetime.now()
|
||||
return chosen.replace(hour=now.hour, minute=now.minute, second=now.second,
|
||||
microsecond=0)
|
||||
|
||||
|
||||
def frontmatter_for(collection: str, form: dict) -> dict:
|
||||
fields = {"title": form["title"]}
|
||||
if COLLECTIONS[collection]["dated"]:
|
||||
# Every path that writes a post comes through here — the editor, an
|
||||
# edit, and a moderator approving a proposal — so this is the one place
|
||||
# the clock has to be attached.
|
||||
fields["date"] = stamp(form["date"], form.get("date_stamped"))
|
||||
fields["date"] = form["date"]
|
||||
fields["lang"] = "es"
|
||||
fields["manual_translation"] = form["manual_translation"]
|
||||
if collection == "page":
|
||||
@ -244,15 +192,6 @@ def frontmatter_for(collection: str, form: dict) -> dict:
|
||||
# the mind of anybody reading the file.
|
||||
if form.get("ai_generated"):
|
||||
fields["ai_generated"] = True
|
||||
# The moment it was pinned, and only when it is. One key carrying both the
|
||||
# flag and the order: several posts can be pinned and the newest pin goes
|
||||
# first, so `{{ if .Params.pinned }}` still reads as a yes/no while
|
||||
# `sort … "Params.pinned" "desc"` puts them in the right order with nothing
|
||||
# else to keep in step. Written as a string rather than a timestamp scalar
|
||||
# so that a file saved twice does not alternate between the two shapes.
|
||||
if form.get("pinned"):
|
||||
fields["pinned"] = (str(form.get("pinned_at") or "")
|
||||
or datetime.now().isoformat(timespec="seconds"))
|
||||
return fields
|
||||
|
||||
|
||||
@ -268,14 +207,14 @@ def _cache_write(path: str, sha: str, fm: dict) -> None:
|
||||
get_db().execute(
|
||||
"""INSERT INTO content_cache (path, sha, title, date, generated, image,
|
||||
event_date, event_time, event_location,
|
||||
ai_generated, pinned)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ai_generated)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(path) DO UPDATE SET
|
||||
sha = excluded.sha, title = excluded.title, date = excluded.date,
|
||||
generated = excluded.generated, image = excluded.image,
|
||||
event_date = excluded.event_date, event_time = excluded.event_time,
|
||||
event_location = excluded.event_location,
|
||||
ai_generated = excluded.ai_generated, pinned = excluded.pinned,
|
||||
ai_generated = excluded.ai_generated,
|
||||
updated_at = datetime('now')""",
|
||||
(path, sha, str(fm.get("title", "")), str(fm.get("date", "")),
|
||||
1 if fm.get("translated_from") else 0,
|
||||
@ -289,11 +228,7 @@ def _cache_write(path: str, sha: str, fm: dict) -> None:
|
||||
# every page view to find out when they are.
|
||||
str(fm.get("event_date", "") or ""), str(fm.get("event_time", "") or ""),
|
||||
str(fm.get("event_location", "") or ""),
|
||||
1 if fm.get("ai_generated") else 0,
|
||||
# When it was pinned, or '' — the same copy of the frontmatter, so the
|
||||
# editor's own list can put the pinned ones first without re-reading
|
||||
# every file to find out which they are.
|
||||
str(fm.get("pinned", "") or "")),
|
||||
1 if fm.get("ai_generated") else 0),
|
||||
)
|
||||
|
||||
|
||||
@ -322,20 +257,12 @@ def listing(collection: str) -> list[dict]:
|
||||
"title": row["title"] or name,
|
||||
"date": row["date"],
|
||||
"ai_generated": bool(row["ai_generated"]),
|
||||
"pinned": row["pinned"],
|
||||
"event_date": row["event_date"] or "",
|
||||
"event_time": row["event_time"] or "",
|
||||
"event_location": row["event_location"] or "",
|
||||
})
|
||||
|
||||
# Newest first, by the whole of the date. That used to be a day and nothing
|
||||
# else, so everything published on one day tied and fell through to the
|
||||
# filename — which under `reverse` is descending-alphabetical slug order,
|
||||
# as likely to be chronological as not. The editor stamps the clock now
|
||||
# (`stamp`), and the filename is left as the last resort for the posts
|
||||
# written before it did.
|
||||
items.sort(key=lambda item: (item["pinned"], item["date"], item["name"]),
|
||||
reverse=True)
|
||||
items.sort(key=lambda item: (item["date"], item["name"]), reverse=True)
|
||||
return items
|
||||
|
||||
|
||||
@ -380,10 +307,6 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
||||
when = datetime.strptime(raw_date, "%Y-%m-%d").date()
|
||||
except ValueError:
|
||||
errors.append("La fecha debe tener el formato AAAA-MM-DD.")
|
||||
# What the file already said, carried through the form untouched so that
|
||||
# `stamp()` can keep the publication time when only the text changed. A
|
||||
# date field is a day and nothing else; this is the rest of it.
|
||||
stamped = request.form.get("date_stamped", "").strip()
|
||||
|
||||
# A page's place in the menu. `parent` is another page's basename — the one
|
||||
# translate.py uses to pair siblings, so a parent chosen once holds in all
|
||||
@ -431,7 +354,6 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
||||
|
||||
fields = {
|
||||
"title": title, "date": when,
|
||||
"date_stamped": stamped, "date_input": raw_date,
|
||||
"description": request.form.get("description", "").strip(),
|
||||
"image": image,
|
||||
"manual_translation": request.form.get("manual_translation") == "on",
|
||||
@ -439,11 +361,6 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
||||
# frontmatter rather than in a database, because the file in the
|
||||
# repository is the record of what was published.
|
||||
"ai_generated": request.form.get("ai_generated") == "on",
|
||||
# And when it was pinned, carried through untouched, so that editing a
|
||||
# pinned post does not count as pinning it again and move it above
|
||||
# everything pinned since.
|
||||
"pinned": request.form.get("pinned") == "on",
|
||||
"pinned_at": request.form.get("pinned_at", "").strip(),
|
||||
"author": author, "author_url": author_url,
|
||||
"parent": parent, "weight": weight,
|
||||
"faq": faq, "image_alt": image_alt,
|
||||
@ -671,15 +588,9 @@ def edit(collection: str, name: str):
|
||||
"error")
|
||||
return redirect(url_for("content.index", collection=collection))
|
||||
|
||||
published = as_datetime(fm.get("date"))
|
||||
fields = {
|
||||
"title": fm.get("title", ""),
|
||||
"date": fm.get("date"),
|
||||
# The day for the date field, and the whole of it for the hidden
|
||||
# one, so an edit that does not move the day keeps the publication
|
||||
# time the post already had.
|
||||
"date_input": date_input(fm.get("date")),
|
||||
"date_stamped": published.isoformat() if published else "",
|
||||
"description": fm.get("description", ""),
|
||||
"image": fm.get("image", ""),
|
||||
"manual_translation": bool(fm.get("manual_translation")),
|
||||
@ -688,8 +599,6 @@ def edit(collection: str, name: str):
|
||||
# correction quietly removes — which is the whole failure the
|
||||
# byline below was given its comment for.
|
||||
"ai_generated": bool(fm.get("ai_generated")),
|
||||
"pinned": bool(fm.get("pinned")),
|
||||
"pinned_at": str(fm.get("pinned", "") or ""),
|
||||
# Carried through the form untouched. Correcting a typo in somebody
|
||||
# else's post must not re-sign it with the name of whoever is
|
||||
# fixing it — the same rule the board has about editing other
|
||||
@ -758,47 +667,6 @@ def delete(collection: str, name: str):
|
||||
return redirect(url_for("content.index", collection=collection))
|
||||
|
||||
|
||||
@bp.route("/contenido/<collection>/fijar/<name>", methods=["POST"])
|
||||
@moderator_required
|
||||
def pin(collection: str, name: str):
|
||||
"""Pin or unpin from the list, without opening the post.
|
||||
|
||||
The same write as saving the form — the file in the repository is the
|
||||
record and there is no second store that could disagree with it — but
|
||||
reached in one press from the screen where you can see what is pinned and
|
||||
what is not, because deciding what the site leads with means looking at
|
||||
the list rather than opening each post to find out.
|
||||
|
||||
The whole document is rebuilt rather than patched: the frontmatter is YAML,
|
||||
and a regular expression over somebody's prose is how a post loses its body.
|
||||
"""
|
||||
meta = _collection_or_404(collection)
|
||||
name = _name_or_404(name)
|
||||
path = f"{meta['folder']}/{name}"
|
||||
wanted = request.form.get("value") == "1"
|
||||
try:
|
||||
text, sha = gitea.read_file(path, gitea.content_token())
|
||||
fm, body = split_frontmatter(text)
|
||||
if fm.get("translated_from"):
|
||||
abort(400, "Ese archivo lo genera la traducción automática.")
|
||||
if bool(fm.get("pinned")) != wanted:
|
||||
if wanted:
|
||||
fm["pinned"] = datetime.now().isoformat(timespec="seconds")
|
||||
else:
|
||||
fm.pop("pinned", None)
|
||||
title = fm.get("title", name)
|
||||
gitea.write_file(
|
||||
path, build_document(fm, body).encode("utf-8"),
|
||||
f"content: {'fijar' if wanted else 'dejar de fijar'} «{title}»",
|
||||
gitea.content_token(), sha=sha, member=g.member)
|
||||
except gitea.GiteaError as exc:
|
||||
flash(str(exc), "error")
|
||||
return redirect(url_for("content.index", collection=collection))
|
||||
|
||||
flash("Fijado arriba." if wanted else "Ya no está fijado.", "ok")
|
||||
return redirect(url_for("content.index", collection=collection))
|
||||
|
||||
|
||||
@bp.route("/contenido/<collection>/vista-previa", methods=["POST"])
|
||||
@moderator_required
|
||||
def preview(collection: str):
|
||||
|
||||
@ -35,15 +35,13 @@ BODY_MAX = 100_000
|
||||
def index():
|
||||
db = get_db()
|
||||
threads = db.execute(
|
||||
"""SELECT t.id, t.title, t.body_md, t.created_at, t.pinned,
|
||||
m.display_name AS author,
|
||||
"""SELECT t.id, t.title, t.body_md, t.created_at, m.display_name AS author,
|
||||
m.gitea_login AS author_login, m.profile_published AS author_published,
|
||||
(SELECT COUNT(*) FROM comments c
|
||||
WHERE c.thread_id = t.id AND c.deleted_at IS NULL) AS replies
|
||||
FROM threads t JOIN members m ON m.id = t.author_id
|
||||
WHERE t.deleted_at IS NULL
|
||||
ORDER BY t.pinned DESC, t.pinned_at DESC, t.created_at DESC, t.id DESC
|
||||
LIMIT ?""",
|
||||
ORDER BY t.created_at DESC LIMIT ?""",
|
||||
(RECENT,),
|
||||
).fetchall()
|
||||
|
||||
@ -64,16 +62,13 @@ def index():
|
||||
JOIN conversation_members theirs
|
||||
ON theirs.conversation_id = c.id AND theirs.member_id != :me
|
||||
JOIN members other ON other.id = theirs.member_id
|
||||
ORDER BY last_at DESC NULLS LAST, c.id DESC LIMIT :limit""",
|
||||
ORDER BY last_at DESC NULLS LAST LIMIT :limit""",
|
||||
{"me": g.member["id"], "limit": RECENT},
|
||||
).fetchall()
|
||||
|
||||
mine = db.execute(
|
||||
"""SELECT id, title, state, note FROM submissions
|
||||
WHERE author_id = ?
|
||||
ORDER BY CASE state WHEN 'pending' THEN 0 ELSE 1 END,
|
||||
created_at DESC, id DESC
|
||||
LIMIT ?""",
|
||||
WHERE author_id = ? ORDER BY created_at DESC LIMIT ?""",
|
||||
(g.member["id"], RECENT),
|
||||
).fetchall()
|
||||
|
||||
@ -87,7 +82,7 @@ def index():
|
||||
m.profile_published AS author_published
|
||||
FROM submissions s JOIN members m ON m.id = s.author_id
|
||||
WHERE s.state = 'pending' AND s.author_id != ?
|
||||
ORDER BY s.created_at, s.id LIMIT ?""",
|
||||
ORDER BY s.created_at LIMIT ?""",
|
||||
(g.member["id"], RECENT),
|
||||
).fetchall()
|
||||
|
||||
|
||||
@ -146,7 +146,7 @@ def history(other_id: int) -> dict:
|
||||
a.profile_published AS author_published
|
||||
FROM messages m JOIN members a ON a.id = m.author_id
|
||||
WHERE m.conversation_id = ? AND m.deleted_at IS NULL
|
||||
ORDER BY m.created_at, m.id""",
|
||||
ORDER BY m.created_at""",
|
||||
(conversation_id,),
|
||||
).fetchall()
|
||||
db.execute(
|
||||
|
||||
@ -364,49 +364,6 @@ def _room_to_say_a_machine_wrote_it(db: sqlite3.Connection) -> None:
|
||||
"INTEGER NOT NULL DEFAULT 0")
|
||||
|
||||
|
||||
def _room_to_say_what_goes_first(db: sqlite3.Connection) -> None:
|
||||
"""When a post was pinned, which is also the order the pinned ones sit in.
|
||||
|
||||
Two plain ADD COLUMNs, and both hold a moment rather than a flag. That is
|
||||
the design: «several pins, newest pin first» needs an order, and a
|
||||
timestamp is both the order and the answer to "is this pinned", so there is
|
||||
no second column to keep in step with the first.
|
||||
|
||||
`threads.pinned` has been in the schema since the board shipped and stays —
|
||||
it is what the wall's index is on, and folding two columns into one would
|
||||
be a table rebuild for tidiness. `pinned_at` sits beside it and is NULL for
|
||||
anything pinned before this step, which sorts those below the ones pinned
|
||||
since. Nothing is pinned today, so that costs nothing and says the truth:
|
||||
we do not know when.
|
||||
|
||||
`content_cache.pinned` is only the copy of the post's own frontmatter that
|
||||
lets the editor's list sort without re-reading every file from the git
|
||||
server. The file in the repository is the record.
|
||||
"""
|
||||
for table, column, kind in (
|
||||
("threads", "pinned_at", "TEXT"),
|
||||
("content_cache", "pinned", "TEXT NOT NULL DEFAULT ''")):
|
||||
existing = _columns(db, table)
|
||||
if existing and column not in existing:
|
||||
db.execute(f"ALTER TABLE {table} ADD COLUMN {column} {kind}")
|
||||
|
||||
# And the wall's index, which now names the new column — `CREATE INDEX IF
|
||||
# NOT EXISTS` in schema.sql leaves an index that already exists exactly as
|
||||
# it is, so without this a server that has been running keeps the old
|
||||
# definition forever while a fresh install gets the new one. Nothing breaks
|
||||
# either way; the two just stop being the same system, which is how a
|
||||
# difference nobody can see becomes a bug nobody can reproduce.
|
||||
# Every column it names, because the oldest databases this runner has to
|
||||
# cross predate some of them and a step that assumes the table it is
|
||||
# looking at is the current one is a step that fails on the one server it
|
||||
# was written for.
|
||||
if {"pinned", "pinned_at", "created_at", "deleted_at"} <= _columns(db, "threads"):
|
||||
db.execute("DROP INDEX IF EXISTS threads_live")
|
||||
db.execute("CREATE INDEX threads_live"
|
||||
" ON threads(pinned DESC, pinned_at DESC, created_at DESC, id DESC)"
|
||||
" WHERE deleted_at IS NULL")
|
||||
|
||||
|
||||
# (number, description, function). The number is the value written to
|
||||
# user_version once the step succeeds.
|
||||
STEPS = [
|
||||
@ -420,7 +377,6 @@ STEPS = [
|
||||
(8, "room for the identity, a typeface and the media library",
|
||||
_room_for_identity_and_a_typeface),
|
||||
(9, "a post can say a machine wrote it", _room_to_say_a_machine_wrote_it),
|
||||
(10, "a post can be pinned to the top", _room_to_say_what_goes_first),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@ -53,10 +53,6 @@ CREATE TABLE IF NOT EXISTS threads (
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
edited_at TEXT,
|
||||
pinned INTEGER NOT NULL DEFAULT 0 CHECK (pinned IN (0, 1)),
|
||||
-- When it was pinned, which is also the order the pinned ones sit in: several
|
||||
-- can be pinned at once and the newest pin goes first. NULL for anything
|
||||
-- pinned before this column existed, which sorts those below.
|
||||
pinned_at TEXT,
|
||||
locked INTEGER NOT NULL DEFAULT 0 CHECK (locked IN (0, 1)),
|
||||
-- Said out loud where the post is read. The association's own words and a
|
||||
-- machine's are both welcome here; which is which is not the reader's job
|
||||
@ -68,8 +64,7 @@ CREATE TABLE IF NOT EXISTS threads (
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS threads_live
|
||||
ON threads(pinned DESC, pinned_at DESC, created_at DESC, id DESC)
|
||||
WHERE deleted_at IS NULL;
|
||||
ON threads(pinned DESC, created_at DESC) WHERE deleted_at IS NULL;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS comments (
|
||||
id INTEGER PRIMARY KEY,
|
||||
@ -215,10 +210,6 @@ CREATE TABLE IF NOT EXISTS content_cache (
|
||||
-- it without re-reading every file from the git server. The file is the
|
||||
-- record; this is the cache.
|
||||
ai_generated INTEGER NOT NULL DEFAULT 0 CHECK (ai_generated IN (0, 1)),
|
||||
-- The same copy of the frontmatter, for the pin: the moment it was pinned,
|
||||
-- or '' when it is not. A moment rather than a flag because several posts
|
||||
-- can be pinned and the newest pin goes first, so the value is the order.
|
||||
pinned TEXT NOT NULL DEFAULT '',
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
|
||||
|
||||
@ -167,16 +167,6 @@ button, input, select, textarea { font: inherit; }
|
||||
|
||||
/* --- prose ----------------------------------------------------------- */
|
||||
|
||||
/* A pasted URL is one word as far as the browser is concerned, and
|
||||
`profiles.clean_links` lets that word be five hundred characters long. So
|
||||
everywhere a member's own text is shown, a word wider than its box breaks
|
||||
instead of leaving it.
|
||||
`.rich` — the box the text is typed into — has had this since the editor
|
||||
shipped. The places that *display* what `.rich` wrote did not, which is why
|
||||
a bio looked right while being written and escaped the card once saved. The
|
||||
guard in test_templates.py holds the two lists together. */
|
||||
.prose, .person-head__links, .panel__row { overflow-wrap: anywhere; }
|
||||
|
||||
.prose { line-height: 1.65; }
|
||||
.prose :first-child { margin-top: 0; }
|
||||
.prose :last-child { margin-bottom: 0; }
|
||||
@ -780,96 +770,45 @@ input[type="file"] {
|
||||
|
||||
/* --- the private calendar ---------------------------------------------- */
|
||||
|
||||
/* A month, at every width.
|
||||
*
|
||||
* This was a <table> and it is now a list on a grid, which is not a style
|
||||
* preference. A table brings `tbody`, `tr` and `td` with it, so every phone
|
||||
* rule had to name an element to undo them — and `.cal td` at specificity
|
||||
* (0,1,1) outranks `.cal__pad` at (0,1,0). That is precisely what shipped: the
|
||||
* padding cells stayed as 92px empty boxes while every real day hid, and a
|
||||
* month with nothing in it drew nothing at all. A grid has no scaffolding to
|
||||
* undo, so the class that names a cell is the only rule that can decide
|
||||
* anything about it. The public agenda has had this shape since it was written
|
||||
* and has never had the bug. */
|
||||
|
||||
.cal-bar {
|
||||
display: flex;
|
||||
/* 320px: it reflows rather than pushing the next-month control off the
|
||||
right edge, which is how a month became impossible to leave. */
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 0.75rem;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-bottom: 0.35rem;
|
||||
}
|
||||
.cal-bar__label { min-width: 10rem; text-align: center; font-size: 1.05rem; }
|
||||
.cal-bar__move {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 44px;
|
||||
height: 44px;
|
||||
border: 1px solid var(--border-light);
|
||||
border-radius: 50%;
|
||||
background: var(--surface);
|
||||
color: var(--brand);
|
||||
text-decoration: none;
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
.cal-bar__move:hover { border-color: var(--brand); }
|
||||
.cal-bar__today { text-align: center; margin: 0 0 1rem; }
|
||||
|
||||
.cal__head, .cal__grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(7, 1fr);
|
||||
gap: 4px;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
.cal {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.cal__head {
|
||||
margin-bottom: 4px;
|
||||
.cal th {
|
||||
padding: 0.4rem;
|
||||
font-size: 0.72rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--muted);
|
||||
text-align: left;
|
||||
}
|
||||
.cal__grid { margin-bottom: 1rem; }
|
||||
.cal__day, .cal__pad {
|
||||
/* The day's link is laid over the whole cell on a phone, which is what
|
||||
makes the cell the tap target rather than six pixels of dot. */
|
||||
position: relative;
|
||||
min-height: 92px;
|
||||
vertical-align: top;
|
||||
height: 92px;
|
||||
padding: 0.35rem;
|
||||
border: 1px solid var(--border-light);
|
||||
border-radius: var(--radius-sm);
|
||||
background: var(--surface);
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
/* The leading and trailing cells are what puts the 1st under its own weekday,
|
||||
so they keep their space and lose only their ink. */
|
||||
.cal__pad { background: transparent; border-color: transparent; }
|
||||
.cal__day--today { border-color: var(--brand); background: var(--brand-softer); }
|
||||
.cal__date { display: block; }
|
||||
.cal__number { color: var(--subtle); font-weight: 700; }
|
||||
/* The header row says the weekday at every width now, so the copy inside each
|
||||
cell is for a screen reader rather than for the eye — it is what makes «22»
|
||||
announce itself as a Thursday. Hidden by clipping rather than by `display`,
|
||||
which would take it out of the accessibility tree as well. */
|
||||
.cal__weekday {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* The column header carries the weekday at this width, so saying it again in
|
||||
every one of thirty-one cells would be noise. The phone block below, where
|
||||
there is no header row, is the only place it shows. */
|
||||
.cal__weekday { display: none; }
|
||||
.cal__events { display: block; }
|
||||
/* Both of these are the phone's half of the month, and are drawn there. */
|
||||
.cal__dots { display: none; }
|
||||
.cal__list { display: none; }
|
||||
.cal__empty { margin: -0.5rem 0 1rem; text-align: center; }
|
||||
|
||||
.cal__event {
|
||||
@ -878,9 +817,6 @@ input[type="file"] {
|
||||
color: var(--brand-dark);
|
||||
text-decoration: none;
|
||||
line-height: 1.3;
|
||||
/* A title holding a URL is one unbreakable word; without this it leaves the
|
||||
cell sideways. */
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.cal__event:hover { text-decoration: underline; }
|
||||
.cal__event time { font-weight: 700; }
|
||||
@ -900,52 +836,44 @@ input[type="file"] {
|
||||
|
||||
.event-facts p { margin: 0 0 0.25rem; }
|
||||
|
||||
/* Still seven columns: a month that is not a grid is a list of dates, and a
|
||||
* list of dates is what the previous answer to this width turned out to be.
|
||||
* What changes is what fits in a fifty-pixel cell — the number and a dot per
|
||||
* event — with the titles in a list underneath that each busy cell links to. */
|
||||
/* Seven columns of nothing is what a month grid is on a phone, so the month
|
||||
* becomes a column of days — every day, in order, with its weekday beside it.
|
||||
*
|
||||
* Every rule here that decides `display` names the cell's own class, and that
|
||||
* is the point rather than a style preference. The version that shipped opened
|
||||
* with `.cal td { display: block }` — specificity (0,1,1) — which outranked
|
||||
* `.cal__pad { display: none }` at (0,1,0), so the padding cells stayed on
|
||||
* screen as 92px empty boxes; while `.cal__day:not(:has(.cal__event))` at
|
||||
* (0,2,0) won, so every real day disappeared. A month with no events drew four
|
||||
* blank boxes and nothing else, which is exactly what a phone showed. The two
|
||||
* rules were adjacent and had opposite outcomes, which is why reading them
|
||||
* looked right. */
|
||||
@media (max-width: 640px) {
|
||||
.cal__head, .cal__grid { gap: 2px; }
|
||||
.cal__head { font-size: 0.6rem; letter-spacing: 0; text-align: center; }
|
||||
.cal__day, .cal__pad { min-height: 54px; padding: 0.2rem; }
|
||||
.cal__date { text-align: center; }
|
||||
.cal__events { display: none; }
|
||||
/* Laid over the whole cell, so tapping anywhere on the 24th — the number
|
||||
included — goes to the 24th. A cell is about 49px wide on a 390px phone
|
||||
and 39px on a 320px one, which is as large as a seventh of the screen
|
||||
can be; the height makes up for it. */
|
||||
.cal__dots {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
.cal, .cal tbody, .cal tr { display: block; width: auto; }
|
||||
.cal thead { display: none; }
|
||||
.cal td.cal__pad { display: none; }
|
||||
.cal td.cal__day {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
align-content: flex-end;
|
||||
gap: 2px;
|
||||
padding: 0 2px 4px;
|
||||
align-items: baseline;
|
||||
gap: 0.6rem;
|
||||
height: auto;
|
||||
min-height: 44px;
|
||||
margin-bottom: 0.3rem;
|
||||
}
|
||||
.cal__dot {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
border-radius: 50%;
|
||||
background: var(--brand);
|
||||
}
|
||||
.cal__dot--public { background: var(--muted); }
|
||||
.cal__list { display: block; }
|
||||
.cal__listday { margin-bottom: 1rem; }
|
||||
.cal__listhead {
|
||||
margin: 0 0 0.2rem;
|
||||
font-size: 0.85rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
color: var(--muted);
|
||||
}
|
||||
/* Two classes, deliberately: `.cal__day:hover .cal__add` is (0,2,0) and a
|
||||
single-class rule here would lose to it the moment a phone browser
|
||||
decided a tap was a hover. There is no room for a + beside a number and
|
||||
four dots anyway — adding an event on a phone goes through the button at
|
||||
the top of the page, which asks for the day. */
|
||||
.cal__day .cal__add { display: none; }
|
||||
/* A week still reads as a week. */
|
||||
.cal tr + tr { margin-top: 0.5rem; }
|
||||
/* Fixed, so the dates line up down the page rather than stepping in and
|
||||
out as the weekday names change length. */
|
||||
.cal__date { flex: 0 0 4.2rem; }
|
||||
/* `display` and not only the colour: the base rule hides this, because up
|
||||
there the column header says the weekday. Leaving it out left every row
|
||||
reading as a bare number — the same shape of mistake as the pads, caught
|
||||
the same way, by looking at the rendered page. */
|
||||
.cal__weekday { display: inline; color: var(--subtle); }
|
||||
.cal__events { flex: 1; min-width: 0; }
|
||||
/* No hover on a phone, so the + is simply there; `float` would take it out
|
||||
of the flex row it is now part of. */
|
||||
.cal__add { display: inline-flex; float: none; }
|
||||
}
|
||||
|
||||
/* --- Gestión → Marca ---------------------------------------------------- */
|
||||
@ -1110,6 +1038,7 @@ input[type="file"] {
|
||||
|
||||
.actions .linkish,
|
||||
.feed-head .linkish,
|
||||
.cal-bar .linkish,
|
||||
.cal-bar__today a,
|
||||
.pager a {
|
||||
display: inline-block;
|
||||
@ -1141,11 +1070,6 @@ input[type="file"] {
|
||||
it does, so the whole thing is one target. */
|
||||
.toggle { padding: 0.65rem 0; }
|
||||
|
||||
/* A touchscreen has no hover, so the + is simply there. This says
|
||||
`display` and the 640px block above says `display: none` through
|
||||
`.cal__day .cal__add` — two classes to this rule's one, so the phone
|
||||
wins on specificity rather than on which block comes later in the file,
|
||||
and a tablet wider than 640px keeps its + with a thumb-sized box. */
|
||||
.cal__add {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
@ -1153,9 +1077,6 @@ input[type="file"] {
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
}
|
||||
/* The day list under the month on a phone: one line of text per event is
|
||||
a 21px target, and these are the links the dots exist to lead to. */
|
||||
.cal__list .cal__event { padding: 0.75rem 0; margin-top: 0; }
|
||||
}
|
||||
|
||||
/* --- said out loud: a machine wrote this -------------------------------- */
|
||||
|
||||
@ -132,8 +132,7 @@ def index():
|
||||
db = get_db()
|
||||
mine = db.execute(
|
||||
"""SELECT * FROM submissions WHERE author_id = ?
|
||||
ORDER BY CASE state WHEN 'pending' THEN 0 ELSE 1 END,
|
||||
created_at DESC, id DESC""",
|
||||
ORDER BY CASE state WHEN 'pending' THEN 0 ELSE 1 END, created_at DESC""",
|
||||
(g.member["id"],),
|
||||
).fetchall()
|
||||
queue = []
|
||||
@ -144,7 +143,7 @@ def index():
|
||||
m.profile_published AS author_published
|
||||
FROM submissions s JOIN members m ON m.id = s.author_id
|
||||
WHERE s.state = 'pending' AND s.author_id != ?
|
||||
ORDER BY s.created_at, s.id""",
|
||||
ORDER BY s.created_at""",
|
||||
(g.member["id"],),
|
||||
).fetchall()
|
||||
return render_template("submissions.html", mine=mine, queue=queue,
|
||||
|
||||
@ -1,16 +0,0 @@
|
||||
{# Fijar / No fijar, for a thread on the wall or on its own page.
|
||||
|
||||
A form rather than a link, because it changes something and a GET that
|
||||
changes something is a thing a prefetching browser will do on its own. It
|
||||
carries where it was pressed so pinning from the wall comes back to the
|
||||
wall, and the handler puts that through the same open-redirect check as the
|
||||
login form. #}
|
||||
{% macro pin(thread, back) %}
|
||||
<form method="post" action="{{ url_for('board.set_state', thread_id=thread.id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="field" value="pinned">
|
||||
<input type="hidden" name="value" value="{{ 0 if thread.pinned else 1 }}">
|
||||
<input type="hidden" name="back" value="{{ back }}">
|
||||
<button class="linkish" type="submit">{{ 'No fijar' if thread.pinned else 'Fijar' }}</button>
|
||||
</form>
|
||||
{% endmacro %}
|
||||
@ -1,16 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Calendario{% endblock %}
|
||||
|
||||
{#- One definition of what an event looks like, used in the grid cell and again
|
||||
in the list underneath it. Two copies of this markup would drift the first
|
||||
time one of them gained a field. -#}
|
||||
{% macro event_link(item) %}
|
||||
<a class="cal__event {{ 'cal__event--public' if item.public }}" href="{{ item.url }}">
|
||||
{%- if item.starts_at %}<time>{{ item.starts_at }}</time> {% endif %}{{ item.title }}
|
||||
{%- if item.public %} <span class="tag tag--quiet">público</span>{% endif %}
|
||||
</a>
|
||||
{% endmacro %}
|
||||
|
||||
{% block main %}
|
||||
<div class="feed-head">
|
||||
<h1>Calendario</h1>
|
||||
@ -26,88 +16,69 @@
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{#- Two round controls with the month between them, rather than three runs of
|
||||
text in a row that cannot wrap: at 320px «← Anterior / noviembre 2026 /
|
||||
Siguiente →» pushed the next-month link off the right edge, which is how a
|
||||
month became impossible to leave. The same shape as the public agenda's
|
||||
bar, which has never had that problem. -#}
|
||||
<nav class="cal-bar" aria-label="Mes">
|
||||
<a class="cal-bar__move" rel="prev" aria-label="Mes anterior"
|
||||
href="{{ url_for('events.month', mes=previous) }}">←</a>
|
||||
<strong class="cal-bar__label">{{ label }}</strong>
|
||||
<a class="cal-bar__move" rel="next" aria-label="Mes siguiente"
|
||||
href="{{ url_for('events.month', mes=next) }}">→</a>
|
||||
<a class="linkish" href="{{ url_for('events.month', mes=previous) }}">← Anterior</a>
|
||||
<strong>{{ label }}</strong>
|
||||
<a class="linkish" href="{{ url_for('events.month', mes=next) }}">Siguiente →</a>
|
||||
</nav>
|
||||
<p class="muted small cal-bar__today">
|
||||
<a href="{{ url_for('events.month', mes=this_month) }}">Ir a este mes</a>
|
||||
</p>
|
||||
|
||||
{# Said above the grid rather than below it, so a thumb meets it first. The
|
||||
grid is drawn either way: a month that draws nothing because it holds
|
||||
nothing looks broken, and looking broken is what it did. #}
|
||||
{# Said above the grid rather than below it: on a phone the month is a column
|
||||
of days, and a line under thirty-one empty rows is a line nobody reads. The
|
||||
public agenda says the same thing in its own words (agenda.html). #}
|
||||
{% if not by_day %}
|
||||
<p class="muted cal__empty">No hay nada en {{ label }}.</p>
|
||||
{% endif %}
|
||||
|
||||
<ol class="cal__head" aria-hidden="true">
|
||||
{% for day in weekdays %}<li>{{ day }}</li>{% endfor %}
|
||||
</ol>
|
||||
<ol class="cal__grid">
|
||||
{% for week in weeks %}
|
||||
{% for day in week %}
|
||||
{# calendar.monthdayscalendar pads the first and last weeks with zeroes,
|
||||
which are days belonging to the neighbouring months. They keep their
|
||||
space — that is what puts the 1st under its own weekday — and lose only
|
||||
their ink. #}
|
||||
{% if day == 0 %}
|
||||
<li class="cal__pad" aria-hidden="true"></li>
|
||||
{% else %}
|
||||
<li class="cal__day {{ 'cal__day--today' if day == today }}">
|
||||
{# `loop.index0` of this inner loop *is* the weekday, since each week is
|
||||
seven cells starting on Monday, so nothing has to be computed in
|
||||
Python. The column header says the weekday at every width now, so
|
||||
this copy is for a screen reader: it is what makes «22» announce
|
||||
itself as a Thursday. #}
|
||||
<span class="cal__date">
|
||||
<span class="cal__weekday">{{ weekdays[loop.index0] }}</span>
|
||||
<span class="cal__number">{{ day }}</span>
|
||||
</span>
|
||||
{% if by_day.get(day) %}
|
||||
{# A phone cell is about fifty pixels wide, which holds a number and
|
||||
some dots and nothing else. The dots are the link to this day's
|
||||
block in the list below, so the month stays a month and the titles
|
||||
stay readable. Above 640px they are hidden and the titles sit in the
|
||||
cell itself. #}
|
||||
<a class="cal__dots" href="#eventos-{{ day }}"
|
||||
aria-label="{{ by_day.get(day)|length }} evento{{ '' if by_day.get(day)|length == 1 else 's' }} el {{ day }}">
|
||||
{% for item in by_day.get(day)[:4] %}<i class="cal__dot {{ 'cal__dot--public' if item.public }}"></i>{% endfor %}
|
||||
</a>
|
||||
{% endif %}
|
||||
<span class="cal__events">
|
||||
{% for item in by_day.get(day, []) %}{{ event_link(item) }}{% endfor %}
|
||||
</span>
|
||||
{% if may_edit %}
|
||||
{# The day is carried into the form, so adding something to the 24th
|
||||
starts with the 24th already filled in. #}
|
||||
<a class="cal__add" title="Añadir evento este día"
|
||||
href="{{ url_for('events.new', dia='%s-%02d'|format(month_key, day)) }}">+</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ol>
|
||||
|
||||
{# Only the days that have something in them, and only on a phone — above 640px
|
||||
every title is already in its cell and this would say it all twice. #}
|
||||
<section class="cal__list" aria-label="Eventos del mes">
|
||||
{% for day, items in by_day|dictsort %}
|
||||
<div class="cal__listday" id="eventos-{{ day }}">
|
||||
<h2 class="cal__listhead">{{ day }} de {{ label }}</h2>
|
||||
{% for item in items %}{{ event_link(item) }}{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
<table class="cal">
|
||||
<thead>
|
||||
<tr>{% for day in weekdays %}<th scope="col">{{ day }}</th>{% endfor %}</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for week in weeks %}
|
||||
<tr>
|
||||
{% for day in week %}
|
||||
{# calendar.monthdayscalendar pads the first and last weeks with
|
||||
zeroes, which are days belonging to the neighbouring months. #}
|
||||
{% if day == 0 %}
|
||||
<td class="cal__pad"></td>
|
||||
{% else %}
|
||||
<td class="cal__day {{ 'cal__day--today' if day == today }}">
|
||||
{# The weekday travels with the number because on a phone the
|
||||
header row is hidden — the grid is a column there, and a day
|
||||
without its weekday is just an integer. `loop.index0` of this
|
||||
loop *is* the weekday, since each week is seven cells
|
||||
starting on Monday, so nothing has to be computed in Python.
|
||||
Above 640px .cal__weekday is display:none and the column
|
||||
header says it instead. #}
|
||||
<span class="cal__date">
|
||||
<span class="cal__weekday">{{ weekdays[loop.index0] }}</span>
|
||||
<span class="cal__number">{{ day }}</span>
|
||||
</span>
|
||||
<span class="cal__events">
|
||||
{% for item in by_day.get(day, []) %}
|
||||
<a class="cal__event {{ 'cal__event--public' if item.public }}"
|
||||
href="{{ item.url }}">
|
||||
{% if item.starts_at %}<time>{{ item.starts_at }}</time> {% endif %}{{ item.title }}
|
||||
{% if item.public %}<span class="tag tag--quiet">público</span>{% endif %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</span>
|
||||
{% if may_edit %}
|
||||
{# The day is carried into the form, so adding something to the
|
||||
24th starts with the 24th already filled in. #}
|
||||
<a class="cal__add" title="Añadir evento este día"
|
||||
href="{{ url_for('events.new', dia='%s-%02d'|format(month_key, day)) }}">+</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<p class="muted small">
|
||||
Los eventos marcados <span class="tag tag--quiet">público</span> están en
|
||||
|
||||
@ -34,12 +34,7 @@
|
||||
|
||||
{% if meta.dated %}
|
||||
<label for="date">Fecha</label>
|
||||
<input id="date" name="date" type="date" required value="{{ f.date_input or today }}">
|
||||
{#- The publication time the post already carries. Hugo sorts the blog by
|
||||
the whole of it and a date field is only a day, so without this, saving
|
||||
a corrected typo would restamp the clock and carry a year-old post to
|
||||
the top of the home page. -#}
|
||||
<input type="hidden" name="date_stamped" value="{{ f.date_stamped or '' }}">
|
||||
<input id="date" name="date" type="date" required value="{{ f.date or today }}">
|
||||
{% endif %}
|
||||
|
||||
{% if collection == 'page' %}
|
||||
@ -159,17 +154,6 @@
|
||||
<span class="toggle__text">Contenido generado con IA</span>
|
||||
</label>
|
||||
|
||||
{#- The same switch for the pin, next to it. The moment it was pinned
|
||||
rides along in the hidden field so that saving a correction does
|
||||
not count as pinning it again and carry it above everything pinned
|
||||
since. -#}
|
||||
<label class="toggle">
|
||||
<input type="checkbox" name="pinned" {{ 'checked' if f.pinned }}>
|
||||
<span class="toggle__track" aria-hidden="true"></span>
|
||||
<span class="toggle__text">Fijar arriba</span>
|
||||
</label>
|
||||
<input type="hidden" name="pinned_at" value="{{ f.pinned_at or '' }}">
|
||||
|
||||
{#- Beside Cancelar and shaped like it: both are things you press in this
|
||||
row, and a bare link wedged between two buttons reads as unfinished. -#}
|
||||
<button class="btn btn--quiet" type="submit"
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
<td>
|
||||
<a href="{{ url_for('content.edit', collection=collection, name=item.name) }}">{{ item.title }}</a>
|
||||
<div class="muted small mono">{{ item.name }}</div>
|
||||
{% if item.pinned %}<span class="tag">Fijado</span>{% endif %}
|
||||
{% if item.ai_generated %}<span class="tag tag--ai" title="Quien lo publicó marcó este texto como generado con inteligencia artificial.">Generado con IA</span>{% endif %}
|
||||
</td>
|
||||
{# data-label is drawn by board.css under 640px, where the header row
|
||||
@ -48,15 +47,6 @@
|
||||
<td>
|
||||
<div class="actions actions--row">
|
||||
<a class="linkish" href="{{ url_for('content.edit', collection=collection, name=item.name) }}">Editar</a>
|
||||
{#- One press from the screen that shows what is already
|
||||
fijado, rather than opening the post to find out. It
|
||||
commits, like every other write here. -#}
|
||||
<form method="post"
|
||||
action="{{ url_for('content.pin', collection=collection, name=item.name) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="value" value="{{ 0 if item.pinned else 1 }}">
|
||||
<button class="linkish" type="submit">{{ 'No fijar' if item.pinned else 'Fijar' }}</button>
|
||||
</form>
|
||||
<form method="post"
|
||||
action="{{ url_for('content.delete', collection=collection, name=item.name) }}"
|
||||
data-confirm="Se eliminará «{{ item.title }}» del sitio público. ¿Seguro?">
|
||||
|
||||
@ -52,9 +52,6 @@
|
||||
{% endif %}
|
||||
{% for t in threads %}
|
||||
<p class="panel__row">
|
||||
{# This panel orders by the pin like the wall does, so it has to say
|
||||
which one is pinned or the order looks arbitrary from here. #}
|
||||
{% if t.pinned %}<span class="tag">Fijado</span> {% endif %}
|
||||
<a href="{{ url_for('board.thread', thread_id=t.id) }}">{{ t.title }}</a>
|
||||
<span class="muted small">{{ person(t.author, t.author_login) }} · {{ t.replies }} respuesta{{ '' if t.replies == 1 else 's' }}</span>
|
||||
</p>
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
{% from "_person.html" import person %}
|
||||
{% from "_reaction.html" import reaction %}
|
||||
{% from "_attachments.html" import attachments %}
|
||||
{% from "_pin.html" import pin %}
|
||||
{% block title %}{{ thread.title }}{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
@ -31,12 +30,13 @@
|
||||
<button class="linkish linkish--danger" type="submit">Eliminar</button>
|
||||
</form>
|
||||
{% endif %}
|
||||
{# Pinning is curation and a moderator does it; closing a conversation
|
||||
stops named people talking to each other and is an admin's. #}
|
||||
{% if may_pin %}
|
||||
{{ pin(thread, url_for('board.thread', thread_id=thread.id)) }}
|
||||
{% endif %}
|
||||
{% if is_admin %}
|
||||
<form method="post" action="{{ url_for('board.set_state', thread_id=thread.id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="field" value="pinned">
|
||||
<input type="hidden" name="value" value="{{ 0 if thread.pinned else 1 }}">
|
||||
<button class="linkish" type="submit">{{ 'No fijar' if thread.pinned else 'Fijar' }}</button>
|
||||
</form>
|
||||
<form method="post" action="{{ url_for('board.set_state', thread_id=thread.id) }}">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<input type="hidden" name="field" value="locked">
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
{% extends "base.html" %}
|
||||
{% from "_person.html" import person %}
|
||||
{% from "_reaction.html" import reaction %}
|
||||
{% from "_pin.html" import pin %}
|
||||
{% block title %}Muro{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
@ -31,10 +30,6 @@
|
||||
<div class="card__foot">
|
||||
{{ reaction('thread', t.id, reactions.get(t.id), url_for('board.threads', page=page)) }}
|
||||
<span>{{ t.replies }} respuesta{{ '' if t.replies == 1 else 's' }}</span>
|
||||
{# From here as well as from the thread page: deciding what the wall
|
||||
leads with means looking at the wall, not opening each thread to
|
||||
find out what is on it. #}
|
||||
{% if may_pin %}{{ pin(t, url_for('board.threads', page=page)) }}{% endif %}
|
||||
</div>
|
||||
</article>
|
||||
{% endfor %}
|
||||
|
||||
@ -87,86 +87,12 @@ def test_a_closed_thread_refuses_replies(client, db, post, thread, make_member,
|
||||
assert count == 0
|
||||
|
||||
|
||||
def test_a_plain_member_cannot_pin(client, post, thread, make_member, sign_in):
|
||||
def test_only_admins_pin(client, post, thread, make_member, sign_in):
|
||||
sign_in(make_member("maria"))
|
||||
assert post(f"/comunidad/tema/{thread['id']}/estado",
|
||||
{"field": "pinned", "value": "1"}).status_code == 403
|
||||
|
||||
|
||||
def test_a_moderator_pins_but_does_not_lock(client, post, thread, make_member,
|
||||
sign_in, db):
|
||||
"""The two ride the same route and are not the same authority. Deciding
|
||||
what the association reads first is curation, which is the whole of a
|
||||
moderator's job; closing a conversation stops named people saying anything
|
||||
more to each other, and that is an admin's."""
|
||||
sign_in(make_member("modera", role="moderator"))
|
||||
|
||||
assert post(f"/comunidad/tema/{thread['id']}/estado",
|
||||
{"field": "pinned", "value": "1"}).status_code in (302, 303)
|
||||
row = db.execute("SELECT pinned, pinned_at FROM threads WHERE id = ?",
|
||||
(thread["id"],)).fetchone()
|
||||
assert row["pinned"] == 1 and row["pinned_at"]
|
||||
|
||||
assert post(f"/comunidad/tema/{thread['id']}/estado",
|
||||
{"field": "locked", "value": "1"}).status_code == 403
|
||||
assert db.execute("SELECT locked FROM threads WHERE id = ?",
|
||||
(thread["id"],)).fetchone()["locked"] == 0
|
||||
|
||||
|
||||
def test_unpinning_forgets_when_it_was_pinned(client, post, thread, make_member,
|
||||
sign_in, db):
|
||||
"""Otherwise pinning it again would put it back where the old pin was,
|
||||
rather than at the top where a new pin belongs."""
|
||||
sign_in(make_member("modera", role="moderator"))
|
||||
post(f"/comunidad/tema/{thread['id']}/estado", {"field": "pinned", "value": "1"})
|
||||
post(f"/comunidad/tema/{thread['id']}/estado", {"field": "pinned", "value": "0"})
|
||||
|
||||
row = db.execute("SELECT pinned, pinned_at FROM threads WHERE id = ?",
|
||||
(thread["id"],)).fetchone()
|
||||
assert row["pinned"] == 0 and row["pinned_at"] is None
|
||||
|
||||
|
||||
def test_a_pinned_thread_leads_the_wall_and_inicio(client, post, make_member,
|
||||
sign_in, db):
|
||||
"""Both lists, because they are the same rows and used to disagree: the
|
||||
wall ordered by the pin and Inicio's panel did not."""
|
||||
author = make_member("escribe")
|
||||
sign_in(author)
|
||||
for title in ("Lo primero", "Lo segundo", "Lo tercero"):
|
||||
post("/comunidad/nuevo", {"title": title, "body": "Texto."})
|
||||
old = db.execute("SELECT id FROM threads ORDER BY id LIMIT 1").fetchone()["id"]
|
||||
|
||||
sign_in(make_member("modera", role="moderator"))
|
||||
post(f"/comunidad/tema/{old}/estado", {"field": "pinned", "value": "1"})
|
||||
|
||||
for url in ("/comunidad/muro", "/comunidad/"):
|
||||
page = client.get(url).get_data(as_text=True)
|
||||
assert page.index("Lo primero") < page.index("Lo tercero"), url
|
||||
|
||||
|
||||
def test_the_newest_pin_goes_above_an_older_one(client, post, make_member,
|
||||
sign_in, db):
|
||||
"""Several pins at once, newest pin first — which is why the column holds
|
||||
the moment rather than a 1."""
|
||||
author = make_member("escribe")
|
||||
sign_in(author)
|
||||
post("/comunidad/nuevo", {"title": "Fijado hace rato", "body": "Texto."})
|
||||
post("/comunidad/nuevo", {"title": "Fijado ahora", "body": "Texto."})
|
||||
first, second = [r["id"] for r in
|
||||
db.execute("SELECT id FROM threads ORDER BY id")]
|
||||
|
||||
sign_in(make_member("modera", role="moderator"))
|
||||
post(f"/comunidad/tema/{first}/estado", {"field": "pinned", "value": "1"})
|
||||
# `datetime('now')` has one-second resolution, so the two pins would
|
||||
# otherwise land in the same second and the order would be the fallback.
|
||||
db.execute("UPDATE threads SET pinned_at = '2026-01-01 00:00:00' WHERE id = ?",
|
||||
(first,))
|
||||
post(f"/comunidad/tema/{second}/estado", {"field": "pinned", "value": "1"})
|
||||
|
||||
page = client.get("/comunidad/muro").get_data(as_text=True)
|
||||
assert page.index("Fijado ahora") < page.index("Fijado hace rato")
|
||||
|
||||
|
||||
def test_the_state_field_is_not_a_way_into_the_query(client, post, thread, make_member, sign_in):
|
||||
"""`field` is interpolated into the UPDATE, so it is checked against a fixed
|
||||
pair first. This asserts the check, not the interpolation."""
|
||||
|
||||
@ -12,8 +12,6 @@ from __future__ import annotations
|
||||
import importlib.util
|
||||
import io
|
||||
import sys
|
||||
from datetime import date as date_type
|
||||
from datetime import datetime
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
@ -568,8 +566,7 @@ def test_an_event_carries_its_own_date_and_an_ics(repo, editor, post):
|
||||
|
||||
path, = repo.files
|
||||
front = yaml.safe_load(repo.files[path].decode().split("---")[1])
|
||||
# The day the writer chose, and the clock attached to it — see `stamp`.
|
||||
assert front["date"].date().isoformat() == "2026-10-03"
|
||||
assert front["date"].isoformat() == "2026-10-03"
|
||||
assert front["event_date"] == "2026-10-24"
|
||||
assert front["event_time"] == "18:30"
|
||||
assert front["event_location"] == "Plaza de Ottakring"
|
||||
@ -703,101 +700,6 @@ def test_the_disclosure_is_not_one_of_the_keys_translation_rewrites(repo, editor
|
||||
assert "ai_generated" not in translate.TRANSLATED_KEYS
|
||||
|
||||
|
||||
# --- what the site leads with ---------------------------------------------
|
||||
|
||||
def test_a_pinned_post_carries_the_moment_it_was_pinned(repo, editor, post):
|
||||
"""One key for both the flag and the order. Several posts can be pinned and
|
||||
the newest pin goes first, so the value has to say when — and it is written
|
||||
only when it is true, like the IA disclosure, so no post carries a line
|
||||
reading `pinned: false` for somebody to wonder about."""
|
||||
publish(post, pinned="on")
|
||||
path, = repo.files
|
||||
fm, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert isinstance(fm["pinned"], str) and fm["pinned"].startswith("20")
|
||||
|
||||
publish(post, title="Sin fijar", pinned="")
|
||||
other = [p for p in repo.files if p != path][0]
|
||||
fm, _ = translate.split_frontmatter(repo.files[other].decode())
|
||||
assert "pinned" not in fm
|
||||
|
||||
|
||||
def test_editing_a_pinned_post_does_not_count_as_pinning_it_again(repo, editor, post):
|
||||
"""Otherwise fixing a typo would carry it above everything pinned since,
|
||||
which is the same shape of bug as the publication date and lands in the
|
||||
same place."""
|
||||
publish(post, pinned="on")
|
||||
path, = repo.files
|
||||
before, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
|
||||
post(f"/comunidad/contenido/post/editar/{path.rsplit('/', 1)[1]}",
|
||||
{"title": "Sabores del barrio", "body": "Corregido.", "date": "2026-09-25",
|
||||
"pinned": "on", "pinned_at": before["pinned"],
|
||||
"sha": repo._sha(repo.files[path])})
|
||||
|
||||
after, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert after["pinned"] == before["pinned"]
|
||||
|
||||
|
||||
def test_the_pin_survives_an_edit_that_says_nothing_about_it(repo, editor, post, client):
|
||||
"""The form loads it back the way it was left. A flag read into the form
|
||||
but not written out again is a flag that one correction quietly removes."""
|
||||
publish(post, pinned="on")
|
||||
path, = repo.files
|
||||
name = path.rsplit("/", 1)[1]
|
||||
page = client.get(f"/comunidad/contenido/post/editar/{name}").get_data(as_text=True)
|
||||
assert 'name="pinned" checked' in page.replace(' >', '>')
|
||||
|
||||
|
||||
def test_pinning_from_the_list_commits_without_opening_the_post(repo, editor, post):
|
||||
publish(post)
|
||||
path, = repo.files
|
||||
name = path.rsplit("/", 1)[1]
|
||||
|
||||
post(f"/comunidad/contenido/post/fijar/{name}", {"value": "1"})
|
||||
fm, body = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert fm["pinned"] and body.strip() == "Texto del artículo."
|
||||
|
||||
post(f"/comunidad/contenido/post/fijar/{name}", {"value": "0"})
|
||||
fm, body = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert "pinned" not in fm and body.strip() == "Texto del artículo."
|
||||
|
||||
|
||||
def test_a_plain_member_cannot_pin_a_post(repo, post, make_member, sign_in):
|
||||
sign_in(make_member("maria"))
|
||||
assert post("/comunidad/contenido/post/fijar/cualquiera.es.md",
|
||||
{"value": "1"}).status_code == 403
|
||||
|
||||
|
||||
def test_a_moderator_can_pin_a_post(repo, post, make_member, sign_in):
|
||||
"""Curating what the public reads is the whole of a moderator's job, and
|
||||
`COLLECTIONS["post"]["role"]` has said so since the queue was built."""
|
||||
sign_in(make_member("modera", role="moderator"))
|
||||
publish(post)
|
||||
path, = repo.files
|
||||
response = post(f"/comunidad/contenido/post/fijar/{path.rsplit('/', 1)[1]}",
|
||||
{"value": "1"})
|
||||
assert response.status_code in (302, 303)
|
||||
fm, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert fm["pinned"]
|
||||
|
||||
|
||||
def test_the_pin_is_not_one_of_the_keys_translation_rewrites(repo, editor, post):
|
||||
"""A pinned post is pinned in German too. `translate_file` copies the whole
|
||||
frontmatter and rewrites only TRANSLATED_KEYS, so this needs no change to
|
||||
the pipeline — asserted against the real list, because a key quietly added
|
||||
to it would send a timestamp through a translation engine."""
|
||||
publish(post, pinned="on")
|
||||
assert "pinned" not in translate.TRANSLATED_KEYS
|
||||
|
||||
|
||||
def test_the_pinned_post_is_first_in_the_editors_list(repo, editor, post, client):
|
||||
publish(post, title="Un aviso viejo", date="2026-01-05", pinned="on")
|
||||
publish(post, title="Algo de ayer", date="2026-09-25")
|
||||
|
||||
page = client.get("/comunidad/contenido/post").get_data(as_text=True)
|
||||
assert page.index("Un aviso viejo") < page.index("Algo de ayer")
|
||||
|
||||
|
||||
# --- a post nobody titled -------------------------------------------------
|
||||
|
||||
def test_an_untitled_post_is_named_when_it_is_published(repo, editor, post):
|
||||
@ -856,82 +758,3 @@ def test_a_post_still_needs_a_body(repo, editor, post):
|
||||
response = publish(post, title="", body="")
|
||||
assert not repo.files
|
||||
assert "cuerpo no puede estar vacío" in response.get_data(as_text=True)
|
||||
|
||||
|
||||
# --- the order the site reads them in -------------------------------------
|
||||
|
||||
def test_two_posts_published_on_one_day_do_not_have_the_same_date(
|
||||
repo, editor, post):
|
||||
"""The bug behind «the posts are not in the order they were written».
|
||||
|
||||
`date: 2026-09-25` with no clock is byte-identical for everything published
|
||||
that day, so Hugo falls through its sort keys to the title and the day
|
||||
comes out alphabetised — permanently, because a rebuild changes nothing
|
||||
about the files. The day is still the one the writer chose; the time is
|
||||
only what breaks the tie.
|
||||
"""
|
||||
publish(post, title="Zutano llega tarde", date="2026-09-25")
|
||||
publish(post, title="Abc va primero", date="2026-09-25")
|
||||
|
||||
dates = {}
|
||||
for path, blob in repo.files.items():
|
||||
fm, _ = translate.split_frontmatter(blob.decode())
|
||||
dates[path] = fm["date"]
|
||||
|
||||
assert len(dates) == 2
|
||||
for path, when in dates.items():
|
||||
assert isinstance(when, datetime), f"{path} carries a bare date: {when!r}"
|
||||
assert when.date() == date_type(2026, 9, 25)
|
||||
# And the URL still carries only the day, so nothing anybody linked moves.
|
||||
assert sorted(repo.files) == [
|
||||
"content/post/2026-09-25-abc-va-primero.es.md",
|
||||
"content/post/2026-09-25-zutano-llega-tarde.es.md",
|
||||
]
|
||||
|
||||
|
||||
def test_the_newest_post_is_first_in_the_editors_own_list(repo, editor, post, client):
|
||||
"""Contenido sorted on the same date-only string, with the filename as the
|
||||
tiebreak — and `reverse=True` reverses the filename too, so the day came
|
||||
out in descending-alphabetical slug order."""
|
||||
publish(post, title="Abc se publica primero", date="2026-09-25")
|
||||
publish(post, title="Zutano se publica después", date="2026-09-25")
|
||||
|
||||
page = client.get("/comunidad/contenido/post").get_data(as_text=True)
|
||||
assert page.index("Zutano se publica después") < page.index("Abc se publica primero")
|
||||
|
||||
|
||||
def test_correcting_a_post_does_not_move_it_to_the_top(repo, editor, post):
|
||||
"""An edit keeps the publication time the file already carried, as long as
|
||||
the day has not moved. Without that, fixing a typo in a year-old post would
|
||||
restamp it with today's clock and carry it up the page."""
|
||||
publish(post, title="Una nota de hace tiempo", date="2026-09-25")
|
||||
path, = repo.files
|
||||
before, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
|
||||
post(f"/comunidad/contenido/post/editar/{path.rsplit('/', 1)[1]}",
|
||||
{"title": "Una nota de hace tiempo", "body": "Corregida.",
|
||||
"date": "2026-09-25", "date_stamped": before["date"].isoformat(),
|
||||
"sha": repo._sha(repo.files[path])})
|
||||
|
||||
after, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert after["date"] == before["date"]
|
||||
|
||||
|
||||
def test_moving_a_post_to_another_day_restamps_it(repo, editor, post):
|
||||
"""The other half: a date deliberately changed is a date changed, and the
|
||||
clock that goes with it is the one it is being published at now."""
|
||||
publish(post, title="Se adelanta", date="2026-09-25")
|
||||
path, = repo.files
|
||||
before, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
|
||||
post(f"/comunidad/contenido/post/editar/{path.rsplit('/', 1)[1]}",
|
||||
{"title": "Se adelanta", "body": "Texto.", "date": "2026-10-01",
|
||||
"date_stamped": before["date"].isoformat(),
|
||||
"sha": repo._sha(repo.files[path])})
|
||||
|
||||
# An edit writes back to the file it opened — the filename keeps the day it
|
||||
# was created with, and always has. The date Hugo sorts and builds the URL
|
||||
# from is the one in the frontmatter, and that is the one that moves.
|
||||
after, _ = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert after["date"].date() == date_type(2026, 10, 1)
|
||||
assert after["date"] != before["date"]
|
||||
|
||||
@ -120,13 +120,14 @@ def test_february_in_a_leap_year_has_twenty_nine_days(client, superadmin_id, sig
|
||||
|
||||
def test_a_month_with_nothing_in_it_says_so_and_still_draws_its_days(
|
||||
client, superadmin_id, sign_in, quiet_gitea):
|
||||
"""An empty month still draws its month, which is how you see that it is
|
||||
empty. The line above it says so in words, as the public agenda does.
|
||||
"""On a phone the month is a column of days rather than a grid, so an empty
|
||||
month is thirty-one empty rows — which is how you see that it is empty. The
|
||||
line above them says it in words, as the public agenda does.
|
||||
|
||||
The HTML has always been right here; what shipped was a stylesheet that hid
|
||||
every day and kept the cells belonging to the neighbouring months, so the
|
||||
page was six hundred pixels of nothing. The rules that catch that one are in
|
||||
test_templates.py, where they can be seen.
|
||||
page was six hundred pixels of nothing. The rule that catches that one is in
|
||||
test_templates.py, where it can be seen.
|
||||
"""
|
||||
sign_in(superadmin_id)
|
||||
page = client.get("/comunidad/calendario?mes=2026-12").get_data(as_text=True)
|
||||
@ -146,49 +147,12 @@ def test_a_month_with_something_in_it_does_not_claim_to_be_empty(
|
||||
assert "Asamblea" in page
|
||||
|
||||
|
||||
def test_a_busy_day_carries_a_dot_per_event_and_a_block_of_its_own(
|
||||
client, an_event, superadmin_id, sign_in):
|
||||
"""What a phone shows instead of the titles, which do not fit in a cell
|
||||
fifty pixels wide.
|
||||
|
||||
The dots are the link to the day's block in the list underneath, so the
|
||||
month stays a month and the titles stay readable. Both halves are asserted
|
||||
together because either one alone is useless: dots that link nowhere, or a
|
||||
block nothing points at.
|
||||
"""
|
||||
an_event("Asamblea", "2026-10-24")
|
||||
an_event("Ensayo", "2026-10-24", starts_at="19:00")
|
||||
sign_in(superadmin_id)
|
||||
|
||||
page = client.get("/comunidad/calendario?mes=2026-10").get_data(as_text=True)
|
||||
|
||||
assert 'href="#eventos-24"' in page
|
||||
assert page.count('class="cal__dot ') == 2
|
||||
block = page.split('id="eventos-24"')[1]
|
||||
assert "Asamblea" in block and "Ensayo" in block
|
||||
# A day with nothing in it has nothing to link to.
|
||||
assert 'href="#eventos-23"' not in page
|
||||
|
||||
|
||||
def test_the_month_can_always_be_left(client, superadmin_id, sign_in, quiet_gitea):
|
||||
"""Both controls, at every width, with no text beside them to push one off
|
||||
the edge. `← Anterior / noviembre 2026 / Siguiente →` was three runs of
|
||||
text in a row that could not wrap, and at 320px the next month was simply
|
||||
not reachable."""
|
||||
sign_in(superadmin_id)
|
||||
page = client.get("/comunidad/calendario?mes=2026-10").get_data(as_text=True)
|
||||
|
||||
assert page.count('class="cal-bar__move"') == 2
|
||||
assert 'rel="prev"' in page and 'rel="next"' in page
|
||||
|
||||
|
||||
def test_every_day_carries_its_weekday_for_a_screen_reader(
|
||||
def test_every_day_carries_its_weekday_for_the_phone(
|
||||
client, superadmin_id, sign_in, quiet_gitea):
|
||||
"""The header row says the weekday to anyone who can see it; this copy is
|
||||
what makes «22» announce itself as a Thursday. It comes from the loop
|
||||
position rather than from a date calculation, which is why this checks the
|
||||
pairing and not the markup: an off-by-one would put Sunday's name on
|
||||
Monday's cell."""
|
||||
"""The column header is hidden at phone width, so without this a day is a
|
||||
bare number in a list. It comes from the loop position rather than from a
|
||||
date calculation, which is why this checks the pairing and not the markup:
|
||||
an off-by-one would put Sunday's name on Monday's row."""
|
||||
sign_in(superadmin_id)
|
||||
page = client.get("/comunidad/calendario?mes=2026-10").get_data(as_text=True)
|
||||
|
||||
|
||||
@ -487,62 +487,3 @@ def test_step_nine_gives_every_post_somewhere_to_say_a_machine_wrote_it(tmp_path
|
||||
assert db.execute("PRAGMA user_version").fetchone()[0] == max(
|
||||
number for number, _, _ in migrations.STEPS)
|
||||
db.close()
|
||||
|
||||
|
||||
def test_step_ten_gives_a_post_somewhere_to_say_when_it_was_pinned(tmp_path):
|
||||
"""Two plain ADD COLUMNs, and the rows around them untouched.
|
||||
|
||||
Both hold a moment rather than a flag, because several posts can be pinned
|
||||
and the newest pin goes first — so the value is the order, and there is no
|
||||
second column to keep in step with the first. `threads.pinned` is the
|
||||
exception and stays: it has been in the schema since the board shipped and
|
||||
is what the wall's index is on.
|
||||
"""
|
||||
from apps.board.app import create_app
|
||||
from apps.board.db import connect
|
||||
|
||||
path = str(tmp_path / "board.db")
|
||||
create_app({"SECRET_KEY": "x", "DB_PATH": path, "OWNER_LOGIN": "salvador",
|
||||
"UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True})
|
||||
|
||||
db = connect(path)
|
||||
member = db.execute("SELECT id FROM members WHERE role = 'superadmin'").fetchone()["id"]
|
||||
db.execute("INSERT INTO threads (author_id, title, body_md, pinned)"
|
||||
" VALUES (?, 'Fijado hace tiempo', 'Texto.', 1)", (member,))
|
||||
db.execute("""INSERT INTO content_cache (path, sha, title, date)
|
||||
VALUES ('content/post/2026-01-01-algo.es.md', 'abc', 'Algo', '2026-01-01')""")
|
||||
# Wind it back to a server that has been running since before this phase.
|
||||
# The index has to go first — SQLite refuses to drop a column one names,
|
||||
# which is the same reason the step has to recreate it rather than leave it
|
||||
# to `CREATE INDEX IF NOT EXISTS`.
|
||||
db.execute("DROP INDEX threads_live")
|
||||
db.execute("CREATE INDEX threads_live ON threads(pinned DESC, created_at DESC)"
|
||||
" WHERE deleted_at IS NULL")
|
||||
db.execute("ALTER TABLE threads DROP COLUMN pinned_at")
|
||||
db.execute("ALTER TABLE content_cache DROP COLUMN pinned")
|
||||
db.execute("PRAGMA user_version = 9")
|
||||
db.commit()
|
||||
db.close()
|
||||
|
||||
create_app({"SECRET_KEY": "x", "DB_PATH": path, "OWNER_LOGIN": "salvador",
|
||||
"UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True})
|
||||
|
||||
db = connect(path)
|
||||
assert "pinned_at" in {row[1] for row in db.execute("PRAGMA table_info(threads)")}
|
||||
assert "pinned" in {row[1] for row in db.execute("PRAGMA table_info(content_cache)")}
|
||||
# A thread pinned before this step keeps its pin and gains no moment: we do
|
||||
# not know when, and NULL says so rather than inventing a time that would
|
||||
# put it above everything pinned since.
|
||||
row = db.execute("SELECT title, pinned, pinned_at FROM threads").fetchone()
|
||||
assert row["title"] == "Fijado hace tiempo"
|
||||
assert row["pinned"] == 1 and row["pinned_at"] is None
|
||||
assert db.execute("SELECT pinned FROM content_cache").fetchone()["pinned"] == ""
|
||||
# And the index is the new one. `CREATE INDEX IF NOT EXISTS` would have
|
||||
# left the old definition standing on a server that had been running,
|
||||
# so a fresh install and an upgraded one would have quietly diverged.
|
||||
index = db.execute("SELECT sql FROM sqlite_master WHERE name = 'threads_live'"
|
||||
).fetchone()["sql"]
|
||||
assert "pinned_at" in index
|
||||
assert db.execute("PRAGMA user_version").fetchone()[0] == max(
|
||||
number for number, _, _ in migrations.STEPS)
|
||||
db.close()
|
||||
|
||||
@ -306,116 +306,56 @@ def _winning_display(rules, ending_in):
|
||||
return winner
|
||||
|
||||
|
||||
def _rules_in(body):
|
||||
body = re.sub(r"/\*.*?\*/", "", body, flags=re.DOTALL)
|
||||
return [(selector.strip(), rule.group("body"))
|
||||
for rule in RULE.finditer(body)
|
||||
for selector in rule.group("selectors").split(",") if selector.strip()]
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def board_css():
|
||||
return (Path(__file__).resolve().parents[1] / "static" / "board.css").read_text(
|
||||
encoding="utf-8")
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def calendar_phone_rules(board_css):
|
||||
block = CALENDAR_PHONE_BLOCK.search(board_css)
|
||||
def calendar_phone_rules():
|
||||
css = (Path(__file__).resolve().parents[1] / "static" / "board.css").read_text(encoding="utf-8")
|
||||
block = CALENDAR_PHONE_BLOCK.search(css)
|
||||
assert block, "board.css has no phone block for the calendar"
|
||||
return _rules_in(block.group("body"))
|
||||
body = re.sub(r"/\*.*?\*/", "", block.group("body"), flags=re.DOTALL)
|
||||
rules = []
|
||||
for rule in RULE.finditer(body):
|
||||
for selector in rule.group("selectors").split(","):
|
||||
if selector.strip():
|
||||
rules.append((selector.strip(), rule.group("body")))
|
||||
return rules
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def calendar_base_rules(board_css):
|
||||
"""The calendar's rules outside any media block — everything from the
|
||||
section heading up to the first `@media` after it."""
|
||||
start = board_css.index("--- the private calendar")
|
||||
end = board_css.index("@media", start)
|
||||
return _rules_in(board_css[start:end])
|
||||
|
||||
|
||||
def test_the_month_is_seven_columns_at_every_width(calendar_base_rules,
|
||||
calendar_phone_rules):
|
||||
"""The regression this phase is about, stated as a rule.
|
||||
|
||||
The month was a <table>, and the only way to make a seven-column table
|
||||
legible at 390px was to stop it being one — which turned a calendar into a
|
||||
list of dates, and on the way there produced the specificity bug that drew
|
||||
an empty month as four blank boxes. It is a grid now, and a grid stays a
|
||||
grid: the phone makes the cells smaller and moves the titles out of them,
|
||||
and that is all it is allowed to do.
|
||||
def test_the_padding_cells_are_actually_hidden_on_a_phone(calendar_phone_rules):
|
||||
"""The one that shipped: `.cal td { display: block }` is (0,1,1) and
|
||||
`.cal__pad { display: none }` is (0,1,0), so the padding cells stayed as
|
||||
92px empty boxes — while `.cal__day:not(:has(.cal__event))` at (0,2,0) won
|
||||
and hid every real day. A month with no events drew four blank boxes and
|
||||
nothing else, and the HTML was correct throughout.
|
||||
"""
|
||||
columns = [re.search(r"grid-template-columns\s*:\s*([^;]+)", body).group(1)
|
||||
for selector, body in calendar_base_rules
|
||||
if selector.endswith(".cal__grid") and "grid-template-columns" in body]
|
||||
assert columns, "the base stylesheet never gives .cal__grid its columns"
|
||||
assert "repeat(7," in columns[0].replace(" ", ""), (
|
||||
f"the month is laid out as `{columns[0].strip()}` rather than seven columns")
|
||||
|
||||
for selector, body in calendar_phone_rules:
|
||||
if not selector.endswith(".cal__grid"):
|
||||
continue
|
||||
display = re.search(r"display\s*:\s*([\w-]+)", body)
|
||||
assert not display or display.group(1) == "grid", (
|
||||
f"`{selector}` takes the month off the grid on a phone "
|
||||
f"(`display: {display.group(1)}`), which is how it became a list "
|
||||
"of dates the first time.")
|
||||
assert "grid-template-columns" not in body, (
|
||||
f"`{selector}` changes the number of columns on a phone; a month "
|
||||
"has seven of them at every width.")
|
||||
winner = _winning_display(calendar_phone_rules, {"td.cal__pad", ".cal__pad", "td"})
|
||||
assert winner, "nothing in the phone block decides what a padding cell does"
|
||||
assert winner[2] == "none", (
|
||||
f"a padding cell ends up `display: {winner[2]}` from `{winner[1]}`. "
|
||||
"A rule naming td outranks one naming only the class, so every cell "
|
||||
"belonging to the neighbouring month is drawn as an empty box."
|
||||
)
|
||||
|
||||
|
||||
def test_no_cell_of_the_month_is_hidden_on_a_phone(calendar_phone_rules):
|
||||
"""Neither a day nor a padding cell.
|
||||
|
||||
The day cells are obvious. The padding cells are the ones worth a test:
|
||||
they were `display: none` while the month was a list, and in a grid they
|
||||
are what puts the 1st under its own weekday — hide them and every date in
|
||||
the month lands on the wrong column, which still *looks* like a calendar.
|
||||
"""
|
||||
for compounds, what in ((({"li.cal__day", ".cal__day"}), "a day"),
|
||||
(({"li.cal__pad", ".cal__pad"}), "a padding cell")):
|
||||
winner = _winning_display(calendar_phone_rules, compounds)
|
||||
assert winner is None or winner[2] != "none", (
|
||||
f"{what} ends up hidden on a phone, from `{winner[1]}`.")
|
||||
def test_every_day_of_the_month_is_drawn_on_a_phone(calendar_phone_rules):
|
||||
"""The month is a column of days there, not only the days with something in
|
||||
them: an empty day is how you see the month is empty, and how an admin taps
|
||||
the 14th to put something on it."""
|
||||
winner = _winning_display(calendar_phone_rules, {"td.cal__day", ".cal__day"})
|
||||
assert winner and winner[2] != "none", (
|
||||
f"a day cell ends up hidden on a phone (`{winner[1] if winner else '—'}`)."
|
||||
)
|
||||
|
||||
|
||||
def test_the_weekday_is_hidden_from_the_eye_and_not_from_a_screen_reader(
|
||||
calendar_base_rules):
|
||||
"""A fifty-pixel cell has room for a number and nothing else, so the
|
||||
weekday inside each cell is clipped rather than drawn — the header row says
|
||||
it for anyone who can see it. `display: none` would be the obvious way to
|
||||
do that and the wrong one: it takes the element out of the accessibility
|
||||
tree too, and then «22» is announced as the number 22 with no day attached.
|
||||
"""
|
||||
rules = [(selector, body) for selector, body in calendar_base_rules
|
||||
if selector.strip().endswith(".cal__weekday")]
|
||||
assert rules, "nothing in board.css hides .cal__weekday from the eye"
|
||||
for selector, body in rules:
|
||||
display = re.search(r"display\s*:\s*([\w-]+)", body)
|
||||
assert not display or display.group(1) != "none", (
|
||||
f"`{selector}` uses display:none, which hides the weekday from a "
|
||||
"screen reader as well. Clip it instead.")
|
||||
assert any("clip-path" in body for _, body in rules), (
|
||||
"the weekday is not clipped, so it is drawn inside every cell")
|
||||
|
||||
|
||||
def test_everywhere_a_member_writes_breaks_a_word_too_long_for_its_box(board_css):
|
||||
"""A pasted URL is one word, and `profiles.clean_links` lets it be five
|
||||
hundred characters long.
|
||||
|
||||
`.rich` — the box the text is typed into — has broken long words since the
|
||||
editor shipped; the places that *show* what was typed did not, so a bio
|
||||
looked right while being written and came back out through the side of the
|
||||
card. The two lists are the same list, which is the only reason this is a
|
||||
test rather than a line in the stylesheet nobody reads.
|
||||
"""
|
||||
for selector in (".rich", ".prose", ".person-head__links", ".cal__event"):
|
||||
assert re.search(
|
||||
r"(^|,)\s*" + re.escape(selector) + r"\s*(,[^{]*)?\{[^}]*overflow-wrap",
|
||||
board_css, re.MULTILINE), (
|
||||
f"`{selector}` has no overflow-wrap, so a pasted link leaves the box")
|
||||
def test_the_weekday_shows_on_a_phone(calendar_phone_rules):
|
||||
"""The header row is hidden at that width, and the base stylesheet hides
|
||||
`.cal__weekday` because up there the header says it. If the phone block
|
||||
only restyles it without turning it back on, every row of the month reads
|
||||
as a bare number — which is how it was first rendered."""
|
||||
winner = _winning_display(calendar_phone_rules, {".cal__weekday", "span.cal__weekday"})
|
||||
assert winner and winner[2] != "none", (
|
||||
"the phone block never gives .cal__weekday a display of its own, so the "
|
||||
"base `display: none` stands and the days lose their weekday."
|
||||
)
|
||||
|
||||
|
||||
AGENDA_PHONE_BLOCK = re.compile(
|
||||
|
||||
@ -1034,50 +1034,6 @@ Only *Inicio* remains in `config.yaml`. Weight under 5 puts a menu entry before
|
||||
the pages, 5 or more after them. *Comunidad* used to be the entry at weight 9 and
|
||||
is a button in the bar now — see §11.19.
|
||||
|
||||
### 11.15c Strict reverse-chronological order, in both halves
|
||||
|
||||
Posts came out in the wrong order on the public site and in the editor, from two
|
||||
different causes that look like one bug.
|
||||
|
||||
**On the site: the editor wrote a day with no clock.** `date: 2026-07-31` is
|
||||
byte-identical for everything published that day, so Hugo fell through its sort
|
||||
keys — weight, date, linktitle, filepath — and the day came out **alphabetised
|
||||
by title**. Permanently: a rebuild changes nothing about the files. None of the
|
||||
four post feeds applied an explicit sort either, so all four inherited it.
|
||||
|
||||
Both halves are fixed, and both are needed — a sort cannot break a tie:
|
||||
|
||||
- `apps/board/content.py`'s **`stamp()`** attaches the clock at the moment of
|
||||
publication, in `frontmatter_for`, which every publishing path goes through
|
||||
(the editor, an edit, a moderator approving a proposal). The day is still
|
||||
whoever publishes chose and the URL still carries only the day, so nothing
|
||||
anybody linked to moves. **An edit keeps the time the file already had** as
|
||||
long as the day has not changed — otherwise correcting a typo would carry a
|
||||
year-old post to the top of the home page. That is what the hidden
|
||||
`date_stamped` field in `content_form.html` is for.
|
||||
- **`partials/posts-ordered.html`** returns the order, and the home page, the
|
||||
section list, `llms.txt` and the `BlogPosting` block in `seo-head.html` all
|
||||
call it. `first N` is applied to its result, never to its input: slicing
|
||||
before sorting is how a post falls off the end of its own list.
|
||||
|
||||
Posts written before this keep their bare date and tie with each other, which
|
||||
is right — the time they were published is not recoverable. Saving one attaches
|
||||
a clock.
|
||||
|
||||
**In the members area: no ordering had a tiebreak.** `created_at` is
|
||||
`datetime('now')`, which has one-second resolution, so two rows written in the
|
||||
same second compared equal and SQLite returned them in whatever order it liked
|
||||
— differently on different pages of the same list. Every ordering now ends in
|
||||
the primary key. `activity.py` had it already and was the model.
|
||||
|
||||
Two disagreements went with it: Inicio's wall panel now orders by `pinned` like
|
||||
the wall itself, and its own-submissions panel uses the same state ranking
|
||||
*Publicaciones* does. The two moderation queues stay **oldest-first** on
|
||||
purpose: a queue is not a feed, and work waiting to be done is FIFO.
|
||||
|
||||
The public agenda also sorts a day's events by `event_time`, which the private
|
||||
calendar has done since it was written.
|
||||
|
||||
### 11.15b Two calendars
|
||||
|
||||
**Public events are posts carrying an `event_date`**, with two more fields of
|
||||
@ -1297,45 +1253,6 @@ This is also the shape the EU AI Act's Article 50 asks for — telling people wh
|
||||
they are reading machine-generated material — which is worth knowing for whoever
|
||||
installs this for the second organisation.
|
||||
|
||||
### 11.17c Fijar: what the site and the wall lead with
|
||||
|
||||
**Moderators and above can pin.** Deciding what the association reads first is
|
||||
curation, which is the whole of a moderator's job — `COLLECTIONS["post"]["role"]`
|
||||
has said so since the queue was built, and `board.set_state` now agrees.
|
||||
**Locking a thread still asks for an admin**: it stops named people saying
|
||||
anything more to each other, and that is power over people rather than over
|
||||
content. The two ride one route and the handler asks twice.
|
||||
|
||||
**Several posts can be pinned at once, and the newest pin goes first.** The
|
||||
stored value is therefore a *moment* rather than a flag, in both halves:
|
||||
|
||||
| | Where | What is stored |
|
||||
|---|---|---|
|
||||
| Public post | its own frontmatter, `pinned: '2026-10-13T12:00:00'`, written only when pinned | plus a copy in `content_cache.pinned`, so the editor's list can sort without re-reading every file from the git server |
|
||||
| Wall thread | `threads.pinned` (the flag, since the board shipped) and `threads.pinned_at` | cleared on unpinning, so pinning again puts it where a new pin belongs |
|
||||
|
||||
One key carrying both the flag and the order means `{{ if .Params.pinned }}`
|
||||
still reads as a yes/no while `sort … "Params.pinned" "desc"` puts them in the
|
||||
right order, with no second field to keep in step. `scripts/translate.py`
|
||||
copies the whole frontmatter and rewrites only `TRANSLATED_KEYS`, so a pinned
|
||||
post is pinned in German and Portuguese for free — asserted against the real
|
||||
list rather than assumed.
|
||||
|
||||
**Two ways to pin a public post**: the *Fijar arriba* switch beside *Publicar*
|
||||
in the editor, and a one-press *Fijar* in the *Contenido* list. Both commit —
|
||||
the file in the repository is the record and there is no second store that
|
||||
could disagree with it — and the list one exists because deciding what the site
|
||||
leads with means looking at the list rather than opening each post to find out
|
||||
what is on it. On the wall the same button is on the thread page and on each
|
||||
card.
|
||||
|
||||
**Migration 10** adds the two columns and **recreates `threads_live`**, the
|
||||
wall's index, because it now names `pinned_at`. `CREATE INDEX IF NOT EXISTS` in
|
||||
`schema.sql` leaves an index that already exists exactly as it is, so without
|
||||
that a server that has been running would keep the old definition forever while
|
||||
a fresh install got the new one. Nothing breaks either way — which is the
|
||||
problem: the two stop being the same system, invisibly.
|
||||
|
||||
### 11.18 Marca: the superadministrator owns the look
|
||||
|
||||
*Gestión* → **Marca**, admins only. Colours, a logo and a favicon for both
|
||||
@ -1484,35 +1401,22 @@ In the members area the navigation **wraps** on a phone rather than scrolling:
|
||||
six sections over two lines shows all six, where a swipe strip would have left
|
||||
Calendario and Gestión off the right edge with nothing to say they were there.
|
||||
|
||||
**The private calendar is a seven-column month at every width.** Below 640px
|
||||
the cells shrink to about 50px, the titles come out of them and each day with
|
||||
something in it shows one dot per event and links to that day's block in a list
|
||||
under the grid — an anchor, so it needs no script. Above 640px the titles are
|
||||
in the cells and the list is not drawn. The padding cells belonging to the
|
||||
neighbouring months keep their space at both widths: they are what puts the 1st
|
||||
under its own weekday.
|
||||
**Both calendars become a column of days below 640px** — every day of the month,
|
||||
in order, with its weekday beside it, the days carrying something standing out,
|
||||
and a line saying so when the month is empty. The private one
|
||||
(`/comunidad/calendario`, a `<table>`) and the public agenda (`/page/agenda/`,
|
||||
an `<ol>`) are deliberately the same shape, because the private one lists the
|
||||
public events and a member moves between the two.
|
||||
|
||||
The weekday inside each cell is **clipped rather than `display: none`**, because
|
||||
the header row says it to anyone who can see it and a screen reader still needs
|
||||
«22» to announce itself as a Thursday.
|
||||
|
||||
**It is an `<ol>` on a CSS grid and not a `<table>`, and that is load-bearing.**
|
||||
A table brings `tbody`, `tr` and `td` with it, so every phone rule had to name
|
||||
an element to undo them — and `.cal td` at specificity (0,1,1) outranks
|
||||
`.cal__pad` at (0,1,0). That is exactly what shipped: the padding cells stayed
|
||||
as 92px empty boxes while `.cal__day:not(:has(…))` at (0,2,0) won and hid every
|
||||
real day, so a month with nothing in it drew four empty boxes and nothing else
|
||||
— with correct HTML throughout. A grid has no scaffolding to undo, which is why
|
||||
the public agenda (`/page/agenda/`, an `<ol>` since it was written) never had
|
||||
the bug. `apps/board/tests/test_templates.py` computes specificity and runs the
|
||||
cascade for a day cell, a padding cell and the grid itself, which is as close as
|
||||
pytest gets to looking at a page.
|
||||
|
||||
**A pasted link breaks rather than leaving its box.** `profiles.clean_links`
|
||||
accepts a 500-character label and a URL is one word, so `.prose`,
|
||||
`.person-head__links`, `.cal__event` and `.panel__row` all carry
|
||||
`overflow-wrap: anywhere` — the rule `.rich`, the box the text is *typed* into,
|
||||
has had since the editor shipped. The guard holds the two lists together.
|
||||
Both phone blocks are written so that **every rule deciding `display` names the
|
||||
cell's own class**, and `apps/board/tests/test_templates.py` fails if one does
|
||||
not. That is the shape of the bug it replaces: the calendar's block opened with
|
||||
`.cal td { display: block }` — specificity (0,1,1) — which outranked
|
||||
`.cal__pad { display: none }` at (0,1,0), while `.cal__day:not(:has(…))` at
|
||||
(0,2,0) won and hid every real day. A month with no events therefore drew four
|
||||
empty boxes and nothing else, with correct HTML throughout. The guard computes
|
||||
the specificity and runs the cascade for a padding cell, a day cell and the
|
||||
weekday label, which is as close as pytest gets to looking at a page.
|
||||
|
||||
**Tap targets are raised under `@media (pointer: coarse)`** in both stylesheets,
|
||||
and both blocks are **padding only** — no type size, colour or spacing changes,
|
||||
|
||||
@ -4151,22 +4151,6 @@ a.notif-card__message:hover {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* Fijado. The same pill, in the brand colour rather than in grey: the IA one
|
||||
is a disclosure and recedes, this one is the association saying «read this
|
||||
first» and should carry the weight of having been chosen. */
|
||||
.tag-pin {
|
||||
display: inline-block;
|
||||
padding: 2px 8px;
|
||||
border: 1px solid var(--brand, #c0391c);
|
||||
border-radius: 999px;
|
||||
background: var(--brand-softer, #fdf1ee);
|
||||
color: var(--brand-dark, #90290f);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.02em;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* --- sharing ------------------------------------------------------------
|
||||
*
|
||||
* A tinted strip rather than six bare icons: the row has to be noticed to be
|
||||
|
||||
@ -3,12 +3,11 @@
|
||||
<main class="feed">
|
||||
<h1 class="feed__title">{{ .Title }}</h1>
|
||||
|
||||
{{ range partial "posts-ordered.html" .Pages }}
|
||||
{{ range .Pages }}
|
||||
<article class="article-card">
|
||||
<div class="article-card__meta">
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 Jan 2006" }}</time>
|
||||
{{ if .Params.ai_generated }}<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" .Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
||||
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
||||
</div>
|
||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||
<p class="article-card__excerpt">{{ .Description | default (.Summary | plainify | truncate 200) }}</p>
|
||||
|
||||
@ -35,9 +35,6 @@
|
||||
{{ if .Params.ai_generated }}
|
||||
<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" .Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}</span>
|
||||
{{ end }}
|
||||
{{/* And whether somebody put it at the top on purpose, so a reader
|
||||
arriving from the home page knows why it was first. */}}
|
||||
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@ -1,12 +1,11 @@
|
||||
{{/* Home: feed of recent articles in the current language. */}}
|
||||
{{ define "main" }}
|
||||
<main class="feed">
|
||||
{{ range first 20 (partial "posts-ordered.html" (where .Site.RegularPages "Section" "post")) }}
|
||||
{{ range first 20 (where .Site.RegularPages "Section" "post") }}
|
||||
<article class="article-card">
|
||||
<div class="article-card__meta">
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 Jan 2006" }}</time>
|
||||
{{ if .Params.ai_generated }}<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" .Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
||||
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
||||
</div>
|
||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||
<p class="article-card__excerpt">{{ .Description | default (.Summary | plainify | truncate 200) }}</p>
|
||||
|
||||
@ -13,6 +13,6 @@ This site publishes in Spanish. Every article has server-rendered German (/de/)
|
||||
{{ end }}
|
||||
## Recent articles
|
||||
|
||||
{{ range first 50 (partial "posts-ordered.html" (where .Site.RegularPages "Section" "post")) -}}
|
||||
{{ range first 50 (where .Site.RegularPages "Section" "post") -}}
|
||||
- [{{ .Title }}]({{ .Permalink }}): {{ .Description | default (.Summary | plainify | truncate 200) }}
|
||||
{{ end -}}
|
||||
|
||||
@ -79,14 +79,7 @@
|
||||
{{ if gt $lead 0 }}{{ range seq $lead }}<li class="agenda__pad" aria-hidden="true"></li>{{ end }}{{ end }}
|
||||
{{ range $day := seq 1 $days }}
|
||||
{{ $date := printf "%s-%02d" $key $day }}
|
||||
{{/* By the hour, so two things on one day read in the order they
|
||||
happen rather than in the order they were announced. The
|
||||
private calendar has sorted this way since it was written
|
||||
(apps/board/events.py: `ORDER BY starts_on, COALESCE(starts_at,
|
||||
'99:99')`), and the two show the same events to the same
|
||||
people. An event with no time sorts first here, which is right:
|
||||
all day begins before the evening does. */}}
|
||||
{{ $onThisDay := sort (where $events "Params.event_date" $date) "Params.event_time" }}
|
||||
{{ $onThisDay := where $events "Params.event_date" $date }}
|
||||
{{/* The column a day falls in is its weekday, Monday first — the
|
||||
same arithmetic the padding above is made of. On a phone the
|
||||
grid becomes one day per row, where a column position says
|
||||
|
||||
@ -1,31 +0,0 @@
|
||||
{{/*
|
||||
The order every list of posts on this site is in, in one place.
|
||||
|
||||
Call it with the pages and range over what comes back:
|
||||
|
||||
{{ range first 20 (partial "posts-ordered.html" (where site.RegularPages "Section" "post")) }}
|
||||
{{ range partial "posts-ordered.html" .Pages }}
|
||||
|
||||
Four lists used to range over the pages with no sort at all and lean on
|
||||
Hugo's default, which is weight, then date, then linktitle, then filepath.
|
||||
That is fine until two posts share a date — and until this phase the editor
|
||||
wrote `date: 2026-07-31` with no clock, so every post published on one day
|
||||
was identical in it and Hugo fell through to the title. A day came out
|
||||
alphabetised, permanently, because nothing about the files changed on a
|
||||
rebuild. The editor stamps the time now (apps/board/content.py, `stamp`),
|
||||
and this is the other half: the order is stated rather than inherited, so a
|
||||
weight somebody adds by hand cannot quietly reorder the home page.
|
||||
|
||||
`first N` applied to the result slices something already ordered. Applied
|
||||
to the input it would slice first and sort afterwards, which is how a
|
||||
pinned post falls off the end of its own list.
|
||||
|
||||
The pinned ones go on top, newest pin first. `pinned` holds the moment it
|
||||
was pinned rather than `true`, so one key is both the flag and the order —
|
||||
there is no second field to keep in step with the first. Two sorts appended
|
||||
rather than one multi-key sort, so this does not depend on Hugo's sort being
|
||||
stable.
|
||||
*/}}
|
||||
{{ $pinned := where . "Params.pinned" "!=" nil }}
|
||||
{{ $rest := where . "Params.pinned" nil }}
|
||||
{{ return (append (sort $rest "Date" "desc") (sort $pinned "Params.pinned" "desc")) }}
|
||||
@ -205,7 +205,7 @@
|
||||
{{ with .Site.Params.sameAs }}{{ $org = merge $org (dict "sameAs" .) }}{{ end }}
|
||||
<script type="application/ld+json">{{ $org | jsonify (dict "indent" " ") | safeJS }}</script>
|
||||
|
||||
{{ $posts := first 10 (partial "posts-ordered.html" (where .Site.RegularPages "Section" "post")) }}
|
||||
{{ $posts := first 10 (where .Site.RegularPages "Section" "post") }}
|
||||
{{ $blogPost := slice }}
|
||||
{{ range $posts }}
|
||||
{{ $entry := dict
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
"noevents" (dict "es" "No hay nada en este mes." "de" "In diesem Monat ist nichts geplant." "pt-br" "Nada marcado neste mês.")
|
||||
"allevents" (dict "es" "Todos los eventos" "de" "Alle Termine" "pt-br" "Todos os eventos")
|
||||
"ai" (dict "es" "Generado con IA" "de" "Mit KI erstellt" "pt-br" "Gerado com IA")
|
||||
"pinned" (dict "es" "Fijado" "de" "Angeheftet" "pt-br" "Fixado")
|
||||
"share" (dict "es" "Compartir" "de" "Teilen" "pt-br" "Compartilhar")
|
||||
"copylink" (dict "es" "Copiar enlace" "de" "Link kopieren" "pt-br" "Copiar link")
|
||||
"copied" (dict "es" "Enlace copiado" "de" "Link kopiert" "pt-br" "Link copiado")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user