Compare commits
3 Commits
6c537c3e7e
...
8f85a27ed1
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f85a27ed1 | |||
| bc0351aa44 | |||
| c2154b6f06 |
@ -59,13 +59,6 @@ COLLECTIONS = {
|
||||
},
|
||||
}
|
||||
|
||||
# The one category that changes what a post *is* rather than what it is about:
|
||||
# tick it and the post needs a date of its own, appears in the agenda, renders
|
||||
# with the date and the place at the top, and offers an .ics.
|
||||
EVENT_CATEGORY = "Evento"
|
||||
|
||||
CATEGORIES = ["Evento", "Turismo", "Cultura", "Gastronomía", "Comunidad", "Comercio"]
|
||||
|
||||
UPLOAD_FOLDER = "static/uploads"
|
||||
|
||||
TITLE_MAX = 140
|
||||
@ -149,8 +142,6 @@ def frontmatter_for(collection: str, form: dict) -> dict:
|
||||
# person: it is a build instruction, not something to explain in a form.
|
||||
fields["outputs"] = ["HTML", "ics"]
|
||||
if collection == "post":
|
||||
if form["categories"]:
|
||||
fields["categories"] = form["categories"]
|
||||
if form["description"]:
|
||||
fields["description"] = form["description"]
|
||||
if form["image"]:
|
||||
@ -181,17 +172,17 @@ def _cache_read(path: str, sha: str):
|
||||
|
||||
def _cache_write(path: str, sha: str, fm: dict) -> None:
|
||||
get_db().execute(
|
||||
"""INSERT INTO content_cache (path, sha, title, date, categories, generated,
|
||||
"""INSERT INTO content_cache (path, sha, title, date, generated,
|
||||
event_date, event_time, event_location)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
ON CONFLICT(path) DO UPDATE SET
|
||||
sha = excluded.sha, title = excluded.title, date = excluded.date,
|
||||
categories = excluded.categories, generated = excluded.generated,
|
||||
generated = excluded.generated,
|
||||
event_date = excluded.event_date, event_time = excluded.event_time,
|
||||
event_location = excluded.event_location,
|
||||
updated_at = datetime('now')""",
|
||||
(path, sha, str(fm.get("title", "")), str(fm.get("date", "")),
|
||||
", ".join(fm.get("categories") or []), 1 if fm.get("translated_from") else 0,
|
||||
1 if fm.get("translated_from") else 0,
|
||||
# Cached for the private calendar, which shows public events beside the
|
||||
# internal ones and would otherwise read every post's frontmatter on
|
||||
# every page view to find out when they are.
|
||||
@ -223,7 +214,7 @@ def listing(collection: str) -> list[dict]:
|
||||
items.append({
|
||||
"name": name, "path": path, "sha": sha,
|
||||
"title": row["title"] or name,
|
||||
"date": row["date"], "categories": row["categories"],
|
||||
"date": row["date"],
|
||||
"event_date": row["event_date"] or "",
|
||||
"event_time": row["event_time"] or "",
|
||||
"event_location": row["event_location"] or "",
|
||||
@ -275,8 +266,6 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
||||
except ValueError:
|
||||
errors.append("La fecha debe tener el formato AAAA-MM-DD.")
|
||||
|
||||
categories = [c for c in request.form.getlist("categories") if c in CATEGORIES]
|
||||
|
||||
# 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
|
||||
# three languages — and the menu is built from these, not from a list in
|
||||
@ -297,7 +286,7 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
||||
# When a post is an event, it has a date of its own. The post's `date` above
|
||||
# is when it was announced — often weeks earlier, and the thing Hugo sorts
|
||||
# the blog by — so the two cannot be the same field.
|
||||
event = read_event_fields(request.form, categories, errors)
|
||||
event = read_event_fields(request.form, errors)
|
||||
|
||||
faq = clean_faq(request.form.get("faq", ""))
|
||||
image_alt = request.form.get("image_alt", "").strip()[:200]
|
||||
@ -322,7 +311,7 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
||||
errors.append("El cuerpo no puede estar vacío.")
|
||||
|
||||
fields = {
|
||||
"title": title, "date": when, "categories": categories,
|
||||
"title": title, "date": when,
|
||||
"description": request.form.get("description", "").strip(),
|
||||
"image": image,
|
||||
"manual_translation": request.form.get("manual_translation") == "on",
|
||||
@ -368,27 +357,33 @@ def commit_picture(data: bytes, filename: str, author=None) -> str:
|
||||
return f"/uploads/{name}"
|
||||
|
||||
|
||||
def read_event_fields(form, categories: list[str], errors: list[str]) -> dict:
|
||||
"""The three fields that come with the Evento category.
|
||||
def read_event_fields(form, errors: list[str]) -> dict:
|
||||
"""The three fields that make a post an event.
|
||||
|
||||
**The date is the marker.** There used to be an «Evento» category to tick
|
||||
first, and ticking it without filling the date in was an error the form had
|
||||
to refuse. With the categories gone there is nothing to tick: a post that
|
||||
carries a date is an event, which also means there is no way left to say
|
||||
"this is an event" and then not say when.
|
||||
|
||||
Shared by the editor and by a member's proposal, so a post written by a
|
||||
moderator and one approved from the queue carry the same frontmatter. The
|
||||
date is required and the other two are not: an event with no time is an
|
||||
all-day event, and one with no place is a mistake somebody can fix later
|
||||
rather than a reason to refuse the whole post.
|
||||
other two fields stay optional: an event with no time is an all-day event,
|
||||
and one with no place is a mistake somebody can fix later rather than a
|
||||
reason to refuse the whole post.
|
||||
|
||||
Returns empty strings when the category is absent, so an ordinary article
|
||||
never carries empty event lines in its frontmatter.
|
||||
Returns empty strings when no date was given, so an ordinary article never
|
||||
carries empty event lines in its frontmatter.
|
||||
"""
|
||||
if EVENT_CATEGORY not in categories:
|
||||
raw = form.get("event_date", "").strip()
|
||||
if not raw:
|
||||
return {"event_date": "", "event_time": "", "event_location": ""}
|
||||
|
||||
raw = form.get("event_date", "").strip()
|
||||
try:
|
||||
event_date = datetime.strptime(raw, "%Y-%m-%d").date().isoformat()
|
||||
except ValueError:
|
||||
event_date = ""
|
||||
errors.append("Un evento necesita fecha, con el formato AAAA-MM-DD.")
|
||||
errors.append("La fecha del evento debe tener el formato AAAA-MM-DD.")
|
||||
|
||||
event_time = form.get("event_time", "").strip()
|
||||
if event_time and not EVENT_TIME.match(event_time):
|
||||
@ -505,7 +500,7 @@ def new(collection: str):
|
||||
meta = _collection_or_404(collection)
|
||||
if request.method == "GET":
|
||||
return render_template("content_form.html", collection=collection, meta=meta,
|
||||
categories=CATEGORIES, item=None, fields=None,
|
||||
item=None, fields=None,
|
||||
body="", today=date_type.today().isoformat(),
|
||||
parents=possible_parents(collection))
|
||||
|
||||
@ -548,7 +543,6 @@ def edit(collection: str, name: str):
|
||||
fields = {
|
||||
"title": fm.get("title", ""),
|
||||
"date": fm.get("date"),
|
||||
"categories": fm.get("categories") or [],
|
||||
"description": fm.get("description", ""),
|
||||
"image": fm.get("image", ""),
|
||||
"manual_translation": bool(fm.get("manual_translation")),
|
||||
@ -567,7 +561,7 @@ def edit(collection: str, name: str):
|
||||
"event_location": fm.get("event_location", ""),
|
||||
}
|
||||
return render_template("content_form.html", collection=collection, meta=meta,
|
||||
categories=CATEGORIES, item={"name": name, "sha": sha},
|
||||
item={"name": name, "sha": sha},
|
||||
fields=fields, body=body,
|
||||
today=date_type.today().isoformat(),
|
||||
parents=possible_parents(collection, name))
|
||||
@ -628,7 +622,7 @@ def preview(collection: str):
|
||||
sha = request.form.get("sha", "")
|
||||
item = {"name": request.form.get("name", ""), "sha": sha} if sha else None
|
||||
return render_template("content_form.html", collection=collection, meta=meta,
|
||||
categories=CATEGORIES, item=item, fields=fields, body=body,
|
||||
item=item, fields=fields, body=body,
|
||||
today=date_type.today().isoformat(),
|
||||
parents=possible_parents(collection,
|
||||
item["name"] if item else ""),
|
||||
@ -686,7 +680,7 @@ def _back_to_form(collection, meta, fields, body, errors, item):
|
||||
for message in errors:
|
||||
flash(message, "error")
|
||||
return render_template("content_form.html", collection=collection, meta=meta,
|
||||
categories=CATEGORIES, item=item, fields=fields, body=body,
|
||||
item=item, fields=fields, body=body,
|
||||
today=date_type.today().isoformat(),
|
||||
parents=possible_parents(collection,
|
||||
item["name"] if item else "")), 400
|
||||
|
||||
@ -3,9 +3,9 @@
|
||||
What the association is doing and when, for the people inside: a meeting, a
|
||||
rehearsal, a visit somewhere. Admins write them, every member reads them, and
|
||||
nothing here is ever published — no Open Graph, no sitemap, nothing written to
|
||||
/var/www. That is the whole difference between this and a post in the Evento
|
||||
category, and it is why the two live in different places rather than behind a
|
||||
flag on one.
|
||||
/var/www. That is the whole difference between this and a public post carrying
|
||||
an event date, and it is why the two live in different places rather than behind
|
||||
a flag on one.
|
||||
|
||||
**The public events appear here too**, marked as public and linking to the site,
|
||||
because a member should have one place to look rather than two. They come from
|
||||
|
||||
@ -232,6 +232,23 @@ def _rooms_for_a_date_of_its_own(db: sqlite3.Connection) -> None:
|
||||
db.execute(f"ALTER TABLE {table} ADD COLUMN {column} TEXT")
|
||||
|
||||
|
||||
def _no_more_categories(db: sqlite3.Connection) -> None:
|
||||
"""Take the category column off the two tables that carried one.
|
||||
|
||||
`DROP COLUMN` rather than a rebuild: SQLite has had it since 3.35 and
|
||||
neither column is in a CHECK, an index or a foreign key, which are the three
|
||||
things that make it refuse. The rebuilds in steps 1 and 4 exist because a
|
||||
CHECK cannot be altered any other way — this needs none of that.
|
||||
|
||||
Dropping rather than leaving a column nobody writes to: a dead column is a
|
||||
question for whoever reads this schema next, and the answer ("we used to
|
||||
have categories") is not in the file.
|
||||
"""
|
||||
for table in ("content_cache", "submissions"):
|
||||
if "categories" in _columns(db, table):
|
||||
db.execute(f"ALTER TABLE {table} DROP COLUMN categories")
|
||||
|
||||
|
||||
# (number, description, function). The number is the value written to
|
||||
# user_version once the step succeeds.
|
||||
STEPS = [
|
||||
@ -240,6 +257,7 @@ STEPS = [
|
||||
(3, "members can have a public page", _members_get_a_public_page),
|
||||
(4, "members can be moderators", _members_can_moderate),
|
||||
(5, "events carry a date of their own", _rooms_for_a_date_of_its_own),
|
||||
(6, "there are no categories any more", _no_more_categories),
|
||||
]
|
||||
|
||||
|
||||
|
||||
@ -42,6 +42,10 @@ LINKS_MAX = 8
|
||||
# collision harmless rather than dangerous — Hugo wins and the profile is
|
||||
# simply unreachable — so this exists to stop somebody discovering months later
|
||||
# that their page has never loaded for anybody.
|
||||
#
|
||||
# `categories` and `tags` stay on the list although the taxonomies are gone: the
|
||||
# site served those paths for a year, and a URL somebody may still have in a
|
||||
# bookmark or a search index should not quietly become a member's profile.
|
||||
RESERVED = {
|
||||
"de", "pt-br", "es", "en", # language trees
|
||||
"page", "post", "posts", "categories", "tags", "category", "tag",
|
||||
|
||||
@ -189,7 +189,6 @@ CREATE TABLE IF NOT EXISTS content_cache (
|
||||
sha TEXT NOT NULL,
|
||||
title TEXT NOT NULL DEFAULT '',
|
||||
date TEXT NOT NULL DEFAULT '',
|
||||
categories TEXT NOT NULL DEFAULT '',
|
||||
-- Files carrying `translated_from` are the pipeline's output, not anyone's
|
||||
-- draft. Recorded here so the listing can skip them without re-reading
|
||||
-- every file to find out what it already knew.
|
||||
@ -245,10 +244,9 @@ CREATE TABLE IF NOT EXISTS submissions (
|
||||
title TEXT NOT NULL,
|
||||
body_md TEXT NOT NULL,
|
||||
description TEXT NOT NULL DEFAULT '',
|
||||
categories TEXT NOT NULL DEFAULT '', -- comma-separated, as content_cache
|
||||
-- Set only when the proposal carries the Evento category. The event's own
|
||||
-- date, which is not the day it is published: a member announcing a concert
|
||||
-- three weeks out is the normal case.
|
||||
-- The event's own date, which is also what makes this proposal an event at
|
||||
-- all. It is not the day it is published: a member announcing a concert three
|
||||
-- weeks out is the normal case.
|
||||
event_date TEXT,
|
||||
event_time TEXT,
|
||||
event_location TEXT,
|
||||
@ -304,7 +302,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS reactions_one_per_comment
|
||||
-- Events the association puts on for its members: a meeting, a rehearsal, a
|
||||
-- visit somewhere. Written by admins, read by every member, and never published
|
||||
-- — nothing here reaches /var/www, the sitemap or a share card, which is the
|
||||
-- difference between this table and a post with the Evento category.
|
||||
-- difference between this table and a public post carrying an event date.
|
||||
--
|
||||
-- `starts_on` and `starts_at` are kept apart rather than as one timestamp
|
||||
-- because an event with no time is an ordinary thing ("the whole Saturday") and
|
||||
|
||||
@ -68,6 +68,10 @@ button, input, select, textarea { font: inherit; }
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
/* A long display name beside a logo has nowhere to go on a phone otherwise,
|
||||
and `space-between` pushes the brand off the left edge rather than
|
||||
wrapping. */
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.site-bar__brand { text-decoration: none; }
|
||||
@ -84,7 +88,15 @@ button, input, select, textarea { font: inherit; }
|
||||
padding: 0.6rem 16px;
|
||||
list-style: none;
|
||||
display: flex;
|
||||
gap: 1.5rem;
|
||||
gap: 0.5rem 1.5rem;
|
||||
/* Six sections and their badges do not fit across a phone. Without this the
|
||||
row overflowed and took the whole page sideways with it — a members area
|
||||
you had to scroll right to read.
|
||||
Wrapping rather than a strip you swipe: two lines show all six, and a
|
||||
horizontal scroll would have left Calendario and Gestión off the right
|
||||
edge with nothing to say they were there. On a laptop it is one line
|
||||
either way. */
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.page-nav a { color: var(--muted); text-decoration: none; }
|
||||
.page-nav a:hover { color: var(--brand); }
|
||||
|
||||
@ -92,17 +92,14 @@ def _read_proposal() -> tuple[dict, list[str]]:
|
||||
"""The same fields the editor asks for, minus the ones only a publisher
|
||||
decides: the date is the day it is approved, and `manual_translation` is a
|
||||
pipeline switch, not something to explain to a member."""
|
||||
categories = [c for c in request.form.getlist("categories")
|
||||
if c in content.CATEGORIES]
|
||||
errors = []
|
||||
fields = {
|
||||
"title": request.form.get("title", "").strip()[:TITLE_MAX],
|
||||
"body": request.form.get("body", "").strip()[:BODY_MAX],
|
||||
"description": request.form.get("description", "").strip()[:300],
|
||||
"categories": categories,
|
||||
# The same three fields the editor asks for, read by the same function:
|
||||
# a member's event and a moderator's have to produce the same post.
|
||||
**content.read_event_fields(request.form, categories, errors),
|
||||
**content.read_event_fields(request.form, errors),
|
||||
}
|
||||
if not fields["title"]:
|
||||
errors.append("El título no puede estar vacío.")
|
||||
@ -154,8 +151,7 @@ def propose():
|
||||
return redirect(url_for("content.new", collection="post"))
|
||||
|
||||
if request.method == "GET":
|
||||
return render_template("submission_form.html", item=None, fields=None,
|
||||
categories=content.CATEGORIES)
|
||||
return render_template("submission_form.html", item=None, fields=None)
|
||||
|
||||
fields, errors = _read_proposal()
|
||||
waiting = get_db().execute(
|
||||
@ -179,11 +175,11 @@ def propose():
|
||||
photo_name = _store_picture(staged)
|
||||
get_db().execute(
|
||||
"""INSERT INTO submissions
|
||||
(author_id, title, body_md, description, categories, photo_name,
|
||||
(author_id, title, body_md, description, photo_name,
|
||||
event_date, event_time, event_location)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(g.member["id"], fields["title"], fields["body"], fields["description"],
|
||||
", ".join(fields["categories"]), photo_name,
|
||||
photo_name,
|
||||
fields["event_date"], fields["event_time"], fields["event_location"]),
|
||||
)
|
||||
flash("Enviado. Un moderador lo leerá antes de publicarlo.", "ok")
|
||||
@ -217,12 +213,10 @@ def edit(submission_id: int):
|
||||
return redirect(url_for("submissions.index"))
|
||||
|
||||
if request.method == "GET":
|
||||
return render_template("submission_form.html", item=row, categories=content.CATEGORIES,
|
||||
return render_template("submission_form.html", item=row,
|
||||
fields={
|
||||
"title": row["title"], "body": row["body_md"],
|
||||
"description": row["description"],
|
||||
"categories": [c.strip() for c in
|
||||
(row["categories"] or "").split(",") if c.strip()],
|
||||
"event_date": row["event_date"] or "",
|
||||
"event_time": row["event_time"] or "",
|
||||
"event_location": row["event_location"] or "",
|
||||
@ -246,14 +240,14 @@ def edit(submission_id: int):
|
||||
|
||||
get_db().execute(
|
||||
"""UPDATE submissions
|
||||
SET title = ?, body_md = ?, description = ?, categories = ?,
|
||||
SET title = ?, body_md = ?, description = ?,
|
||||
photo_name = ?, event_date = ?, event_time = ?,
|
||||
event_location = ?, state = 'pending', note = NULL,
|
||||
reviewed_by = NULL, reviewed_at = NULL,
|
||||
updated_at = datetime('now')
|
||||
WHERE id = ?""",
|
||||
(fields["title"], fields["body"], fields["description"],
|
||||
", ".join(fields["categories"]), photo_name, fields["event_date"],
|
||||
photo_name, fields["event_date"],
|
||||
fields["event_time"], fields["event_location"], submission_id),
|
||||
)
|
||||
# Back to pending on every edit, including one made after a rejection: a
|
||||
@ -320,7 +314,6 @@ def approve(submission_id: int):
|
||||
# this and the URL carries it, so a proposal that waited a week should
|
||||
# not arrive dated a week ago.
|
||||
"date": date_type.today(),
|
||||
"categories": [c.strip() for c in (row["categories"] or "").split(",") if c.strip()],
|
||||
"description": row["description"],
|
||||
"image": "",
|
||||
"manual_translation": False,
|
||||
@ -419,5 +412,4 @@ def _store_picture(staged: list[dict]) -> str | None:
|
||||
def _back_to_form(item, fields, errors):
|
||||
for message in errors:
|
||||
flash(message, "error")
|
||||
return render_template("submission_form.html", item=item, fields=fields,
|
||||
categories=content.CATEGORIES), 400
|
||||
return render_template("submission_form.html", item=item, fields=fields), 400
|
||||
|
||||
@ -66,26 +66,15 @@
|
||||
{% endif %}
|
||||
|
||||
{% if collection == 'post' %}
|
||||
<fieldset class="fieldset">
|
||||
<legend>Categorías</legend>
|
||||
{% for category in categories %}
|
||||
<label class="check">
|
||||
<input type="checkbox" name="categories" value="{{ category }}"
|
||||
{{ 'checked' if category in (f.categories or []) }}>
|
||||
{{ category }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
{# An event's own date, which is not the day the post goes up. Shown whenever
|
||||
a post can be written: ticking Evento above is what makes these required,
|
||||
checked on the server rather than hidden and shown with a script. #}
|
||||
{# An event's own date, which is not the day the post goes up. The date is
|
||||
also what makes this post an event: there is nothing to tick first, so
|
||||
there is no way to say "this is an event" and then not say when. #}
|
||||
<fieldset class="fieldset">
|
||||
<legend>Si es un evento</legend>
|
||||
<p class="muted small">
|
||||
Marca <strong>Evento</strong> arriba y rellena al menos la fecha. El
|
||||
evento aparecerá en la agenda del sitio y se podrá añadir al
|
||||
calendario del móvil.
|
||||
Pon la fecha y será un evento: aparecerá en la agenda del sitio, con el
|
||||
día y el lugar destacados, y se podrá añadir al calendario del móvil.
|
||||
Déjala vacía y es un artículo normal.
|
||||
</p>
|
||||
|
||||
<label for="event_date">Fecha del evento</label>
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
{% else %}
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr><th>Título</th>{% if meta.dated %}<th>Fecha</th>{% endif %}<th>Categorías</th><th></th></tr>
|
||||
<tr><th>Título</th>{% if meta.dated %}<th>Fecha</th>{% endif %}{% if meta.dated %}<th>Evento</th>{% endif %}<th></th></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for item in items %}
|
||||
@ -31,7 +31,10 @@
|
||||
<div class="muted small mono">{{ item.name }}</div>
|
||||
</td>
|
||||
{% if meta.dated %}<td>{{ item.date }}</td>{% endif %}
|
||||
<td>{{ item.categories }}</td>
|
||||
{# The column that used to hold the categories. An event date is the
|
||||
one thing left that changes what a post is, and it is what a
|
||||
moderator scanning this list is looking for. #}
|
||||
{% if meta.dated %}<td>{{ item.event_date }}</td>{% endif %}
|
||||
{# The flex row goes INSIDE the cell, never on it. `.actions` is
|
||||
display:flex, and a <td> told to be a flex container stops being a
|
||||
table cell: it leaves the row's layout and draws its bottom border
|
||||
|
||||
@ -36,6 +36,6 @@
|
||||
<p class="muted small">
|
||||
Este evento sólo se ve desde el área de miembros. Para anunciar algo a todo
|
||||
el mundo, usa <a href="{{ url_for('submissions.index') }}">Publicaciones</a>
|
||||
con la categoría «Evento».
|
||||
poniéndole una fecha de evento.
|
||||
</p>
|
||||
{% endblock %}
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
<div class="card__meta">
|
||||
<span class="tag tag--{{ item.state }}">{{ labels[item.state] }}</span>
|
||||
<span>{{ person(item.author, item.author_login) }}</span> · <time>{{ item.created_at }}</time>
|
||||
{% if item.categories %} · <span>{{ item.categories }}</span>{% endif %}
|
||||
{% if item.event_date %} · <span>Evento el {{ item.event_date }}</span>{% endif %}
|
||||
</div>
|
||||
{% if item.description %}<p class="muted">{{ item.description }}</p>{% endif %}
|
||||
{% if item.photo_name %}
|
||||
|
||||
@ -24,26 +24,14 @@
|
||||
value="{{ fields.description if fields else '' }}">
|
||||
<p class="muted small">Una o dos líneas: es lo que se ve en los listados.</p>
|
||||
|
||||
<fieldset class="choices">
|
||||
<legend>Categorías</legend>
|
||||
{% for category in categories %}
|
||||
<label class="choice">
|
||||
<input type="checkbox" name="categories" value="{{ category }}"
|
||||
{{ 'checked' if fields and category in fields.categories }}>
|
||||
{{ category }}
|
||||
</label>
|
||||
{% endfor %}
|
||||
</fieldset>
|
||||
|
||||
{# An event's own date, which is not the day the post goes up. Shown whenever
|
||||
a post can be written: ticking Evento above is what makes these required,
|
||||
checked on the server rather than hidden and shown with a script. #}
|
||||
{# An event's own date, which is not the day the post goes up. The date is
|
||||
also what makes this an event: there is nothing to tick first, so there is
|
||||
no way to say "this is an event" and then not say when. #}
|
||||
<fieldset class="fieldset">
|
||||
<legend>Si es un evento</legend>
|
||||
<p class="muted small">
|
||||
Marca <strong>Evento</strong> arriba y rellena al menos la fecha. El
|
||||
evento aparecerá en la agenda del sitio y se podrá añadir al
|
||||
calendario del móvil.
|
||||
Pon la fecha y será un evento: aparecerá en la agenda del sitio, con el
|
||||
día y el lugar destacados. Déjala vacía y es un artículo normal.
|
||||
</p>
|
||||
|
||||
<label for="event_date">Fecha del evento</label>
|
||||
|
||||
@ -66,12 +66,12 @@ def test_accents_are_folded_not_dropped():
|
||||
|
||||
|
||||
def test_the_frontmatter_marks_an_authored_source(repo, editor, post):
|
||||
publish(post, categories="Gastronomía", description="Un resumen.")
|
||||
publish(post, description="Un resumen.")
|
||||
path, = repo.files
|
||||
fm, body = translate.split_frontmatter(repo.files[path].decode())
|
||||
assert fm["lang"] == "es"
|
||||
assert fm["manual_translation"] is False
|
||||
assert fm["categories"] == ["Gastronomía"]
|
||||
assert "categories" not in fm # the taxonomy is gone, not emptied
|
||||
assert "translated_from" not in fm # what makes it a source, not output
|
||||
assert not translate.is_generated(fm)
|
||||
assert body.strip() == "Texto del artículo."
|
||||
@ -561,7 +561,7 @@ def test_an_event_carries_its_own_date_and_an_ics(repo, editor, post):
|
||||
import yaml
|
||||
post("/comunidad/contenido/post/nuevo",
|
||||
{"title": "Feria de otoño", "body": "Ven.", "date": "2026-10-03",
|
||||
"categories": ["Evento", "Comunidad"], "event_date": "2026-10-24",
|
||||
"event_date": "2026-10-24",
|
||||
"event_time": "18:30", "event_location": "Plaza de Ottakring"})
|
||||
|
||||
path, = repo.files
|
||||
@ -574,21 +574,23 @@ def test_an_event_carries_its_own_date_and_an_ics(repo, editor, post):
|
||||
assert front["outputs"] == ["HTML", "ics"]
|
||||
|
||||
|
||||
def test_the_evento_category_without_a_date_is_refused(repo, editor, post):
|
||||
def test_a_post_with_no_event_date_is_simply_an_article(repo, editor, post):
|
||||
"""There is nothing to tick any more, so there is no "said it was an event
|
||||
and did not say when" to refuse. The date is the whole declaration."""
|
||||
import yaml
|
||||
response = post("/comunidad/contenido/post/nuevo",
|
||||
{"title": "Algún día", "body": "Texto.", "date": "2026-10-03",
|
||||
"categories": ["Evento"]})
|
||||
{"title": "Algún día", "body": "Texto.", "date": "2026-10-03"})
|
||||
|
||||
assert response.status_code == 400
|
||||
assert "necesita fecha" in response.get_data(as_text=True)
|
||||
assert repo.files == {}
|
||||
assert response.status_code == 302
|
||||
path, = repo.files
|
||||
front = yaml.safe_load(repo.files[path].decode().split("---")[1])
|
||||
assert "event_date" not in front
|
||||
|
||||
|
||||
def test_a_nonsense_hour_is_refused(repo, editor, post):
|
||||
response = post("/comunidad/contenido/post/nuevo",
|
||||
{"title": "Feria", "body": "Texto.", "date": "2026-10-03",
|
||||
"categories": ["Evento"], "event_date": "2026-10-24",
|
||||
"event_time": "25:99"})
|
||||
"event_date": "2026-10-24", "event_time": "25:99"})
|
||||
|
||||
assert response.status_code == 400
|
||||
assert repo.files == {}
|
||||
@ -599,7 +601,7 @@ def test_an_ordinary_post_carries_no_event_lines(repo, editor, post):
|
||||
import yaml
|
||||
post("/comunidad/contenido/post/nuevo",
|
||||
{"title": "Un artículo", "body": "Texto.", "date": "2026-10-03",
|
||||
"categories": ["Cultura"], "event_date": "2026-10-24"})
|
||||
"event_date": ""})
|
||||
|
||||
path, = repo.files
|
||||
front = yaml.safe_load(repo.files[path].decode().split("---")[1])
|
||||
@ -612,7 +614,7 @@ def test_an_event_keeps_its_date_when_edited(repo, editor, post, client):
|
||||
repo.files["content/post/2026-10-03-feria.es.md"] = (
|
||||
"---\ntitle: Feria\ndate: 2026-10-03\nlang: es\nmanual_translation: false\n"
|
||||
"event_date: '2026-10-24'\nevent_time: '18:30'\n"
|
||||
"event_location: La plaza\ncategories:\n- Evento\n---\n\nVen.\n").encode("utf-8")
|
||||
"event_location: La plaza\n---\n\nVen.\n").encode("utf-8")
|
||||
|
||||
body = client.get("/comunidad/contenido/post/editar/2026-10-03-feria.es.md").get_data(as_text=True)
|
||||
assert 'value="2026-10-24"' in body
|
||||
@ -620,7 +622,7 @@ def test_an_event_keeps_its_date_when_edited(repo, editor, post, client):
|
||||
|
||||
post("/comunidad/contenido/post/editar/2026-10-03-feria.es.md",
|
||||
{"title": "Feria", "body": "Ven pronto.", "date": "2026-10-03",
|
||||
"categories": ["Evento"], "event_date": "2026-10-24",
|
||||
"event_date": "2026-10-24",
|
||||
"event_time": "18:30", "event_location": "La plaza",
|
||||
"sha": repo._sha(repo.files["content/post/2026-10-03-feria.es.md"])})
|
||||
|
||||
|
||||
@ -319,3 +319,43 @@ def test_the_app_starts_against_a_database_from_before_all_this(tmp_path):
|
||||
create_app({"SECRET_KEY": "x", "DB_PATH": path, "OWNER_LOGIN": "salvador",
|
||||
"UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True})
|
||||
db.close()
|
||||
|
||||
|
||||
def test_step_six_drops_the_category_columns_and_keeps_the_rows(tmp_path):
|
||||
"""The categories are gone; the two columns that held them go with them.
|
||||
|
||||
Built on the current schema rather than an old one, because the point here
|
||||
is not "does an old database survive" — step 5's test covers that — but
|
||||
that a database which *has* the column loses it without losing anything
|
||||
around it. A dropped column takes its data and nothing else, and a row
|
||||
written before the drop still reads afterwards.
|
||||
"""
|
||||
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)
|
||||
# Put the column back and fill it, as a server that has been running since
|
||||
# before this phase would have it.
|
||||
db.execute("ALTER TABLE content_cache ADD COLUMN categories TEXT NOT NULL DEFAULT ''")
|
||||
db.execute("""INSERT INTO content_cache (path, sha, title, date, categories, event_date)
|
||||
VALUES ('content/post/2026-10-24-feria.es.md', 'abc', 'Feria',
|
||||
'2026-10-24', 'Evento, Comunidad', '2026-11-07')""")
|
||||
db.execute("PRAGMA user_version = 5")
|
||||
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)
|
||||
columns = {row[1] for row in db.execute("PRAGMA table_info(content_cache)")}
|
||||
assert "categories" not in columns
|
||||
row = db.execute("SELECT title, event_date FROM content_cache").fetchone()
|
||||
assert (row["title"], row["event_date"]) == ("Feria", "2026-11-07")
|
||||
assert db.execute("PRAGMA user_version").fetchone()[0] == max(
|
||||
number for number, _, _ in migrations.STEPS)
|
||||
db.close()
|
||||
|
||||
@ -73,11 +73,10 @@ def test_a_proposal_is_a_row_and_not_a_commit(repo, db, post, maria, sign_in):
|
||||
"""The whole point of the table. If this ever commits, the post is on
|
||||
vienalatina.com before anybody has read it."""
|
||||
sign_in(maria)
|
||||
propose(post, description="Una feria", categories=["Comunidad"])
|
||||
propose(post, description="Una feria")
|
||||
|
||||
row = only_submission(db)
|
||||
assert (row["state"], row["title"], row["categories"]) == (
|
||||
"pending", "Feria en Ottakring", "Comunidad")
|
||||
assert (row["state"], row["title"]) == ("pending", "Feria en Ottakring")
|
||||
assert repo.files == {}
|
||||
assert repo.commits == []
|
||||
|
||||
@ -189,7 +188,7 @@ def test_approving_commits_once_under_the_author_is_name(
|
||||
"""Attribution is the reason `write_file` takes an author at all. A post
|
||||
approved by Luisa but written by María has to say María in git."""
|
||||
sign_in(maria)
|
||||
propose(post, categories=["Comunidad"])
|
||||
propose(post)
|
||||
submission_id = only_submission(db)["id"]
|
||||
|
||||
sign_in(luisa)
|
||||
@ -205,11 +204,11 @@ def test_approving_commits_once_under_the_author_is_name(
|
||||
|
||||
def test_the_approved_file_is_what_the_pipeline_expects(repo, db, post, maria,
|
||||
luisa, sign_in):
|
||||
"""The same contract the editor's own tests hold it to: Spanish source, no
|
||||
`translated_from`, categories as a list."""
|
||||
"""The same contract the editor's own tests hold it to: a Spanish source
|
||||
with no `translated_from`."""
|
||||
import yaml
|
||||
sign_in(maria)
|
||||
propose(post, categories=["Comunidad", "Cultura"], description="Una feria")
|
||||
propose(post, description="Una feria")
|
||||
submission_id = only_submission(db)["id"]
|
||||
|
||||
sign_in(luisa)
|
||||
@ -220,7 +219,7 @@ def test_the_approved_file_is_what_the_pipeline_expects(repo, db, post, maria,
|
||||
front = yaml.safe_load(text.split("---")[1])
|
||||
assert front["lang"] == "es"
|
||||
assert front["manual_translation"] is False
|
||||
assert front["categories"] == ["Comunidad", "Cultura"]
|
||||
assert "categories" not in front
|
||||
assert front["description"] == "Una feria"
|
||||
assert "translated_from" not in front
|
||||
assert "empanadas" in text
|
||||
@ -477,7 +476,7 @@ def test_a_member_can_propose_an_event_and_it_keeps_its_date(
|
||||
site is the one the member described, dated when it happens."""
|
||||
import yaml
|
||||
sign_in(maria)
|
||||
propose(post, categories=["Evento"], event_date="2026-11-07",
|
||||
propose(post, event_date="2026-11-07",
|
||||
event_time="20:00", event_location="Sala Ottakring")
|
||||
submission_id = only_submission(db)["id"]
|
||||
|
||||
@ -492,10 +491,13 @@ def test_a_member_can_propose_an_event_and_it_keeps_its_date(
|
||||
assert front["author"] == "Maria"
|
||||
|
||||
|
||||
def test_an_event_proposal_without_a_date_is_refused(db, post, maria, sign_in):
|
||||
def test_a_proposal_with_a_nonsense_event_date_is_refused(db, post, maria, sign_in):
|
||||
"""A proposal with no date at all is just an article, so there is nothing
|
||||
left to refuse there — the date is the declaration. A date that is not a
|
||||
date still is."""
|
||||
sign_in(maria)
|
||||
|
||||
response = propose(post, categories=["Evento"])
|
||||
response = propose(post, event_date="el martes")
|
||||
|
||||
assert response.status_code == 400
|
||||
assert db.execute("SELECT COUNT(*) AS n FROM submissions").fetchone()["n"] == 0
|
||||
|
||||
@ -207,3 +207,48 @@ def test_the_form_rule_is_an_exclusion_and_not_a_list_of_accepted_types():
|
||||
)
|
||||
for typed_in in ("password", "number", "email", "date", "text", "search", "url"):
|
||||
assert typed_in not in excluded, f"{typed_in} is a box somebody types in"
|
||||
|
||||
|
||||
# --- the theme's own chrome -----------------------------------------------
|
||||
#
|
||||
# These two read the Hugo theme rather than the members area, which no other
|
||||
# test here does. They are here because the bug they guard against is this
|
||||
# suite's recurring shape — CSS that expects markup nobody wrote — and because
|
||||
# pytest is the only thing in this repository that runs on every commit.
|
||||
|
||||
THEME = Path(__file__).resolve().parents[3] / "themes" / "vienalatina"
|
||||
|
||||
|
||||
def test_the_collapsed_menu_has_something_that_can_open_it():
|
||||
"""The one that shipped: `main.css` hid `.site-bar__pages` below 768px and
|
||||
showed it again on a toggle, the hamburger's own styles were ported with
|
||||
it, and `header.html` never got the button. For three phases the public
|
||||
site had no navigation at all on a phone — every rule correct, every
|
||||
selector pointing at an element that did not exist.
|
||||
|
||||
So: if the stylesheet hides the menu behind a state, the header has to carry
|
||||
that state and the control that flips it.
|
||||
"""
|
||||
css = (THEME / "assets" / "css" / "main.css").read_text(encoding="utf-8")
|
||||
header = (THEME / "layouts" / "partials" / "header.html").read_text(encoding="utf-8")
|
||||
|
||||
assert ".site-menu__state:checked ~ .site-bar__pages" in css, (
|
||||
"main.css no longer opens the mobile menu from the checkbox. If the "
|
||||
"mechanism changed, change this test with it — but check first that the "
|
||||
"menu still opens on a phone."
|
||||
)
|
||||
for needed in ('id="site-menu"', 'class="site-menu__state"', 'for="site-menu"'):
|
||||
assert needed in header, (
|
||||
f"header.html has no {needed}. The CSS hides the menu on a phone and "
|
||||
"only shows it again on that checkbox, so without it the site has no "
|
||||
"navigation below 768px."
|
||||
)
|
||||
|
||||
|
||||
def test_the_way_into_the_members_area_is_in_the_bar_itself():
|
||||
"""Not in the menu. It was a menu entry, which on a phone put it inside a
|
||||
menu that did not open — and even on a desktop made the one link that is not
|
||||
content look like one of the pages."""
|
||||
header = (THEME / "layouts" / "partials" / "header.html").read_text(encoding="utf-8")
|
||||
bar = header.split('<nav class="site-bar__pages"')[0]
|
||||
assert "site-bar__cta" in bar and "/comunidad/" in bar
|
||||
|
||||
35
config.yaml
35
config.yaml
@ -21,9 +21,11 @@ defaultContentLanguageInSubdir: false
|
||||
permalinks:
|
||||
post: "/:year/:month/:day/:slug/"
|
||||
|
||||
taxonomies:
|
||||
category: "categories"
|
||||
tag: "tags"
|
||||
# No taxonomies. An empty map rather than no `taxonomies` key at all: leaving
|
||||
# the key out restores Hugo's own defaults, which are `tags` and `categories` —
|
||||
# so deleting the block built the very pages it was meant to remove. This turns
|
||||
# them off, and /categories/… and /tags/ fall through to the site's 404.
|
||||
taxonomies: {}
|
||||
|
||||
languages:
|
||||
es:
|
||||
@ -32,22 +34,21 @@ languages:
|
||||
weight: 1
|
||||
params:
|
||||
description: "Comunidad latinoamericana en Viena — turismo, cultura, gastronomía, comunidad y comercio."
|
||||
# Only the two ends of the menu live here. Everything between them is built
|
||||
# from the pages themselves by partials/header.html — so a page published
|
||||
# from the members area appears on the site, with its own translated title,
|
||||
# instead of needing three edits in this file. Weight decides the side:
|
||||
# under 5 goes before the pages, 5 or more after them.
|
||||
# Only Inicio lives here. Everything after it is built from the pages
|
||||
# themselves by partials/header.html — so a page published from the members
|
||||
# area appears on the site, with its own translated title, instead of
|
||||
# needing three edits in this file. Weight decides the side: under 5 goes
|
||||
# before the pages, 5 or more after them.
|
||||
#
|
||||
# Comunidad used to be the entry at weight 9. It is a button in the header
|
||||
# bar now rather than a word in the menu, so its three translations live in
|
||||
# partials/t.html — the URL is the same in every language, and a menu entry
|
||||
# was only ever carrying the label.
|
||||
menus:
|
||||
main:
|
||||
- name: "Inicio"
|
||||
url: "/"
|
||||
weight: 1
|
||||
# The way into the members area, in the menu for everybody: somebody who
|
||||
# has an account needs to find the door, and somebody who does not should
|
||||
# at least see that there is one.
|
||||
- name: "Comunidad"
|
||||
url: "/comunidad/"
|
||||
weight: 9
|
||||
de:
|
||||
languageCode: "de"
|
||||
languageName: "Deutsch"
|
||||
@ -59,9 +60,6 @@ languages:
|
||||
- name: "Start"
|
||||
url: "/de/"
|
||||
weight: 1
|
||||
- name: "Community"
|
||||
url: "/comunidad/"
|
||||
weight: 9
|
||||
pt-br:
|
||||
languageCode: "pt-BR"
|
||||
languageName: "Português (Brasil)"
|
||||
@ -73,9 +71,6 @@ languages:
|
||||
- name: "Início"
|
||||
url: "/pt-br/"
|
||||
weight: 1
|
||||
- name: "Comunidade"
|
||||
url: "/comunidad/"
|
||||
weight: 9
|
||||
|
||||
params:
|
||||
# The picture a share card falls back on when a post or page has none, and the
|
||||
|
||||
@ -264,7 +264,6 @@ title: "Artículo de prueba"
|
||||
date: 2026-08-01
|
||||
lang: es
|
||||
manual_translation: false
|
||||
categories: [Comunidad]
|
||||
---
|
||||
|
||||
Esto es una prueba del flujo de traducción automática en el Grätzl.
|
||||
@ -807,7 +806,7 @@ profile:
|
||||
```sh
|
||||
sudo caddy validate --config /etc/caddy/Caddyfile
|
||||
sudo systemctl reload caddy
|
||||
for path in / /de/ /pt-br/ /page/acerca/ /categories/ /robots.txt /comunidad/ /noexiste; do
|
||||
for path in / /de/ /pt-br/ /page/acerca/ /page/agenda/ /robots.txt /comunidad/ /noexiste; do
|
||||
printf '%-20s %s\n' "$path" "$(curl -s -o /dev/null -w '%{http_code}' https://vienalatina.com$path)"
|
||||
done
|
||||
```
|
||||
@ -932,16 +931,22 @@ so nothing in the Caddyfile, the pipeline or the editor's filename rules has to
|
||||
learn about folders. The dropdown is the one the theme already had, ported from
|
||||
WordPress: hover and `:focus-within`, inline on a phone, no script.
|
||||
|
||||
Only *Inicio* and *Comunidad* remain in `config.yaml`. Weight under 5 puts a menu
|
||||
entry before the pages, 5 or more after them.
|
||||
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.15b Two calendars
|
||||
|
||||
**Public events are posts** in the **Evento** category, with three fields of
|
||||
their own: `event_date`, `event_time` and `event_location`. The post's own `date`
|
||||
is when it was announced — usually weeks earlier, and what Hugo sorts the blog by
|
||||
— so the event's date cannot be the same field. Ticking Evento without a date is
|
||||
refused. Members can propose events exactly as they propose anything else, and a
|
||||
**Public events are posts carrying an `event_date`**, with two more fields of
|
||||
their own: `event_time` and `event_location`. The post's own `date` is when it
|
||||
was announced — usually weeks earlier, and what Hugo sorts the blog by — so the
|
||||
event's date cannot be the same field.
|
||||
|
||||
**The date is the whole declaration.** There used to be an «Evento» category to
|
||||
tick first, and ticking it without filling the date in was an error the form had
|
||||
to refuse; with the categories gone there is nothing to tick, and no way left to
|
||||
say "this is an event" without saying when. A date that is not a date is still
|
||||
refused. Members propose events exactly as they propose anything else, and a
|
||||
moderator approves them.
|
||||
|
||||
An event's page leads with the day, the time and the place, shows its picture
|
||||
@ -1074,6 +1079,42 @@ needs nothing — it walks `content/` only, and `data/` and `static/` are outsid
|
||||
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.
|
||||
|
||||
### 11.19 The chrome on a phone
|
||||
|
||||
**The public menu opens from a ☰ below 768px**, and above it is the horizontal
|
||||
strip it has always been. No JavaScript: `header.html` carries a visually hidden
|
||||
checkbox immediately before the menu, the ☰ is a `<label>` for it anywhere in the
|
||||
bar, and one rule in `main.css` —
|
||||
`.site-menu__state:checked ~ .site-bar__pages { display: flex }` — does the rest.
|
||||
|
||||
That is worth knowing because of how it was broken. The panel's styles, the ☰'s
|
||||
styles and the animated ✕ were all ported from the WordPress theme when the menu
|
||||
was built; the **button was not**, and nothing ever set the class the CSS was
|
||||
waiting for. So for three phases every phone saw the site with no navigation at
|
||||
all — brand, language letters, posts — while every rule involved was correct.
|
||||
`apps/board/tests/test_templates.py` now fails if the stylesheet hides the menu
|
||||
behind a state the header does not carry.
|
||||
|
||||
*Why a checkbox and not `<details>`*, which is this project's usual answer for a
|
||||
control without a script: on desktop this menu has to be open and horizontal, and
|
||||
current Chrome hides a closed `<details>`'s content with `content-visibility` on
|
||||
`::details-content`, which a `display` rule on the child no longer overrides. A
|
||||
checkbox behaves the same in every engine. It stays in the tab order and keeps
|
||||
its label, so the menu opens from a keyboard.
|
||||
|
||||
**Comunidad is a button in the bar**, at every width — brand-coloured through the
|
||||
same tokens Gestión → Marca writes, so it follows the site's colours. Its three
|
||||
translations are in `partials/t.html` rather than in three `menus.main` blocks:
|
||||
the URL is the same in every language, so the menu entry was only ever carrying
|
||||
a label. The language switcher is **rendered twice**, in the bar for desktop and
|
||||
at the foot of the menu panel for the phone — a brand, a button, a ☰ and three
|
||||
language letters do not fit across 360px, and CSS cannot lift an element out of
|
||||
the bar and into the panel.
|
||||
|
||||
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.
|
||||
|
||||
## 12. Make Gitea look like the site
|
||||
|
||||
Members sign in to `/comunidad/` through Gitea, so Gitea's sign-in form and its
|
||||
|
||||
@ -57,9 +57,7 @@ def build_provider():
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
CONTENT_DIR = REPO_ROOT / "content"
|
||||
|
||||
# Frontmatter strings translated alongside the body. Note `categories` is
|
||||
# deliberately absent: the taxonomy terms stay Spanish in every language, or
|
||||
# Hugo would fork the taxonomy per language.
|
||||
# Frontmatter strings translated alongside the body.
|
||||
# `event_location` is deliberately absent: an address is how somebody finds the
|
||||
# place, and a translated street or venue name is worse than an untranslated one.
|
||||
# `event_date` and `event_time` are data, not prose.
|
||||
|
||||
@ -168,6 +168,13 @@ img { max-width: 100%; height: auto; }
|
||||
|
||||
.lang-btn:hover { color: var(--text, #1a0d09); }
|
||||
|
||||
/* A finger is about 44px across and this button is 20px tall with a mouse in
|
||||
mind. Widened only where the pointer is coarse, so the desktop bar keeps its
|
||||
proportions and the phone gets something hittable. */
|
||||
@media (pointer: coarse) {
|
||||
.lang-btn { padding: 12px 10px; }
|
||||
}
|
||||
|
||||
.lang-btn[aria-pressed="true"] {
|
||||
color: var(--brand, #c0391c);
|
||||
background: var(--brand-softer, #fdf1ed);
|
||||
@ -287,6 +294,52 @@ img { max-width: 100%; height: auto; }
|
||||
color: var(--muted, #5c3d37);
|
||||
}
|
||||
|
||||
/* The way into the members area, as a button rather than a word in the menu.
|
||||
In the bar at every width, so a phone never has to open a menu to find it.
|
||||
Brand-coloured through the tokens, so it follows whatever an admin picks in
|
||||
Gestión → Marca. */
|
||||
.site-bar__cta {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
background: var(--brand, #c0391c);
|
||||
color: #fff;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
padding: 9px 16px;
|
||||
border-radius: 999px;
|
||||
white-space: nowrap;
|
||||
text-decoration: none;
|
||||
transition: background 140ms ease;
|
||||
}
|
||||
.site-bar__cta:hover {
|
||||
background: var(--brand-dark, #9a2a0f);
|
||||
color: #fff;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* The menu's state. Visually hidden but still focusable and still announced:
|
||||
`display: none` or `hidden` would take it out of the tab order and leave the
|
||||
menu unopenable from a keyboard. */
|
||||
.site-menu__state {
|
||||
position: absolute;
|
||||
width: 1px;
|
||||
height: 1px;
|
||||
margin: -1px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
overflow: hidden;
|
||||
clip-path: inset(50%);
|
||||
white-space: nowrap;
|
||||
}
|
||||
/* Focus lands on the invisible checkbox, so the ring has to be drawn on the ☰
|
||||
it drives — otherwise tabbing to the menu looks like tabbing to nothing. */
|
||||
.site-menu__state:focus-visible ~ .site-bar__inner .site-bar__hamburger,
|
||||
.site-bar__inner:has(~ .site-menu__state:focus-visible) .site-bar__hamburger {
|
||||
outline: 2px solid var(--brand-dark, #9a2a0f);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
/* Hamburger — hidden on desktop, visible on mobile */
|
||||
.site-bar__hamburger {
|
||||
display: none;
|
||||
@ -319,14 +372,19 @@ img { max-width: 100%; height: auto; }
|
||||
transition: transform 200ms ease, opacity 200ms ease;
|
||||
}
|
||||
|
||||
/* Animated X when open */
|
||||
.site-bar__hamburger[aria-expanded="true"] .hamburger-line:nth-child(1) {
|
||||
/* Animated X when open.
|
||||
Through :has(), because the ☰ sits in the bar and the checkbox that holds the
|
||||
state is a sibling of the menu below it — there is no selector from one to
|
||||
the other without it. Purely decorative: in a browser without :has() the ☰
|
||||
stays three lines and the menu still opens, which is why this is the one
|
||||
place :has() is load-bearing for nothing. */
|
||||
.site-bar:has(.site-menu__state:checked) .hamburger-line:nth-child(1) {
|
||||
transform: translateY(7.5px) rotate(45deg);
|
||||
}
|
||||
.site-bar__hamburger[aria-expanded="true"] .hamburger-line:nth-child(2) {
|
||||
.site-bar:has(.site-menu__state:checked) .hamburger-line:nth-child(2) {
|
||||
opacity: 0;
|
||||
}
|
||||
.site-bar__hamburger[aria-expanded="true"] .hamburger-line:nth-child(3) {
|
||||
.site-bar:has(.site-menu__state:checked) .hamburger-line:nth-child(3) {
|
||||
transform: translateY(-7.5px) rotate(-45deg);
|
||||
}
|
||||
|
||||
@ -380,7 +438,18 @@ img { max-width: 100%; height: auto; }
|
||||
background: var(--surface, #fff);
|
||||
}
|
||||
|
||||
/* On mobile/tablet the nav is collapsed and toggled by the hamburger */
|
||||
/* The switcher at the foot of the mobile panel — the second copy. Hidden on
|
||||
desktop, where the one in the bar is the real one. */
|
||||
.site-bar__pages-lang { display: none; }
|
||||
|
||||
/* On mobile/tablet the nav is collapsed and opened by the ☰.
|
||||
*
|
||||
* This is what was missing: these rules were ported from the WordPress theme
|
||||
* along with the hamburger's own styles, but the button was never ported with
|
||||
* them and nothing ever set `is-open`. For three phases the menu was
|
||||
* display:none on every phone with nothing in existence that could show it —
|
||||
* the site simply had no navigation below 768px. The selector below is a
|
||||
* sibling of the checkbox in header.html, which is the whole mechanism. */
|
||||
@media (max-width: 768px) {
|
||||
.site-bar__pages {
|
||||
display: none;
|
||||
@ -390,14 +459,40 @@ img { max-width: 100%; height: auto; }
|
||||
box-shadow: 0 4px 16px rgba(60, 20, 10, 0.08);
|
||||
}
|
||||
|
||||
.site-bar__pages.is-open {
|
||||
.site-menu__state:checked ~ .site-bar__pages {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
/* The bar's own switcher goes, the panel's arrives: four things do not fit
|
||||
across a 360px bar. The button takes over the auto margin that used to
|
||||
push the switcher right, so it sits against the ☰ rather than floating in
|
||||
the middle of the bar. */
|
||||
.site-bar__nav { display: none; }
|
||||
.site-bar__cta { margin-left: auto; font-size: 0.8rem; padding: 9px 14px; }
|
||||
.site-bar__pages-lang {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
margin: 4px 16px 0;
|
||||
padding-top: 10px;
|
||||
border-top: 1px solid var(--border-light, #e0cec8);
|
||||
}
|
||||
.site-bar__pages-lang .lang-switcher {
|
||||
border-right: 0;
|
||||
padding-right: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.page-nav {
|
||||
flex-direction: column;
|
||||
padding: 0;
|
||||
overflow: visible;
|
||||
/* The desktop rule centres the strip with `margin: 0 auto`. An auto margin
|
||||
on the cross axis beats a flex item's stretch, so in this column the
|
||||
whole menu shrank to the width of its longest word and sat in the middle
|
||||
of the screen with the items starting at 43% — which is what it did the
|
||||
first time this panel was ever rendered. */
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.page-nav li a {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{{/* Category / archive listing — article-card markup from the WP theme feed. */}}
|
||||
{{/* Section and term listings — article-card markup from the WP theme feed. */}}
|
||||
{{ define "main" }}
|
||||
<main class="feed">
|
||||
<h1 class="feed__title">{{ .Title }}</h1>
|
||||
@ -6,9 +6,6 @@
|
||||
{{ range .Pages }}
|
||||
<article class="article-card">
|
||||
<div class="article-card__meta">
|
||||
{{ range first 1 (.GetTerms "categories") }}
|
||||
<a class="article-card__kind" href="{{ .Permalink }}">{{ .LinkTitle }}</a>
|
||||
{{ end }}
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 Jan 2006" }}</time>
|
||||
</div>
|
||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||
|
||||
@ -7,9 +7,6 @@
|
||||
<header class="article-single__head">
|
||||
<div>
|
||||
<div class="article-card__meta">
|
||||
{{ range first 1 (.GetTerms "categories") }}
|
||||
<a class="article-card__kind" href="{{ .Permalink }}">{{ .LinkTitle }}</a>
|
||||
{{ end }}
|
||||
<time datetime="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}">
|
||||
{{ .Date.Format "2 Jan 2006" }}
|
||||
</time>
|
||||
|
||||
@ -4,9 +4,6 @@
|
||||
{{ range first 20 (where .Site.RegularPages "Section" "post") }}
|
||||
<article class="article-card">
|
||||
<div class="article-card__meta">
|
||||
{{ range first 1 (.GetTerms "categories") }}
|
||||
<a class="article-card__kind" href="{{ .Permalink }}">{{ .LinkTitle }}</a>
|
||||
{{ end }}
|
||||
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 Jan 2006" }}</time>
|
||||
</div>
|
||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||
|
||||
@ -1,27 +1,26 @@
|
||||
{{/* BreadcrumbList — where this page sits, for a search result and for an answer
|
||||
engine deciding what a page is about.
|
||||
|
||||
Two levels for a page (Inicio → this), three for an article (Inicio → its
|
||||
category → this). Nothing is rendered visibly: the site is shallow enough
|
||||
that a visible trail would be clutter, while the machine-readable one still
|
||||
answers "what is this page part of".
|
||||
Two levels: Inicio → this. An article used to carry its category in the
|
||||
middle; there are no categories any more, and a post is a child of the home
|
||||
page. Nothing is rendered visibly: the site is shallow enough that a visible
|
||||
trail would be clutter, while the machine-readable one still answers "what
|
||||
is this page part of".
|
||||
|
||||
A subpage says Inicio → its parent → itself, read from the same `parent`
|
||||
basename the menu is built from, so the trail and the menu cannot disagree. */}}
|
||||
{{ $items := slice (dict "@type" "ListItem" "position" 1 "name" "Inicio" "item" .Site.Home.Permalink) }}
|
||||
{{ $position := 2 }}
|
||||
|
||||
{{ if eq .Section "post" }}
|
||||
{{ range first 1 (.GetTerms "categories") }}
|
||||
{{ $items = $items | append (dict "@type" "ListItem" "position" $position "name" .LinkTitle "item" .Permalink) }}
|
||||
{{ $position = add $position 1 }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ if ne .Section "post" }}
|
||||
{{ with .Params.parent }}
|
||||
{{ $base := . }}
|
||||
{{ range where $.Site.RegularPages "Section" "page" }}
|
||||
{{ with .File }}{{ if eq .ContentBaseName $base }}
|
||||
{{ $items = $items | append (dict "@type" "ListItem" "position" $position "name" $.Page.Title "item" $.Permalink) }}
|
||||
{{/* Was missing: only the category branch bumped the position, so a subpage
|
||||
emitted its parent and itself both at position 2. */}}
|
||||
{{ $position = add $position 1 }}
|
||||
{{ end }}{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
@ -22,10 +22,48 @@
|
||||
</a>
|
||||
|
||||
<nav class="site-bar__nav" aria-label="Idioma">
|
||||
{{/* Desktop only; the mobile copy is at the foot of the menu panel
|
||||
below. Rendered twice rather than moved, because at 360px the bar
|
||||
cannot hold a brand, a button, a ☰ and three language letters
|
||||
without something wrapping — and CSS cannot lift an element out
|
||||
of the bar and into the panel. */}}
|
||||
{{ partial "lang-switcher.html" . }}
|
||||
</nav>
|
||||
|
||||
{{/* The way into the members area, as a button rather than a word in the
|
||||
menu. It is the one link on this site that is not content: somebody
|
||||
who has an account needs to find the door at a glance, and somebody
|
||||
who does not should see that there is one. In the bar at every width,
|
||||
so a phone never has to open a menu to find it. */}}
|
||||
<a class="site-bar__cta" href="/comunidad/">{{ partial "t.html" (dict "key" "community" "lang" .Site.Language.Lang) }}</a>
|
||||
|
||||
{{/* The ☰ itself. A <label> can sit anywhere in the document, so the
|
||||
checkbox it drives lives below, as a sibling of the menu it opens —
|
||||
which is what lets one CSS rule show the menu with no script. */}}
|
||||
<label class="site-bar__hamburger" for="site-menu" aria-hidden="true">
|
||||
<span class="hamburger-line"></span>
|
||||
<span class="hamburger-line"></span>
|
||||
<span class="hamburger-line"></span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{{/* The state of the menu, as a checkbox, immediately before the menu so
|
||||
that `:checked ~ .site-bar__pages` reaches it.
|
||||
|
||||
A checkbox rather than a <details>, which is this project's usual answer
|
||||
for a menu without a script. It does not work here: on desktop this menu
|
||||
has to be open and horizontal, and current Chrome hides a closed
|
||||
<details>'s content with content-visibility on ::details-content, which
|
||||
a display rule on the child no longer overrides. The trick that made
|
||||
that work has gone; a checkbox behaves the same in every engine.
|
||||
|
||||
Visually hidden but not `hidden`: it keeps its place in the tab order,
|
||||
right before the menu it controls, and is announced with its own label —
|
||||
so the menu opens from a keyboard. The ☰ above is aria-hidden because it
|
||||
would otherwise be read a second time as the same control. */}}
|
||||
<input id="site-menu" class="site-menu__state" type="checkbox"
|
||||
aria-label="{{ partial "t.html" (dict "key" "menu" "lang" .Site.Language.Lang) }}">
|
||||
|
||||
{{/* The menu is built from the pages themselves, not from a list in
|
||||
config.yaml. It used to be three names written there, which meant a page
|
||||
published from the members area never appeared on the site at all — and
|
||||
@ -97,5 +135,12 @@
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
|
||||
{{/* The language switcher again, for the phone. The copy in the bar is
|
||||
hidden below 768px and this one is shown — see the note up there for
|
||||
why it is rendered twice rather than moved. */}}
|
||||
<div class="site-bar__pages-lang">
|
||||
{{ partial "lang-switcher.html" . }}
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
@ -57,7 +57,6 @@
|
||||
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}">
|
||||
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" }}">
|
||||
{{ with .Params.author }}<meta property="article:author" content="{{ . }}">{{ end }}
|
||||
{{ range first 1 (.GetTerms "categories") }}<meta property="article:section" content="{{ .LinkTitle }}">{{ end }}
|
||||
|
||||
<meta name="twitter:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}">
|
||||
<meta name="twitter:title" content="{{ .Title }}">
|
||||
|
||||
@ -18,6 +18,8 @@
|
||||
"next" (dict "es" "Mes siguiente" "de" "Nächster Monat" "pt-br" "Próximo mês")
|
||||
"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")
|
||||
"community" (dict "es" "Comunidad" "de" "Community" "pt-br" "Comunidade")
|
||||
"menu" (dict "es" "Menú" "de" "Menü" "pt-br" "Menu")
|
||||
-}}
|
||||
{{- $entry := index $words .key -}}
|
||||
{{- if $entry -}}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user