diff --git a/apps/board/app.py b/apps/board/app.py
index bdb1a09..8f9d53d 100644
--- a/apps/board/app.py
+++ b/apps/board/app.py
@@ -13,7 +13,7 @@ from datetime import datetime, timezone
from flask import Flask, render_template, request
from werkzeug.middleware.proxy_fix import ProxyFix
-from .db import close_db, init_db
+from .db import TOMBSTONE_LOGIN, close_db, init_db
from .security import check_csrf, csrf_token
URL_PREFIX = "/comunidad"
@@ -94,10 +94,11 @@ def create_app(overrides: dict | None = None) -> Flask:
# restart, which is a confusing way to find out the variable is unset.
raise RuntimeError("BOARD_SECRET_KEY is required (generate one with `openssl rand -hex 32`).")
- from . import (auth, board, content, events, home, members, messages,
- profiles, submissions, uploads)
+ from . import (auth, board, brand, content, events, home, members,
+ messages, profiles, submissions, uploads)
app.register_blueprint(auth.bp, url_prefix=URL_PREFIX)
app.register_blueprint(home.bp, url_prefix=URL_PREFIX)
+ app.register_blueprint(brand.bp, url_prefix=URL_PREFIX)
app.register_blueprint(submissions.bp, url_prefix=URL_PREFIX)
app.register_blueprint(events.bp, url_prefix=URL_PREFIX)
app.register_blueprint(members.bp, url_prefix=URL_PREFIX)
@@ -114,11 +115,21 @@ def create_app(overrides: dict | None = None) -> Flask:
app.teardown_appcontext(close_db)
app.jinja_env.globals["csrf_token"] = csrf_token
app.jinja_env.globals["url_prefix"] = URL_PREFIX
+ # For _person.html: the one login with no page behind it. A literal in the
+ # template would be the same string written twice, in two languages.
+ app.jinja_env.globals["tombstone_login"] = TOMBSTONE_LOGIN
@app.context_processor
def _year():
return {"current_year": datetime.now(timezone.utc).year}
+ @app.context_processor
+ def _brand():
+ # Not lazy, unlike the badges below: base.html draws the stylesheet
+ # link, the logo and the favicon on every page, so there is no render
+ # that would save the query by deferring it.
+ return {"brand": brand.state()}
+
@app.context_processor
def _badges():
# Lazily, as functions: base.html is rendered for signed-out pages and
diff --git a/apps/board/brand.py b/apps/board/brand.py
new file mode 100644
index 0000000..8b84ea5
--- /dev/null
+++ b/apps/board/brand.py
@@ -0,0 +1,613 @@
+"""The look of both halves of the site, owned by the admin rather than by me.
+
+Until this existed, the brand colours were two identical `:root` blocks — one in
+`themes/vienalatina/assets/css/main.css`, one in `apps/board/static/board.css` —
+with a comment in the second saying *"If the brand colours change, change them
+in both."* There was no logo anywhere and no favicon in either `
`. Every
+one of those is a change only somebody with the repository could make.
+
+**The dictionary below is now the single source of truth for the palette**, and
+`apps/board/tests/test_brand.py` parses both stylesheets and fails if either
+drifts from it. That is what retires the comment: not by merging the two files —
+they are served by different things and each has to stand on its own — but by
+making a divergence fail the build instead of going unnoticed for a month.
+
+### The two destinations
+
+One form, saved to two places, because the two halves cannot read the same
+store:
+
+* **SQLite**, for the members area, which must render correctly when the git
+ server is unreachable — the same rule the private calendar follows.
+* **Git** (`data/brand.yaml` and `static/brand/…`), for the public site, which
+ is files on disk built by Hugo and has no database to read.
+
+SQLite is written first and the commits follow. If Gitea is down the change
+still takes effect here, the row keeps `published_at` NULL, and the screen says
+so with a button to try the publish again. The other order would let a git
+outage block a change that does not need git.
+
+### Why the custom CSS is a file and not a `",
+ follow_redirects=True)
+
+ assert "no puede contener" in response.get_data(as_text=True)
+ assert db.execute("SELECT COUNT(*) AS n FROM brand").fetchone()["n"] == 0
+
+
+def test_an_enormous_css_box_is_refused(client, db, post, admin):
+ response = save(post, custom_css="a{}" * 20_000, follow_redirects=True)
+
+ assert "caracteres" in response.get_data(as_text=True)
+ assert db.execute("SELECT COUNT(*) AS n FROM brand").fetchone()["n"] == 0
+
+
+def test_the_screen_never_loads_the_custom_css(client, post, admin):
+ """The reason an admin can always undo a mistake: `* { display: none }` in
+ the box breaks every page except this one."""
+ save(post, custom_css="* { display: none }")
+
+ page = client.get("/comunidad/gestion/marca").get_data(as_text=True)
+ other = client.get("/comunidad/gestion").get_data(as_text=True)
+
+ assert "marca.css" not in page
+ assert "marca.css" in other
+ assert "Restaurar lo de fábrica" in page
+
+
+# --- the two pictures -----------------------------------------------------
+
+def test_a_logo_is_sniffed_not_trusted(client, db, post, admin):
+ """The same check as every other upload: the extension comes from the
+ bytes. A GIF called logo.png is a GIF."""
+ response = save(post, logo=(io.BytesIO(GIF), "logo.png"),
+ content_type="multipart/form-data", follow_redirects=True)
+
+ assert "es un gif" in response.get_data(as_text=True)
+ assert db.execute("SELECT COUNT(*) AS n FROM brand").fetchone()["n"] == 0
+
+
+def test_a_png_logo_is_kept_and_served(app, client, db, post, admin):
+ save(post, logo=(io.BytesIO(PNG), "vienalatina.png"),
+ content_type="multipart/form-data")
+
+ name = db.execute("SELECT logo_name FROM brand").fetchone()["logo_name"]
+ assert name and name.endswith(".png")
+ with app.app_context():
+ from apps.board import uploads
+ assert uploads.directory().joinpath(name).exists()
+
+ # Public on purpose: it is in the of the sign-in page.
+ client.get("/comunidad/logout")
+ assert client.get(f"/comunidad/marca/{name}").status_code == 200
+
+
+def test_a_picture_that_is_not_the_current_one_is_not_served(client, db, post, admin):
+ save(post, logo=(io.BytesIO(PNG), "uno.png"), content_type="multipart/form-data")
+ first = db.execute("SELECT logo_name FROM brand").fetchone()["logo_name"]
+
+ save(post, logo=(io.BytesIO(PNG), "dos.png"), content_type="multipart/form-data")
+
+ assert client.get(f"/comunidad/marca/{first}").status_code == 404
+
+
+def test_a_replaced_logo_goes_off_disk(app, client, db, post, admin):
+ save(post, logo=(io.BytesIO(PNG), "uno.png"), content_type="multipart/form-data")
+ first = db.execute("SELECT logo_name FROM brand").fetchone()["logo_name"]
+
+ save(post, logo=(io.BytesIO(PNG), "dos.png"), content_type="multipart/form-data")
+
+ with app.app_context():
+ from apps.board import uploads
+ assert not uploads.directory().joinpath(first).exists()
+
+
+def test_the_favicon_is_png_only(client, db, post, admin):
+ """ICO and SVG are both refused, for different reasons: the sniffer
+ identifies bytes by a prefix and an SVG is XML that can carry script."""
+ response = save(post, favicon=(io.BytesIO(GIF), "icono.gif"),
+ content_type="multipart/form-data", follow_redirects=True)
+
+ assert "hace falta png" in response.get_data(as_text=True)
+ assert db.execute("SELECT COUNT(*) AS n FROM brand").fetchone()["n"] == 0
+
+
+def test_the_logo_and_the_favicon_reach_the_chrome(client, post, admin):
+ save(post, logo=(io.BytesIO(PNG), "logo.png"),
+ favicon=(io.BytesIO(PNG), "icono.png"),
+ content_type="multipart/form-data")
+
+ body = client.get("/comunidad/").get_data(as_text=True)
+
+ assert "site-bar__logo" in body
+ assert 'rel="icon"' in body
+ assert "site-bar__brand-text" not in body
+
+
+# --- publishing to the public site ----------------------------------------
+
+@pytest.fixture(autouse=True)
+def unreachable(monkeypatch):
+ """No test in this file talks to a real git server.
+
+ Autouse and not optional: every save tries to publish, so without this each
+ one would open a socket to git.vienalatina.com and wait for it to fail. The
+ tests that care about the commit ask for `repo` as well, whose patches are
+ applied after these and therefore win.
+ """
+ def refuse(*args, **kwargs):
+ raise brand.gitea.GiteaError("No se pudo contactar con el servidor de git.")
+ for name in ("list_directory", "read_file", "write_file", "delete_file"):
+ monkeypatch.setattr(brand.gitea, name, refuse)
+
+
+def test_the_commit_carries_the_colours_and_the_pictures(db, post, admin, repo):
+ save(post, **{"token-brand": "#1b5e20", "custom_css": ".x { color: red }"},
+ logo=(io.BytesIO(PNG), "vienalatina.png"),
+ favicon=(io.BytesIO(PNG), "icono.png"),
+ content_type="multipart/form-data")
+
+ assert set(repo.files) == {"data/brand.yaml",
+ "static/brand/logo.png",
+ "static/brand/favicon.png"}
+ yaml = repo.files["data/brand.yaml"].decode("utf-8")
+ assert ' brand: "#1b5e20"' in yaml
+ assert 'logo: "/brand/logo.png"' in yaml # the path Hugo serves it at
+ assert 'favicon: "/brand/favicon.png"' in yaml
+ assert "custom_css: |\n .x { color: red }" in yaml
+ # Only the differences, exactly as the stylesheet does it.
+ assert "surface:" not in yaml
+ assert db.execute("SELECT published_at FROM brand").fetchone()["published_at"]
+
+
+def test_a_logo_in_another_format_does_not_leave_the_old_one_behind(post, admin, repo):
+ """`static/brand/logo.png` and `logo.webp` would otherwise both sit in the
+ repository, deployed, with only one of them referenced."""
+ save(post, logo=(io.BytesIO(PNG), "uno.png"), content_type="multipart/form-data")
+ assert "static/brand/logo.png" in repo.files
+
+ webp = b"RIFF\x00\x00\x00\x00WEBP" + b"\x00" * 64
+ save(post, logo=(io.BytesIO(webp), "dos.webp"), content_type="multipart/form-data")
+
+ assert "static/brand/logo.webp" in repo.files
+ assert "static/brand/logo.png" not in repo.files
+
+
+def test_a_save_survives_the_git_server_being_down(client, db, post, admin):
+ """The order this is written in. SQLite first, so a change that does not
+ need git is not blocked by git — and the screen says the public site is a
+ step behind rather than pretending it is not."""
+ response = save(post, **{"token-brand": "#1b5e20"}, follow_redirects=True)
+
+ row = db.execute("SELECT tokens_json, published_at FROM brand").fetchone()
+ assert json.loads(row["tokens_json"]) == {"brand": "#1b5e20"}
+ assert row["published_at"] is None
+ assert "Pendiente de publicar" in response.get_data(as_text=True)
+ assert "--brand: #1b5e20;" in client.get("/comunidad/marca.css").get_data(as_text=True)
+
+
+def test_the_retry_publishes_what_was_already_saved(db, post, admin, monkeypatch, repo):
+ """What the *Reintentar publicar* button is for: the colours are in SQLite
+ and the commit never happened."""
+ def refuse(*args, **kwargs):
+ raise brand.gitea.GiteaError("caído")
+
+ # Only the write, and put it back by hand rather than with
+ # `monkeypatch.undo()` — which would also undo the `repo` fixture's own
+ # patches and leave the retry talking to the real git server.
+ working = brand.gitea.write_file
+ monkeypatch.setattr(brand.gitea, "write_file", refuse)
+ save(post, **{"token-brand": "#1b5e20"})
+ assert db.execute("SELECT published_at FROM brand").fetchone()["published_at"] is None
+
+ monkeypatch.setattr(brand.gitea, "write_file", working)
+ post("/comunidad/gestion/marca/publicar")
+
+ assert ' brand: "#1b5e20"' in repo.files["data/brand.yaml"].decode("utf-8")
+ assert db.execute("SELECT published_at FROM brand").fetchone()["published_at"]
+
+
+# --- restoring ------------------------------------------------------------
+
+def test_restoring_empties_the_row_and_the_disk(app, client, db, post, admin):
+ save(post, **{"token-brand": "#1b5e20"}, )
+ save(post, logo=(io.BytesIO(PNG), "logo.png"), content_type="multipart/form-data")
+ name = db.execute("SELECT logo_name FROM brand").fetchone()["logo_name"]
+
+ post("/comunidad/gestion/marca/restaurar")
+
+ assert db.execute("SELECT COUNT(*) AS n FROM brand").fetchone()["n"] == 0
+ with app.app_context():
+ from apps.board import uploads
+ assert not uploads.directory().joinpath(name).exists()
+ css = client.get("/comunidad/marca.css").get_data(as_text=True)
+ assert ":root" not in css # nothing to override any more
+ assert "site-bar__brand-text" in client.get("/comunidad/").get_data(as_text=True)
+
+
+# --- erasure --------------------------------------------------------------
+
+def test_erasing_the_admin_leaves_the_brand_standing(client, db, post, owner_id,
+ make_member, sign_in):
+ """The colours belong to the association, like an event in the calendar.
+ An admin leaving is not a reason for the site to look like a default
+ install again."""
+ admin_id = make_member("admina", role="admin")
+ sign_in(admin_id)
+ save(post, **{"token-brand": "#1b5e20"})
+
+ sign_in(owner_id)
+ post(f"/comunidad/miembros/{admin_id}/eliminar")
+
+ row = db.execute("SELECT tokens_json, updated_by FROM brand").fetchone()
+ assert json.loads(row["tokens_json"]) == {"brand": "#1b5e20"}
+ assert row["updated_by"] is None
diff --git a/apps/board/tests/test_content.py b/apps/board/tests/test_content.py
index 083a628..bd112c7 100644
--- a/apps/board/tests/test_content.py
+++ b/apps/board/tests/test_content.py
@@ -9,7 +9,6 @@ import the real translate.py and run its parser over what the editor wrote.
from __future__ import annotations
-import hashlib
import importlib.util
import io
import sys
@@ -18,6 +17,7 @@ from pathlib import Path
import pytest
from apps.board import content, gitea
+from apps.board.tests.conftest import FakeRepo # noqa: F401 (used by the `repo` fixture)
REPO_ROOT = Path(__file__).resolve().parents[3]
@@ -35,54 +35,6 @@ def _load_translate():
translate = _load_translate()
-class FakeRepo:
- """A repository in a dict, with shas that change when content does."""
-
- def __init__(self):
- self.files: dict[str, bytes] = {}
- self.commits: list[str] = []
- self.authors: list[dict] = []
- self.reads = 0
-
- @staticmethod
- def _sha(data: bytes) -> str:
- return hashlib.sha1(data).hexdigest()
-
- def list_directory(self, path, token=None):
- out = []
- for name, data in self.files.items():
- if name.startswith(path + "/") and "/" not in name[len(path) + 1:]:
- out.append({"name": name.rsplit("/", 1)[1], "path": name,
- "type": "file", "sha": self._sha(data)})
- return out
-
- def read_file(self, path, token=None):
- self.reads += 1
- if path not in self.files:
- raise gitea.GiteaError("Ese archivo ya no existe.")
- return self.files[path].decode("utf-8"), self._sha(self.files[path])
-
- def write_file(self, path, data, message, token=None, sha=None, member=None):
- if sha and self.files.get(path) is not None and self._sha(self.files[path]) != sha:
- raise gitea.StaleFile("Alguien más guardó este archivo mientras lo editabas.")
- self.files[path] = data
- self.commits.append(message)
- self.authors.append(gitea._identity(member))
- return self._sha(data)
-
- def delete_file(self, path, sha, message, token=None, member=None):
- self.files.pop(path, None)
- self.commits.append(message)
-
-
-@pytest.fixture
-def repo(monkeypatch):
- fake = FakeRepo()
- for name in ("list_directory", "read_file", "write_file", "delete_file"):
- monkeypatch.setattr(gitea, name, getattr(fake, name))
- return fake
-
-
@pytest.fixture
def editor(db, make_member, sign_in):
"""An admin. The editor commits through the server's own content token
diff --git a/apps/board/tests/test_members.py b/apps/board/tests/test_members.py
index 0e3b603..1bb4c2f 100644
--- a/apps/board/tests/test_members.py
+++ b/apps/board/tests/test_members.py
@@ -180,19 +180,26 @@ def test_erasing_a_member_keeps_their_threads_readable(app, db, post, owner_id,
assert row["display_name"] == "Miembro eliminado"
-def test_the_member_list_renders_for_each_role(client, db, owner_id, make_member, sign_in):
- """Every role takes a different branch through members.html — the owner
- sees transfer and erase, an admin sees suspend, a user sees neither — so
- each one is rendered here rather than trusted."""
+def test_the_member_page_renders_for_each_role(client, db, owner_id, make_member, sign_in):
+ """Every role takes a different branch through member.html — the owner sees
+ transfer and erase, an admin sees suspend, a plain member sees neither — so
+ each one is rendered here rather than trusted.
+
+ These controls used to be on the cards in the directory and are on the
+ person's page now, which is what this looks at. The owner's branch needs an
+ admin to transfer to, so the page opened is the admin's.
+ """
admin_id = make_member("admina", role="admin")
- user_id = make_member("usuaria")
for member_id, expected in ((owner_id, "Transferir titularidad"),
(admin_id, "Suspender"),
- (user_id, None)):
+ (make_member("usuaria"), None)):
sign_in(member_id)
- body = client.get("/comunidad/miembros").get_data(as_text=True)
- assert "usuaria" in body
+ # Never your own page: nobody manages themselves, so the block is not
+ # drawn there and the test would pass for the wrong reason.
+ who = "usuaria" if member_id == admin_id else "admina"
+ body = client.get(f"/comunidad/miembro/{who}").get_data(as_text=True)
+ assert who.title() in body
if expected:
assert expected in body
else:
@@ -353,15 +360,16 @@ def test_erasing_a_member_lets_the_name_be_used_again(
"SELECT 1 FROM members WHERE gitea_login = 'salvador'").fetchone() is not None
-# --- the directory --------------------------------------------------------
+# --- the directory and the page -------------------------------------------
#
# Miembros used to be a five-column admin table whose last column held four
-# forms, wrapping on top of each other. It is a directory now: everybody sees
-# the people, admins open a per-card block for the controls. Both halves are
-# asserted, because "the table is gone" is only an improvement if the controls
-# came with it.
+# forms, wrapping on top of each other; then it was cards, each carrying a bio,
+# some links and a fold-out admin block. It is faces and names now, and
+# everything about one person — their profile, the conversation with them, and
+# the controls — is on their own page. Both halves are asserted, because "the
+# cards are simpler" is only an improvement if nothing was lost on the way.
-def test_everybody_sees_the_people(client, db, make_member, sign_in):
+def test_the_directory_is_faces_and_names(client, db, make_member, sign_in):
maria = make_member("maria")
db.execute("UPDATE members SET bio = ? WHERE id = ?",
("Vivo en Ottakring.\nSegunda línea.", maria))
@@ -370,33 +378,57 @@ def test_everybody_sees_the_people(client, db, make_member, sign_in):
body = client.get("/comunidad/miembros").get_data(as_text=True)
assert "Maria" in body and "maria" in body
+ assert "/comunidad/miembro/maria" in body # the card is the way in
+ # The bio is on their page. A grid whose job is to let you find one person
+ # should not be four lines of reading each.
+ assert "Vivo en Ottakring." not in body
+
+
+def test_their_page_is_who_they_are_and_where_you_write(client, db, make_member, sign_in):
+ maria = make_member("maria")
+ db.execute("UPDATE members SET bio = ?, links = ? WHERE id = ?",
+ ("Vivo en Ottakring.", '[{"label": "Mi web", "url": "https://ejemplo.at"}]',
+ maria))
+ sign_in(make_member("otra"))
+
+ body = client.get("/comunidad/miembro/maria").get_data(as_text=True)
+
assert "Vivo en Ottakring." in body
- assert "Segunda línea." not in body # the first line only, as a summary
- assert f'/comunidad/privados/con/{maria}' in body # somewhere to write from
+ assert 'href="https://ejemplo.at"' in body and 'rel="nofollow noopener"' in body
+ assert f'action="/comunidad/privados/con/{maria}"' in body # the write box
+ assert "No ha publicado una página pública." in body
def test_a_plain_member_sees_no_controls_and_no_addresses(client, make_member, sign_in):
make_member("maria")
sign_in(make_member("otra"))
- body = client.get("/comunidad/miembros").get_data(as_text=True)
-
- for control in ("Gestionar", "Suspender", "Cambiar rol", "Eliminar",
- "Enviar invitación", "maria@example.com"):
- assert control not in body, control
+ for url in ("/comunidad/miembros", "/comunidad/miembro/maria"):
+ body = client.get(url).get_data(as_text=True)
+ for control in ("Gestionar", "Suspender", "Cambiar rol", "Eliminar",
+ "Enviar invitación", "maria@example.com"):
+ assert control not in body, f"{control} in {url}"
def test_an_admin_keeps_every_control(client, make_member, sign_in):
make_member("maria")
sign_in(make_member("admina", role="admin"))
- body = client.get("/comunidad/miembros").get_data(as_text=True)
+ body = client.get("/comunidad/miembro/maria").get_data(as_text=True)
for control in ("Gestionar", "Suspender", "Cambiar rol", "Enviar invitación",
"maria@example.com"):
assert control in body, control
assert "Eliminar" not in body # erasure is the owner's alone
+ # And none of it leaks back onto the directory, which is where it was.
+ # Asserted on the forms rather than the words: the grid's footnote says in
+ # so many words that the controls are under «Gestionar» on each page, which
+ # is the sentence that sends an admin to the right place.
+ grid = client.get("/comunidad/miembros").get_data(as_text=True)
+ assert "/estado" not in grid and "/rol" not in grid
+ assert "maria@example.com" not in grid
+
def test_a_photo_shows_inside_even_when_the_page_is_not_published(
app, client, db, make_member, sign_in):
@@ -430,3 +462,18 @@ def test_the_members_area_photo_needs_a_session(app, client, db, make_member):
assert response.status_code == 302
assert "/login" in response.headers["Location"]
+
+
+def test_a_moderator_gets_no_controls_either(client, make_member, sign_in):
+ """A moderator curates content, not people. The block is hidden from them
+ and the routes refuse them, which is the half that matters."""
+ maria = make_member("maria")
+ sign_in(make_member("luisa", role="moderator"))
+
+ body = client.get("/comunidad/miembro/maria").get_data(as_text=True)
+ assert "Gestionar" not in body
+
+ assert client.get("/comunidad/miembros/nuevo").status_code == 403
+ assert client.post(f"/comunidad/miembros/{maria}/estado",
+ data={"csrf_token": "token-for-tests", "active": "0"}
+ ).status_code == 403
diff --git a/apps/board/tests/test_messages.py b/apps/board/tests/test_messages.py
index b67de82..afd644b 100644
--- a/apps/board/tests/test_messages.py
+++ b/apps/board/tests/test_messages.py
@@ -1,12 +1,17 @@
"""Private messages, unread marks and blocking.
-A conversation is addressed by the person, not by an id: `/privados/con/`
-is "what I have said to them and they to me", and it exists as a page before it
-exists as a row. That makes the access rule structural rather than checked — a
-lookup is always scoped to the member doing the looking, so there is no query
-that could return somebody else's correspondence. The tests below still come at
-it from the outside, because the failure mode here is not an error, it is
-somebody quietly reading what is not theirs.
+A conversation is addressed by the person and read on their page:
+`/comunidad/miembro/` is "who they are, and what I have said to them
+and they to me", and it exists as a page before it exists as a row. That makes
+the access rule structural rather than checked — a lookup is always scoped to
+the member doing the looking, so there is no query that could return somebody
+else's correspondence. The tests below still come at it from the outside,
+because the failure mode here is not an error, it is somebody quietly reading
+what is not theirs.
+
+Sending is a POST of its own (`/privados/con/`), which is why the two
+helpers below are separate: `page` is where a conversation is read, `send` is
+the only thing that writes to one.
"""
from __future__ import annotations
@@ -17,7 +22,13 @@ from pathlib import Path
PNG = b"\x89PNG\r\n\x1a\n" + b"\x00" * 64
-def talk(member_id: int) -> str:
+def page(login: str) -> str:
+ """Where the conversation with somebody is read: their page."""
+ return f"/comunidad/miembro/{login}"
+
+
+def send(member_id: int) -> str:
+ """Where a message is posted. By id, as the form on that page does."""
return f"/comunidad/privados/con/{member_id}"
@@ -27,49 +38,50 @@ def test_a_third_person_sees_their_own_empty_conversation(
client, post, make_member, sign_in):
"""The old design gave conversations their own ids, so this test had to
check that a stranger opening one got a 404. Addressing by person removes
- the question: `/privados/con/` means *my* conversation with José, so
- a third person opening the same URL sees an empty page, not this one."""
+ the question: José's page shows *my* conversation with José, so a third
+ person opening the same URL sees his page with an empty conversation on it,
+ not this one."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Algo privado"})
+ post(send(jose), {"body": "Algo privado"})
sign_in(make_member("curiosa"))
- page = client.get(talk(jose))
+ response = client.get(page("jose"))
- assert page.status_code == 200
- assert "Algo privado" not in page.get_data(as_text=True)
+ assert response.status_code == 200
+ assert "Algo privado" not in response.get_data(as_text=True)
def test_writing_to_somebody_does_not_join_you_to_their_other_conversations(
client, db, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Para José"})
+ post(send(jose), {"body": "Para José"})
curiosa = make_member("curiosa")
sign_in(curiosa)
- post(talk(jose), {"body": "Para José también"})
+ post(send(jose), {"body": "Para José también"})
# Two separate conversations, and neither shows the other's messages.
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 2
- assert "Para José" not in client.get(talk(jose)).get_data(as_text=True).replace(
+ assert "Para José" not in client.get(page("jose")).get_data(as_text=True).replace(
"Para José también", "")
def test_the_two_parties_see_it(client, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Hola José"})
+ post(send(jose), {"body": "Hola José"})
sign_in(jose)
- assert "Hola José" in client.get(talk(maria)).get_data(as_text=True)
+ assert "Hola José" in client.get(page("maria")).get_data(as_text=True)
def test_writing_twice_reuses_the_one_conversation(client, db, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Una"})
- post(talk(jose), {"body": "Dos"})
+ post(send(jose), {"body": "Una"})
+ post(send(jose), {"body": "Dos"})
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 1
assert db.execute("SELECT COUNT(*) AS n FROM messages").fetchone()["n"] == 2
@@ -84,63 +96,108 @@ def test_the_box_is_there_before_anything_has_been_said(
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- page = client.get(talk(jose))
+ response = client.get(page("jose"))
- assert page.status_code == 200
- body = page.get_data(as_text=True)
+ assert response.status_code == 200
+ body = response.get_data(as_text=True)
assert 'name="body"' in body # the textarea, on first arrival
assert "Todavía no os habéis escrito" in body
def test_merely_looking_creates_nothing(client, db, make_member, sign_in):
- """Otherwise the inbox fills with "Sin mensajes todavía" for every name
- somebody was curious about."""
+ """Looking at somebody's page is not writing to them, and a directory of
+ faces means a page gets opened out of curiosity all the time."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- client.get(talk(jose))
+ client.get(page("jose"))
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 0
-def test_the_picker_sends_you_straight_there(client, make_member, sign_in):
+# --- the addresses that moved ---------------------------------------------
+
+def test_the_old_section_still_leads_somewhere(client, make_member, sign_in):
+ """*Privados* was a section for months. A bookmark to it lands on the
+ directory rather than on a 404."""
+ sign_in(make_member("maria"))
+
+ response = client.get("/comunidad/privados")
+
+ assert response.status_code == 302
+ assert response.headers["Location"].endswith("/comunidad/miembros")
+
+
+def test_an_old_conversation_link_lands_on_the_person(client, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- response = client.get(f"/comunidad/privados/con?member_id={jose}")
+ response = client.get(f"/comunidad/privados/con/{jose}")
assert response.status_code == 302
- assert response.headers["Location"].endswith(f"/privados/con/{jose}")
+ assert response.headers["Location"].endswith("/comunidad/miembro/jose")
-def test_you_cannot_write_to_yourself(client, make_member, sign_in):
+def test_your_own_page_has_no_conversation_on_it(client, make_member, sign_in):
+ """It is a real page — it is how you see what the others see — but there is
+ nothing to say to yourself and nothing to mark read."""
maria = make_member("maria")
sign_in(maria)
- assert client.get(talk(maria)).status_code == 400
+
+ body = client.get(page("maria")).get_data(as_text=True)
+
+ assert 'name="body"' not in body
+ assert "Esta es tu ficha" in body
-def test_you_cannot_write_to_somebody_who_is_not_a_member(client, make_member, sign_in):
+def test_you_cannot_write_to_yourself(client, post, make_member, sign_in):
+ maria = make_member("maria")
+ sign_in(maria)
+ assert post(send(maria), {"body": "Hola yo"}).status_code == 400
+
+
+def test_you_cannot_write_to_somebody_who_is_not_a_member(
+ client, post, make_member, sign_in):
sign_in(make_member("maria"))
- assert client.get(talk(9999)).status_code == 404
+ assert post(send(9999), {"body": "Hola"}).status_code == 404
+ assert client.get(page("nadie")).status_code == 404
# --- unread ---------------------------------------------------------------
def test_unread_is_per_member_and_clears_on_reading(client, post, make_member, sign_in):
+ """The badge is on *Miembros* now, and on the card of whoever wrote. Both
+ come from the same two numbers, so this is also the test that the directory
+ counts per person rather than in total."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "¿Vienes?"})
+ post(send(jose), {"body": "¿Vienes?"})
badge = '1'
# The sender has nothing unread — their own message does not count.
- assert badge not in client.get("/comunidad/privados").get_data(as_text=True)
+ assert badge not in client.get("/comunidad/miembros").get_data(as_text=True)
sign_in(jose)
- assert badge in client.get("/comunidad/privados").get_data(as_text=True)
+ assert badge in client.get("/comunidad/miembros").get_data(as_text=True)
- client.get(talk(maria)) # opening marks it read
- assert badge not in client.get("/comunidad/privados").get_data(as_text=True)
+ client.get(page("maria")) # opening marks it read
+ assert badge not in client.get("/comunidad/miembros").get_data(as_text=True)
+
+
+def test_the_person_who_wrote_is_at_the_top(client, post, make_member, sign_in):
+ """Without this the directory is alphabetical and the person waiting for an
+ answer is wherever the alphabet put them — which is the one thing the old
+ inbox did that a grid of faces does not."""
+ make_member("ana") # sorts first by name, nothing unread
+ maria, zoe = make_member("maria"), make_member("zoe")
+ sign_in(zoe)
+ post(send(maria), {"body": "¿Vienes?"})
+
+ sign_in(maria)
+ body = client.get("/comunidad/miembros").get_data(as_text=True)
+
+ assert body.index("/comunidad/miembro/zoe") < body.index("/comunidad/miembro/ana")
# --- blocking -------------------------------------------------------------
@@ -151,12 +208,12 @@ def test_a_block_stops_both_directions(client, post, make_member, sign_in):
safety feature."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Hola"})
+ post(send(jose), {"body": "Hola"})
post(f"/comunidad/privados/bloquear/{jose}") # maria blocks jose
- assert post(talk(jose), {"body": "Otra cosa"}).status_code == 403 # …and maria too
+ assert post(send(jose), {"body": "Otra cosa"}).status_code == 403 # …and maria too
sign_in(jose)
- assert post(talk(maria), {"body": "¿Hola?"}).status_code == 403
+ assert post(send(maria), {"body": "¿Hola?"}).status_code == 403
def test_a_block_is_enforced_in_the_handler_not_the_template(
@@ -168,17 +225,17 @@ def test_a_block_is_enforced_in_the_handler_not_the_template(
post(f"/comunidad/privados/bloquear/{maria}")
sign_in(maria) # never reloaded the page, still has the form
- assert post(talk(jose), {"body": "Hola"}).status_code == 403
+ assert post(send(jose), {"body": "Hola"}).status_code == 403
def test_a_blocked_person_still_sees_the_history_but_no_box(
client, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Antes del bloqueo"})
+ post(send(jose), {"body": "Antes del bloqueo"})
post(f"/comunidad/privados/bloquear/{jose}")
- body = client.get(talk(jose)).get_data(as_text=True)
+ body = client.get(page("jose")).get_data(as_text=True)
assert "Antes del bloqueo" in body
assert 'name="body"' not in body
assert "bloqueo entre vosotros" in body
@@ -197,12 +254,18 @@ def test_unblocking_only_removes_your_own(client, db, post, make_member, sign_in
assert db.execute("SELECT COUNT(*) AS n FROM blocks").fetchone()["n"] == 1
-def test_a_blocked_person_is_not_offered_in_the_list(client, post, make_member, sign_in):
+def test_a_blocked_person_is_still_in_the_directory(client, post, make_member, sign_in):
+ """A deliberate change. The old inbox had a picker of people you could
+ write to, and a blocked person was left out of it. The directory is not a
+ picker — it is the list of who is in the association, and somebody you have
+ blocked has not left. The block is stated on their page, where the write
+ box would have been."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
post(f"/comunidad/privados/bloquear/{jose}")
- assert "Jose" not in client.get("/comunidad/privados").get_data(as_text=True)
+ assert "Jose" in client.get("/comunidad/miembros").get_data(as_text=True)
+ assert "bloqueo entre vosotros" in client.get(page("jose")).get_data(as_text=True)
# --- pictures -------------------------------------------------------------
@@ -213,7 +276,7 @@ def test_a_picture_in_a_message_is_private_to_the_two_of_them(
signed in is nowhere near enough of a check."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Mira", "pictures": (io.BytesIO(PNG), "foto.png")},
+ post(send(jose), {"body": "Mira", "pictures": (io.BytesIO(PNG), "foto.png")},
content_type="multipart/form-data")
name = db.execute("SELECT stored_name FROM attachments").fetchone()["stored_name"]
@@ -229,7 +292,7 @@ def test_a_picture_in_a_message_is_private_to_the_two_of_them(
def test_an_empty_message_with_no_picture_is_refused(client, db, post, make_member, sign_in):
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": " "})
+ post(send(jose), {"body": " "})
assert db.execute("SELECT COUNT(*) AS n FROM messages").fetchone()["n"] == 0
assert db.execute("SELECT COUNT(*) AS n FROM conversations").fetchone()["n"] == 0
@@ -244,7 +307,7 @@ def test_erasing_a_member_takes_their_private_messages(
somebody's erased correspondence is what erasure exists to prevent."""
maria, jose = make_member("maria"), make_member("jose")
sign_in(maria)
- post(talk(jose), {"body": "Privado", "pictures": (io.BytesIO(PNG), "f.png")},
+ post(send(jose), {"body": "Privado", "pictures": (io.BytesIO(PNG), "f.png")},
content_type="multipart/form-data")
name = db.execute("SELECT stored_name FROM attachments").fetchone()["stored_name"]
@@ -268,3 +331,29 @@ def test_erasing_a_member_removes_blocks_either_way(
post(f"/comunidad/miembros/{maria}/eliminar")
assert db.execute("SELECT COUNT(*) AS n FROM blocks").fetchone()["n"] == 0
+
+
+# --- where sending lands --------------------------------------------------
+
+def test_sending_lands_back_on_their_page(client, post, make_member, sign_in):
+ """The form posts by id and the page is addressed by login, so the redirect
+ is the one place the two have to agree."""
+ maria, jose = make_member("maria"), make_member("jose")
+ sign_in(maria)
+
+ response = post(send(jose), {"body": "Hola"})
+
+ assert response.status_code == 302
+ assert response.headers["Location"].endswith("/comunidad/miembro/jose#final")
+
+
+def test_a_suspended_member_has_a_page_but_no_box(client, post, make_member, sign_in):
+ """They are in the directory, so their page has to exist; the handler
+ refuses a message to them, so the box is not drawn and the page says why."""
+ make_member("jose", active=0)
+ sign_in(make_member("maria"))
+
+ body = client.get(page("jose")).get_data(as_text=True)
+
+ assert "suspendido" in body
+ assert 'name="body"' not in body
diff --git a/apps/board/tests/test_navigation.py b/apps/board/tests/test_navigation.py
index 7e6f82d..d3ce9f2 100644
--- a/apps/board/tests/test_navigation.py
+++ b/apps/board/tests/test_navigation.py
@@ -1,7 +1,7 @@
"""What each role can see and reach.
This file exists because of a bug that no other test in this suite could have
-caught: *Privados*, *Mi perfil* and *Contenido* were all inside one
+caught: private messages, *Mi perfil* and *Contenido* were all inside one
`{% if g.member.role in ('owner', 'admin') %}` block in base.html, so an
ordinary member signed in to a wall and a member list and nothing else. Every
feature worked. Every test passed. Most of the members area was simply invisible
@@ -21,7 +21,7 @@ import pytest
SECTIONS = {
"Inicio": "/comunidad/",
"Muro": "/comunidad/muro",
- "Privados": "/comunidad/privados",
+ "Miembros": "/comunidad/miembros",
"Publicaciones": "/comunidad/publicaciones",
"Calendario": "/comunidad/calendario",
}
@@ -39,7 +39,7 @@ def nav(client, sign_in):
@pytest.mark.parametrize("role", ["user", "moderator"])
-def test_a_member_sees_the_four_shared_sections(role, nav, make_member):
+def test_a_member_sees_the_five_shared_sections(role, nav, make_member):
"""The regression. Not one of these may depend on a role again."""
body = nav(make_member("maria", role=role))
for label in SECTIONS:
@@ -176,7 +176,7 @@ def test_a_member_gets_their_name_and_their_sections(client, make_member, sign_i
assert state["signed_in"] is True
assert state["name"] == "Maria"
assert [s["label"] for s in state["sections"]] == [
- "Inicio", "Muro", "Privados", "Publicaciones", "Calendario"]
+ "Inicio", "Muro", "Miembros", "Publicaciones", "Calendario"]
assert state["csrf"] # the bar renders a real logout form
diff --git a/apps/board/tests/test_profiles.py b/apps/board/tests/test_profiles.py
index 6ac07ad..76087fb 100644
--- a/apps/board/tests/test_profiles.py
+++ b/apps/board/tests/test_profiles.py
@@ -219,30 +219,67 @@ def test_the_form_says_what_publishing_means(client, make_member, sign_in):
# --- names as doors -------------------------------------------------------
#
-# A profile nobody can reach from inside the members area is a profile nobody
-# visits. Every screen renders names through the one macro in
-# templates/_person.html, which links only when there is a page to link to —
-# the rule is in one place because both failures are silent: never linking
-# hides the profiles, always linking sends people to a 404.
+# Every screen renders names through the one macro in templates/_person.html,
+# and it used to link to somebody's *public* page, only when they had published
+# one — so most names on the wall were plain text and there was no way to get
+# from a post to writing to its author. It links inside now, to
+# /comunidad/miembro/, which exists for every member; their public page
+# is linked from there when they have one.
+#
+# The rule is in one place because both failures are silent: never linking
+# hides the people, always linking sends somebody to a 404.
-def test_a_name_on_the_wall_links_to_a_published_page(client, post, published, sign_in):
+def test_a_name_on_the_wall_links_to_their_page_inside(client, post, published, sign_in):
author = published("maria")
sign_in(author)
post("/comunidad/nuevo", {"title": "Hola", "body": "Qué tal"})
for url in ("/comunidad/muro", "/comunidad/tema/1", "/comunidad/"):
- assert 'href="/maria"' in client.get(url).get_data(as_text=True), url
+ assert ('href="/comunidad/miembro/maria"'
+ in client.get(url).get_data(as_text=True)), url
-def test_a_name_without_a_page_is_not_a_link(client, post, published, sign_in):
+def test_a_name_links_even_without_a_public_page(client, post, published, sign_in):
+ """The change this phase makes. Somebody who has published nothing is still
+ somebody you can reach — and their page says in as many words that there is
+ no public one."""
author = published("maria", profile_published=0)
sign_in(author)
post("/comunidad/nuevo", {"title": "Hola", "body": "Qué tal"})
for url in ("/comunidad/muro", "/comunidad/tema/1"):
body = client.get(url).get_data(as_text=True)
- assert 'href="/maria"' not in body, url
- assert "Maria" in body, url # the name is still there
+ assert 'href="/comunidad/miembro/maria"' in body, url
+ assert 'href="/maria"' not in body, url # their public page is not there
+
+ page = client.get("/comunidad/miembro/maria").get_data(as_text=True)
+ assert 'href="/maria"' not in page
+
+
+def test_their_page_links_out_to_the_public_one_when_there_is_one(
+ client, published, make_member, sign_in):
+ published("maria")
+ sign_in(make_member("jose"))
+
+ assert 'href="/maria"' in client.get("/comunidad/miembro/maria").get_data(as_text=True)
+
+
+def test_an_erased_members_name_is_not_a_link(client, post, owner_id,
+ make_member, sign_in):
+ """The one name with no page behind it. An erased member's writing is
+ reassigned to the tombstone, which is not a person and has nothing to
+ show — and `members.show` 404s for it, so a link there would be a dead
+ end on the wall."""
+ maria = make_member("maria")
+ sign_in(maria)
+ post("/comunidad/nuevo", {"title": "Hola", "body": "Qué tal"})
+
+ sign_in(owner_id)
+ post(f"/comunidad/miembros/{maria}/eliminar")
+
+ body = client.get("/comunidad/muro").get_data(as_text=True)
+ assert "Miembro eliminado" in body
+ assert "/comunidad/miembro/__removed__" not in body
def test_a_comment_and_a_private_message_link_too(client, post, published,
@@ -256,6 +293,6 @@ def test_a_comment_and_a_private_message_link_too(client, post, published,
post("/comunidad/privados/con/%d" % jose, {"body": "Hola José"})
sign_in(jose)
- assert 'href="/maria"' in client.get("/comunidad/tema/1").get_data(as_text=True)
- assert 'href="/maria"' in client.get(
- f"/comunidad/privados/con/{maria}").get_data(as_text=True)
+ link = 'href="/comunidad/miembro/maria"'
+ assert link in client.get("/comunidad/tema/1").get_data(as_text=True)
+ assert link in client.get("/comunidad/miembro/maria").get_data(as_text=True)
diff --git a/apps/board/tests/test_templates.py b/apps/board/tests/test_templates.py
index 8c29daa..a5ef914 100644
--- a/apps/board/tests/test_templates.py
+++ b/apps/board/tests/test_templates.py
@@ -148,7 +148,7 @@ PROSE_BOXES = {
"thread_form.html": "body",
"comment_form.html": "body",
"thread.html": "body",
- "conversation.html": "body",
+ "member.html": "body",
"submission_form.html": "body",
"content_form.html": "body",
"profile_edit.html": "bio",
diff --git a/config.yaml b/config.yaml
index 2052eb3..b683dd2 100644
--- a/config.yaml
+++ b/config.yaml
@@ -79,10 +79,13 @@ languages:
params:
# The picture a share card falls back on when a post or page has none, and the
- # organisation's logo in the structured data. One path — /uploads/algo.png —
- # and WhatsApp, Signal, Mastodon and Bluesky all start showing an image. Left
- # empty until there is a logo to put here; a link then shares as title and
- # description, which is what happens today.
+ # organisation's logo in the structured data.
+ #
+ # **The logo uploaded in Gestión → Marca is used first**, so this is now only
+ # for a site that wants a different share picture from its logo — a photo of
+ # the city, say. One path (/uploads/algo.png) and WhatsApp, Signal, Mastodon
+ # and Bluesky all start showing an image. Empty, with no logo either, means a
+ # link shares as title and description.
defaultImage: ""
# The organisation's profiles elsewhere, for `sameAs` in the Organization
diff --git a/docs/server-setup.md b/docs/server-setup.md
index e9dd032..cb6abbd 100644
--- a/docs/server-setup.md
+++ b/docs/server-setup.md
@@ -672,13 +672,36 @@ Limits: 4 images per message, and `BOARD_UPLOAD_MAX_BYTES` (8MB by default)
each. Adding a picture to a post *after* publishing it means posting a reply —
editing changes the words, and leaves the pictures alone.
-### 11.10 Private messages (`/comunidad/privados/`)
+### 11.10 Private messages (on each person's page)
-An inbox between two members: conversations, unread badges, photos, blocking.
+Between two members: conversations, unread badges, photos, blocking.
Deliberately not live chat — that needs a connection held open per signed-in
member, which gunicorn's sync workers cannot do, and it would be the first
thing on this box with a real scaling limit.
+**There is no inbox.** You write to somebody by opening their page —
+`/comunidad/miembro/`, reached from *Miembros* or from their name
+anywhere on the wall — and the whole conversation with them is on it, under
+their photo and bio, with the write box at the foot. One place per person
+rather than a mailbox listing people.
+
+Three consequences worth knowing:
+
+* **The unread badge is on *Miembros***, and repeated on the card of whoever
+ wrote. Those cards are sorted so that anybody with something unread is at the
+ top of the grid — without that, the person waiting for an answer is wherever
+ the alphabet put them.
+* **Opening the page marks it read.** There is no second step any more, so
+ there is no moment where the messages are on screen and still counted unread.
+* **The old addresses redirect.** `/comunidad/privados` goes to the directory
+ and `/comunidad/privados/con/` to that person's page; the POST that sends
+ a message is still `/comunidad/privados/con/`, which is why the two look
+ alike in the logs.
+
+A member's own page carries no conversation and no box: it is there so they can
+see what the others see, and their own private messages are each on the page of
+the person they had them with.
+
**Blocking is symmetric.** One block stops messages in both directions, and
either person can only remove their own. A block that silenced just the blocked
person would leave the blocker able to keep writing, which is a megaphone
@@ -693,7 +716,7 @@ of the choice, and deliberate.
### 11.10b The members' bar on the public site
A signed-in member sees a slim bar above the public header on vienalatina.com,
-with the same five sections the members area has. The public pages are files on
+with the same sections the members area has. The public pages are files on
disk and get cached, so the bar is drawn in the browser:
`themes/vienalatina/assets/js/memberbar.js` asks `/comunidad/sesion.json` who is
reading, and that endpoint is the only thing that decides anything — a visitor
@@ -800,7 +823,7 @@ the same problem the Gitea theme has. If the colours change in
`themes/vienalatina/assets/css/main.css`, change them in
`apps/board/templates/profile.html` too.
-### 11.13 The five sections, and the moderation queue
+### 11.13 The six sections, and the moderation queue
Signing in lands on **Inicio**, a dashboard of what has happened since the last
visit. The navigation is the same for everybody except the last entry:
@@ -809,19 +832,26 @@ visit. The navigation is the same for everybody except the last entry:
|---|---|---|
| **Inicio** | `/comunidad/` | everybody |
| **Muro** | `/comunidad/muro` | everybody |
-| **Privados** | `/comunidad/privados` | everybody |
+| **Miembros** | `/comunidad/miembros` | everybody |
| **Publicaciones** | `/comunidad/publicaciones` | everybody, with two different pages behind it |
+| **Calendario** | `/comunidad/calendario` | everybody; admins add events |
| **Gestión** | `/comunidad/gestion` | admins and the owner |
-Gestión holds three things: Miembros, the published **Artículos**, and the
-site's static **Páginas**. A moderator cannot open it, so their route to the
-published articles is the *Ya publicado* link on Publicaciones — the only one
-they have, which is why it sits beside the button rather than inside a
+**Miembros replaced Privados**, which was a list of conversations. The people
+are the section now — a grid of faces and names — and each person's page holds
+their profile, the private conversation with them, and (for an admin) the
+controls for that one person. §11.10 has the mechanics. The unread badge moved
+to this entry with the messages.
+
+Gestión holds Miembros' *Dar de alta*, the published **Artículos**, the site's
+static **Páginas** and **Marca**. A moderator cannot open it, so their route to
+the published articles is the *Ya publicado* link on Publicaciones — the only
+one they have, which is why it sits beside the button rather than inside a
paragraph.
*Mi perfil*, *Descargar mis datos* and *Salir* are in the menu under the member's
own name, top right. They are not sections of the site, and while they were in the
-navigation three of the five entries were admin-only — which meant an ordinary
+navigation three of the entries were admin-only — which meant an ordinary
member signed in to a wall and a member list, with their own profile and their own
private messages hidden from them. `apps/board/tests/test_navigation.py` asserts
the navigation per role now, so that cannot come back quietly.
@@ -866,18 +896,21 @@ only the title and the description. Editing a post keeps the author it already
had, so correcting somebody's typo never re-signs their article.
**On the wall itself**: one 👍 per member per post or comment, which clicking
-again takes back, and every name is a link to that person's page — but only when
-they have published one, so nobody is sent to a 404. Both rules live in one place
-each (`templates/_reaction.html`, `templates/_person.html`) so no screen has to
+again takes back, and every name is a link to that person's page inside the
+members area — which exists for everybody, published page or not. The one name
+that is not a link is *Miembro eliminado*, the tombstone an erased member's
+writing is reassigned to. Both rules live in one place each
+(`templates/_reaction.html`, `templates/_person.html`) so no screen has to
remember them.
-**Miembros is a directory**, not an admin table: a card per person with their
-photo, username, role, the first line of their bio, somewhere to write to them
-and a link to their page. Admins get the controls — suspend, re-invite, change
-role, erase — inside a *Gestionar* block on each card, closed by default. A
-member's photo shows here even when their public page is unpublished, because
-this side is behind the login; `profiles.member_photo` serves it and the profile
-form says so in plain words.
+**Miembros is a directory of faces and names**: a card per person with their
+photo, username and role, and the whole card is a link to their page. Everything
+about one person is on that page — their bio and links, the private conversation
+with them, and, for an admin, the controls (suspend, re-invite, change role,
+erase) inside a *Gestionar* block, closed by default. A member's photo shows
+here even when their public page is unpublished, because this side is behind the
+login; `profiles.member_photo` serves it and the profile form says so in plain
+words.
### 11.15 The public menu is built from the pages
@@ -975,6 +1008,72 @@ Choosing a picture shows a thumbnail with its name and size before anything is
uploaded. That is the one reason `blob:` is in the `img-src` policy — a handle to
bytes already in the page, which reaches no network.
+### 11.18 Marca: the admin owns the look
+
+*Gestión* → **Marca**, admins only. Colours, a logo and a favicon for both
+halves of the site, with an *Avanzado* fold holding every token as a text field
+and a free CSS box.
+
+**`apps/board/brand.py`'s `FACTORY` is the single source of truth for the
+palette.** The two `:root` blocks — `themes/vienalatina/assets/css/main.css` and
+`apps/board/static/board.css` — each still carry their own copy, because they are
+served by different things and each has to stand alone; what changed is that
+`apps/board/tests/test_brand.py` parses both and fails the build if either
+disagrees with `FACTORY`. The comment that used to say *"If the brand colours
+change, change them in both"* was an instruction, which is the weakest kind of
+guarantee there is.
+
+**One save, two destinations**, because the two halves cannot read the same
+store:
+
+| Where | What | Why |
+|---|---|---|
+| SQLite, table `brand`, one row | the tokens, the custom CSS, both pictures under `/data/uploads` | the members area must render when the git server is down |
+| the content repository: `data/brand.yaml`, `static/brand/logo.*`, `static/brand/favicon.png` | the same values | the public site is files on disk and has no database |
+
+**SQLite first, then the commits.** If Gitea is unreachable the change still
+takes effect in the members area, `published_at` stays NULL, and the screen says
+so with a *Reintentar publicar* button. The other order would let a git outage
+block a change that does not need git. A colour therefore reaches
+vienalatina.com on the next pipeline run — a couple of minutes — and the members
+area immediately.
+
+Three details worth knowing before changing any of it:
+
+* **Only what differs from the factory is stored**, as JSON in one column. A
+ token added here later arrives with its default already in place for every
+ existing install, which a snapshot of all thirteen would not.
+* **`--brand-dark`, `--brand-soft` and `--brand-softer` are worked out from
+ `--brand`** in HLS (hue and saturation kept, lightness moved), so an admin
+ picks one colour and gets a coherent set. Each can be overridden in
+ *Avanzado*. With no brand colour stored, the factory hexes are used verbatim —
+ deriving from an unchanged colour would shift the palette by a rounding error
+ the first time anybody opened the screen.
+* **A WCAG contrast warning, not a refusal.** Text on background below 4.5:1,
+ or white on the brand colour below 3:1, is named with its ratio and saved
+ anyway. An admin may have a reason; what this prevents is shipping an
+ unreadable site without once being told.
+
+**The Marca screen deliberately does not load the generated stylesheet.** Every
+other page does. That is what keeps *Restaurar lo de fábrica* reachable after
+somebody puts `* { display: none }` in the CSS box — and the reason the colours
+an admin picks do not show on the page where they pick them. The live preview
+block is where they see them, restyled by `board.js` setting the custom
+properties on that one element (a DOM write, not an inline `style` attribute,
+which is what makes it work under a policy with no `'unsafe-inline'`).
+
+**No SVG and no ICO.** The logo takes PNG, JPG or WebP and the favicon PNG only,
+both identified from their bytes by the same sniffer the wall uses. An SVG is XML
+that can carry script and would be served from our own origin; ICO would be one
+more branch in the sniffer for a format every current browser no longer needs.
+
+The pictures are committed to stable paths, so saving a new logo replaces the
+file instead of leaving every previous one deployed and unreferenced; a logo
+saved in a different format has its predecessor deleted. `scripts/translate.py`
+needs nothing — it walks `content/` only, and `data/` and `static/` are outside
+it. A site with no `data/brand.yaml` builds byte-for-byte the HTML it built
+before any of this existed, which is asserted by building both ways.
+
## 12. Make Gitea look like the site
Members sign in to `/comunidad/` through Gitea, so Gitea's sign-in form and its
diff --git a/themes/vienalatina/layouts/_default/baseof.html b/themes/vienalatina/layouts/_default/baseof.html
index e7fd25e..0399b0c 100644
--- a/themes/vienalatina/layouts/_default/baseof.html
+++ b/themes/vienalatina/layouts/_default/baseof.html
@@ -7,6 +7,7 @@
{{ partial "seo-head.html" . }}
{{ $css := resources.Get "css/main.css" | minify | fingerprint }}
+ {{ partial "brand-head.html" . }}
{{ range .AlternativeOutputFormats -}}
diff --git a/themes/vienalatina/layouts/partials/brand-head.html b/themes/vienalatina/layouts/partials/brand-head.html
new file mode 100644
index 0000000..38fad14
--- /dev/null
+++ b/themes/vienalatina/layouts/partials/brand-head.html
@@ -0,0 +1,31 @@
+{{/* The admin's colours and the favicon, from data/brand.yaml.
+
+ That file is written by the members area — Gestión → Marca commits it
+ through the contents API, the pipeline runs, and the colours arrive here on
+ the next build. The whole partial is inside a `with`, so a site with no
+ brand.yaml emits nothing at all and its HTML is byte-identical to before
+ this existed.
+
+ Built with resources.FromString rather than written into a