Compare commits
No commits in common. "8f85a27ed11b3ebec7e56b65ae1690231400cebb" and "6c537c3e7e3f0b5ed431e321387c58619c66c7c9" have entirely different histories.
8f85a27ed1
...
6c537c3e7e
@ -59,6 +59,13 @@ 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"
|
UPLOAD_FOLDER = "static/uploads"
|
||||||
|
|
||||||
TITLE_MAX = 140
|
TITLE_MAX = 140
|
||||||
@ -142,6 +149,8 @@ def frontmatter_for(collection: str, form: dict) -> dict:
|
|||||||
# person: it is a build instruction, not something to explain in a form.
|
# person: it is a build instruction, not something to explain in a form.
|
||||||
fields["outputs"] = ["HTML", "ics"]
|
fields["outputs"] = ["HTML", "ics"]
|
||||||
if collection == "post":
|
if collection == "post":
|
||||||
|
if form["categories"]:
|
||||||
|
fields["categories"] = form["categories"]
|
||||||
if form["description"]:
|
if form["description"]:
|
||||||
fields["description"] = form["description"]
|
fields["description"] = form["description"]
|
||||||
if form["image"]:
|
if form["image"]:
|
||||||
@ -172,17 +181,17 @@ def _cache_read(path: str, sha: str):
|
|||||||
|
|
||||||
def _cache_write(path: str, sha: str, fm: dict) -> None:
|
def _cache_write(path: str, sha: str, fm: dict) -> None:
|
||||||
get_db().execute(
|
get_db().execute(
|
||||||
"""INSERT INTO content_cache (path, sha, title, date, generated,
|
"""INSERT INTO content_cache (path, sha, title, date, categories, generated,
|
||||||
event_date, event_time, event_location)
|
event_date, event_time, event_location)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
||||||
ON CONFLICT(path) DO UPDATE SET
|
ON CONFLICT(path) DO UPDATE SET
|
||||||
sha = excluded.sha, title = excluded.title, date = excluded.date,
|
sha = excluded.sha, title = excluded.title, date = excluded.date,
|
||||||
generated = excluded.generated,
|
categories = excluded.categories, generated = excluded.generated,
|
||||||
event_date = excluded.event_date, event_time = excluded.event_time,
|
event_date = excluded.event_date, event_time = excluded.event_time,
|
||||||
event_location = excluded.event_location,
|
event_location = excluded.event_location,
|
||||||
updated_at = datetime('now')""",
|
updated_at = datetime('now')""",
|
||||||
(path, sha, str(fm.get("title", "")), str(fm.get("date", "")),
|
(path, sha, str(fm.get("title", "")), str(fm.get("date", "")),
|
||||||
1 if fm.get("translated_from") else 0,
|
", ".join(fm.get("categories") or []), 1 if fm.get("translated_from") else 0,
|
||||||
# Cached for the private calendar, which shows public events beside the
|
# Cached for the private calendar, which shows public events beside the
|
||||||
# internal ones and would otherwise read every post's frontmatter on
|
# internal ones and would otherwise read every post's frontmatter on
|
||||||
# every page view to find out when they are.
|
# every page view to find out when they are.
|
||||||
@ -214,7 +223,7 @@ def listing(collection: str) -> list[dict]:
|
|||||||
items.append({
|
items.append({
|
||||||
"name": name, "path": path, "sha": sha,
|
"name": name, "path": path, "sha": sha,
|
||||||
"title": row["title"] or name,
|
"title": row["title"] or name,
|
||||||
"date": row["date"],
|
"date": row["date"], "categories": row["categories"],
|
||||||
"event_date": row["event_date"] or "",
|
"event_date": row["event_date"] or "",
|
||||||
"event_time": row["event_time"] or "",
|
"event_time": row["event_time"] or "",
|
||||||
"event_location": row["event_location"] or "",
|
"event_location": row["event_location"] or "",
|
||||||
@ -266,6 +275,8 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
errors.append("La fecha debe tener el formato AAAA-MM-DD.")
|
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
|
# 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
|
# 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
|
# three languages — and the menu is built from these, not from a list in
|
||||||
@ -286,7 +297,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
|
# 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
|
# is when it was announced — often weeks earlier, and the thing Hugo sorts
|
||||||
# the blog by — so the two cannot be the same field.
|
# the blog by — so the two cannot be the same field.
|
||||||
event = read_event_fields(request.form, errors)
|
event = read_event_fields(request.form, categories, errors)
|
||||||
|
|
||||||
faq = clean_faq(request.form.get("faq", ""))
|
faq = clean_faq(request.form.get("faq", ""))
|
||||||
image_alt = request.form.get("image_alt", "").strip()[:200]
|
image_alt = request.form.get("image_alt", "").strip()[:200]
|
||||||
@ -311,7 +322,7 @@ def _read_form(collection: str) -> tuple[dict, str, list[str]]:
|
|||||||
errors.append("El cuerpo no puede estar vacío.")
|
errors.append("El cuerpo no puede estar vacío.")
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
"title": title, "date": when,
|
"title": title, "date": when, "categories": categories,
|
||||||
"description": request.form.get("description", "").strip(),
|
"description": request.form.get("description", "").strip(),
|
||||||
"image": image,
|
"image": image,
|
||||||
"manual_translation": request.form.get("manual_translation") == "on",
|
"manual_translation": request.form.get("manual_translation") == "on",
|
||||||
@ -357,33 +368,27 @@ def commit_picture(data: bytes, filename: str, author=None) -> str:
|
|||||||
return f"/uploads/{name}"
|
return f"/uploads/{name}"
|
||||||
|
|
||||||
|
|
||||||
def read_event_fields(form, errors: list[str]) -> dict:
|
def read_event_fields(form, categories: list[str], errors: list[str]) -> dict:
|
||||||
"""The three fields that make a post an event.
|
"""The three fields that come with the Evento category.
|
||||||
|
|
||||||
**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
|
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
|
moderator and one approved from the queue carry the same frontmatter. The
|
||||||
other two fields stay optional: an event with no time is an all-day event,
|
date is required and the other two are not: an event with no time is an
|
||||||
and one with no place is a mistake somebody can fix later rather than a
|
all-day event, and one with no place is a mistake somebody can fix later
|
||||||
reason to refuse the whole post.
|
rather than a reason to refuse the whole post.
|
||||||
|
|
||||||
Returns empty strings when no date was given, so an ordinary article never
|
Returns empty strings when the category is absent, so an ordinary article
|
||||||
carries empty event lines in its frontmatter.
|
never carries empty event lines in its frontmatter.
|
||||||
"""
|
"""
|
||||||
raw = form.get("event_date", "").strip()
|
if EVENT_CATEGORY not in categories:
|
||||||
if not raw:
|
|
||||||
return {"event_date": "", "event_time": "", "event_location": ""}
|
return {"event_date": "", "event_time": "", "event_location": ""}
|
||||||
|
|
||||||
|
raw = form.get("event_date", "").strip()
|
||||||
try:
|
try:
|
||||||
event_date = datetime.strptime(raw, "%Y-%m-%d").date().isoformat()
|
event_date = datetime.strptime(raw, "%Y-%m-%d").date().isoformat()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
event_date = ""
|
event_date = ""
|
||||||
errors.append("La fecha del evento debe tener el formato AAAA-MM-DD.")
|
errors.append("Un evento necesita fecha, con el formato AAAA-MM-DD.")
|
||||||
|
|
||||||
event_time = form.get("event_time", "").strip()
|
event_time = form.get("event_time", "").strip()
|
||||||
if event_time and not EVENT_TIME.match(event_time):
|
if event_time and not EVENT_TIME.match(event_time):
|
||||||
@ -500,7 +505,7 @@ def new(collection: str):
|
|||||||
meta = _collection_or_404(collection)
|
meta = _collection_or_404(collection)
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
return render_template("content_form.html", collection=collection, meta=meta,
|
return render_template("content_form.html", collection=collection, meta=meta,
|
||||||
item=None, fields=None,
|
categories=CATEGORIES, item=None, fields=None,
|
||||||
body="", today=date_type.today().isoformat(),
|
body="", today=date_type.today().isoformat(),
|
||||||
parents=possible_parents(collection))
|
parents=possible_parents(collection))
|
||||||
|
|
||||||
@ -543,6 +548,7 @@ def edit(collection: str, name: str):
|
|||||||
fields = {
|
fields = {
|
||||||
"title": fm.get("title", ""),
|
"title": fm.get("title", ""),
|
||||||
"date": fm.get("date"),
|
"date": fm.get("date"),
|
||||||
|
"categories": fm.get("categories") or [],
|
||||||
"description": fm.get("description", ""),
|
"description": fm.get("description", ""),
|
||||||
"image": fm.get("image", ""),
|
"image": fm.get("image", ""),
|
||||||
"manual_translation": bool(fm.get("manual_translation")),
|
"manual_translation": bool(fm.get("manual_translation")),
|
||||||
@ -561,7 +567,7 @@ def edit(collection: str, name: str):
|
|||||||
"event_location": fm.get("event_location", ""),
|
"event_location": fm.get("event_location", ""),
|
||||||
}
|
}
|
||||||
return render_template("content_form.html", collection=collection, meta=meta,
|
return render_template("content_form.html", collection=collection, meta=meta,
|
||||||
item={"name": name, "sha": sha},
|
categories=CATEGORIES, item={"name": name, "sha": sha},
|
||||||
fields=fields, body=body,
|
fields=fields, body=body,
|
||||||
today=date_type.today().isoformat(),
|
today=date_type.today().isoformat(),
|
||||||
parents=possible_parents(collection, name))
|
parents=possible_parents(collection, name))
|
||||||
@ -622,7 +628,7 @@ def preview(collection: str):
|
|||||||
sha = request.form.get("sha", "")
|
sha = request.form.get("sha", "")
|
||||||
item = {"name": request.form.get("name", ""), "sha": sha} if sha else None
|
item = {"name": request.form.get("name", ""), "sha": sha} if sha else None
|
||||||
return render_template("content_form.html", collection=collection, meta=meta,
|
return render_template("content_form.html", collection=collection, meta=meta,
|
||||||
item=item, fields=fields, body=body,
|
categories=CATEGORIES, item=item, fields=fields, body=body,
|
||||||
today=date_type.today().isoformat(),
|
today=date_type.today().isoformat(),
|
||||||
parents=possible_parents(collection,
|
parents=possible_parents(collection,
|
||||||
item["name"] if item else ""),
|
item["name"] if item else ""),
|
||||||
@ -680,7 +686,7 @@ def _back_to_form(collection, meta, fields, body, errors, item):
|
|||||||
for message in errors:
|
for message in errors:
|
||||||
flash(message, "error")
|
flash(message, "error")
|
||||||
return render_template("content_form.html", collection=collection, meta=meta,
|
return render_template("content_form.html", collection=collection, meta=meta,
|
||||||
item=item, fields=fields, body=body,
|
categories=CATEGORIES, item=item, fields=fields, body=body,
|
||||||
today=date_type.today().isoformat(),
|
today=date_type.today().isoformat(),
|
||||||
parents=possible_parents(collection,
|
parents=possible_parents(collection,
|
||||||
item["name"] if item else "")), 400
|
item["name"] if item else "")), 400
|
||||||
|
|||||||
@ -3,9 +3,9 @@
|
|||||||
What the association is doing and when, for the people inside: a meeting, a
|
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
|
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
|
nothing here is ever published — no Open Graph, no sitemap, nothing written to
|
||||||
/var/www. That is the whole difference between this and a public post carrying
|
/var/www. That is the whole difference between this and a post in the Evento
|
||||||
an event date, and it is why the two live in different places rather than behind
|
category, and it is why the two live in different places rather than behind a
|
||||||
a flag on one.
|
flag on one.
|
||||||
|
|
||||||
**The public events appear here too**, marked as public and linking to the site,
|
**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
|
because a member should have one place to look rather than two. They come from
|
||||||
|
|||||||
@ -232,23 +232,6 @@ def _rooms_for_a_date_of_its_own(db: sqlite3.Connection) -> None:
|
|||||||
db.execute(f"ALTER TABLE {table} ADD COLUMN {column} TEXT")
|
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
|
# (number, description, function). The number is the value written to
|
||||||
# user_version once the step succeeds.
|
# user_version once the step succeeds.
|
||||||
STEPS = [
|
STEPS = [
|
||||||
@ -257,7 +240,6 @@ STEPS = [
|
|||||||
(3, "members can have a public page", _members_get_a_public_page),
|
(3, "members can have a public page", _members_get_a_public_page),
|
||||||
(4, "members can be moderators", _members_can_moderate),
|
(4, "members can be moderators", _members_can_moderate),
|
||||||
(5, "events carry a date of their own", _rooms_for_a_date_of_its_own),
|
(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,10 +42,6 @@ LINKS_MAX = 8
|
|||||||
# collision harmless rather than dangerous — Hugo wins and the profile is
|
# collision harmless rather than dangerous — Hugo wins and the profile is
|
||||||
# simply unreachable — so this exists to stop somebody discovering months later
|
# simply unreachable — so this exists to stop somebody discovering months later
|
||||||
# that their page has never loaded for anybody.
|
# 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 = {
|
RESERVED = {
|
||||||
"de", "pt-br", "es", "en", # language trees
|
"de", "pt-br", "es", "en", # language trees
|
||||||
"page", "post", "posts", "categories", "tags", "category", "tag",
|
"page", "post", "posts", "categories", "tags", "category", "tag",
|
||||||
|
|||||||
@ -189,6 +189,7 @@ CREATE TABLE IF NOT EXISTS content_cache (
|
|||||||
sha TEXT NOT NULL,
|
sha TEXT NOT NULL,
|
||||||
title TEXT NOT NULL DEFAULT '',
|
title TEXT NOT NULL DEFAULT '',
|
||||||
date 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
|
-- Files carrying `translated_from` are the pipeline's output, not anyone's
|
||||||
-- draft. Recorded here so the listing can skip them without re-reading
|
-- draft. Recorded here so the listing can skip them without re-reading
|
||||||
-- every file to find out what it already knew.
|
-- every file to find out what it already knew.
|
||||||
@ -244,9 +245,10 @@ CREATE TABLE IF NOT EXISTS submissions (
|
|||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
body_md TEXT NOT NULL,
|
body_md TEXT NOT NULL,
|
||||||
description TEXT NOT NULL DEFAULT '',
|
description TEXT NOT NULL DEFAULT '',
|
||||||
-- The event's own date, which is also what makes this proposal an event at
|
categories TEXT NOT NULL DEFAULT '', -- comma-separated, as content_cache
|
||||||
-- all. It is not the day it is published: a member announcing a concert three
|
-- Set only when the proposal carries the Evento category. The event's own
|
||||||
-- weeks out is the normal case.
|
-- date, which is not the day it is published: a member announcing a concert
|
||||||
|
-- three weeks out is the normal case.
|
||||||
event_date TEXT,
|
event_date TEXT,
|
||||||
event_time TEXT,
|
event_time TEXT,
|
||||||
event_location TEXT,
|
event_location TEXT,
|
||||||
@ -302,7 +304,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS reactions_one_per_comment
|
|||||||
-- Events the association puts on for its members: a meeting, a rehearsal, a
|
-- 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
|
-- 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
|
-- — nothing here reaches /var/www, the sitemap or a share card, which is the
|
||||||
-- difference between this table and a public post carrying an event date.
|
-- difference between this table and a post with the Evento category.
|
||||||
--
|
--
|
||||||
-- `starts_on` and `starts_at` are kept apart rather than as one timestamp
|
-- `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
|
-- because an event with no time is an ordinary thing ("the whole Saturday") and
|
||||||
|
|||||||
@ -68,10 +68,6 @@ button, input, select, textarea { font: inherit; }
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
gap: 1rem;
|
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; }
|
.site-bar__brand { text-decoration: none; }
|
||||||
@ -88,15 +84,7 @@ button, input, select, textarea { font: inherit; }
|
|||||||
padding: 0.6rem 16px;
|
padding: 0.6rem 16px;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 0.5rem 1.5rem;
|
gap: 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 { color: var(--muted); text-decoration: none; }
|
||||||
.page-nav a:hover { color: var(--brand); }
|
.page-nav a:hover { color: var(--brand); }
|
||||||
|
|||||||
@ -92,14 +92,17 @@ def _read_proposal() -> tuple[dict, list[str]]:
|
|||||||
"""The same fields the editor asks for, minus the ones only a publisher
|
"""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
|
decides: the date is the day it is approved, and `manual_translation` is a
|
||||||
pipeline switch, not something to explain to a member."""
|
pipeline switch, not something to explain to a member."""
|
||||||
|
categories = [c for c in request.form.getlist("categories")
|
||||||
|
if c in content.CATEGORIES]
|
||||||
errors = []
|
errors = []
|
||||||
fields = {
|
fields = {
|
||||||
"title": request.form.get("title", "").strip()[:TITLE_MAX],
|
"title": request.form.get("title", "").strip()[:TITLE_MAX],
|
||||||
"body": request.form.get("body", "").strip()[:BODY_MAX],
|
"body": request.form.get("body", "").strip()[:BODY_MAX],
|
||||||
"description": request.form.get("description", "").strip()[:300],
|
"description": request.form.get("description", "").strip()[:300],
|
||||||
|
"categories": categories,
|
||||||
# The same three fields the editor asks for, read by the same function:
|
# 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.
|
# a member's event and a moderator's have to produce the same post.
|
||||||
**content.read_event_fields(request.form, errors),
|
**content.read_event_fields(request.form, categories, errors),
|
||||||
}
|
}
|
||||||
if not fields["title"]:
|
if not fields["title"]:
|
||||||
errors.append("El título no puede estar vacío.")
|
errors.append("El título no puede estar vacío.")
|
||||||
@ -151,7 +154,8 @@ def propose():
|
|||||||
return redirect(url_for("content.new", collection="post"))
|
return redirect(url_for("content.new", collection="post"))
|
||||||
|
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
return render_template("submission_form.html", item=None, fields=None)
|
return render_template("submission_form.html", item=None, fields=None,
|
||||||
|
categories=content.CATEGORIES)
|
||||||
|
|
||||||
fields, errors = _read_proposal()
|
fields, errors = _read_proposal()
|
||||||
waiting = get_db().execute(
|
waiting = get_db().execute(
|
||||||
@ -175,11 +179,11 @@ def propose():
|
|||||||
photo_name = _store_picture(staged)
|
photo_name = _store_picture(staged)
|
||||||
get_db().execute(
|
get_db().execute(
|
||||||
"""INSERT INTO submissions
|
"""INSERT INTO submissions
|
||||||
(author_id, title, body_md, description, photo_name,
|
(author_id, title, body_md, description, categories, photo_name,
|
||||||
event_date, event_time, event_location)
|
event_date, event_time, event_location)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||||
(g.member["id"], fields["title"], fields["body"], fields["description"],
|
(g.member["id"], fields["title"], fields["body"], fields["description"],
|
||||||
photo_name,
|
", ".join(fields["categories"]), photo_name,
|
||||||
fields["event_date"], fields["event_time"], fields["event_location"]),
|
fields["event_date"], fields["event_time"], fields["event_location"]),
|
||||||
)
|
)
|
||||||
flash("Enviado. Un moderador lo leerá antes de publicarlo.", "ok")
|
flash("Enviado. Un moderador lo leerá antes de publicarlo.", "ok")
|
||||||
@ -213,10 +217,12 @@ def edit(submission_id: int):
|
|||||||
return redirect(url_for("submissions.index"))
|
return redirect(url_for("submissions.index"))
|
||||||
|
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
return render_template("submission_form.html", item=row,
|
return render_template("submission_form.html", item=row, categories=content.CATEGORIES,
|
||||||
fields={
|
fields={
|
||||||
"title": row["title"], "body": row["body_md"],
|
"title": row["title"], "body": row["body_md"],
|
||||||
"description": row["description"],
|
"description": row["description"],
|
||||||
|
"categories": [c.strip() for c in
|
||||||
|
(row["categories"] or "").split(",") if c.strip()],
|
||||||
"event_date": row["event_date"] or "",
|
"event_date": row["event_date"] or "",
|
||||||
"event_time": row["event_time"] or "",
|
"event_time": row["event_time"] or "",
|
||||||
"event_location": row["event_location"] or "",
|
"event_location": row["event_location"] or "",
|
||||||
@ -240,14 +246,14 @@ def edit(submission_id: int):
|
|||||||
|
|
||||||
get_db().execute(
|
get_db().execute(
|
||||||
"""UPDATE submissions
|
"""UPDATE submissions
|
||||||
SET title = ?, body_md = ?, description = ?,
|
SET title = ?, body_md = ?, description = ?, categories = ?,
|
||||||
photo_name = ?, event_date = ?, event_time = ?,
|
photo_name = ?, event_date = ?, event_time = ?,
|
||||||
event_location = ?, state = 'pending', note = NULL,
|
event_location = ?, state = 'pending', note = NULL,
|
||||||
reviewed_by = NULL, reviewed_at = NULL,
|
reviewed_by = NULL, reviewed_at = NULL,
|
||||||
updated_at = datetime('now')
|
updated_at = datetime('now')
|
||||||
WHERE id = ?""",
|
WHERE id = ?""",
|
||||||
(fields["title"], fields["body"], fields["description"],
|
(fields["title"], fields["body"], fields["description"],
|
||||||
photo_name, fields["event_date"],
|
", ".join(fields["categories"]), photo_name, fields["event_date"],
|
||||||
fields["event_time"], fields["event_location"], submission_id),
|
fields["event_time"], fields["event_location"], submission_id),
|
||||||
)
|
)
|
||||||
# Back to pending on every edit, including one made after a rejection: a
|
# Back to pending on every edit, including one made after a rejection: a
|
||||||
@ -314,6 +320,7 @@ def approve(submission_id: int):
|
|||||||
# this and the URL carries it, so a proposal that waited a week should
|
# this and the URL carries it, so a proposal that waited a week should
|
||||||
# not arrive dated a week ago.
|
# not arrive dated a week ago.
|
||||||
"date": date_type.today(),
|
"date": date_type.today(),
|
||||||
|
"categories": [c.strip() for c in (row["categories"] or "").split(",") if c.strip()],
|
||||||
"description": row["description"],
|
"description": row["description"],
|
||||||
"image": "",
|
"image": "",
|
||||||
"manual_translation": False,
|
"manual_translation": False,
|
||||||
@ -412,4 +419,5 @@ def _store_picture(staged: list[dict]) -> str | None:
|
|||||||
def _back_to_form(item, fields, errors):
|
def _back_to_form(item, fields, errors):
|
||||||
for message in errors:
|
for message in errors:
|
||||||
flash(message, "error")
|
flash(message, "error")
|
||||||
return render_template("submission_form.html", item=item, fields=fields), 400
|
return render_template("submission_form.html", item=item, fields=fields,
|
||||||
|
categories=content.CATEGORIES), 400
|
||||||
|
|||||||
@ -66,15 +66,26 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if collection == 'post' %}
|
{% if collection == 'post' %}
|
||||||
{# An event's own date, which is not the day the post goes up. The date is
|
<fieldset class="fieldset">
|
||||||
also what makes this post an event: there is nothing to tick first, so
|
<legend>Categorías</legend>
|
||||||
there is no way to say "this is an event" and then not say when. #}
|
{% 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. #}
|
||||||
<fieldset class="fieldset">
|
<fieldset class="fieldset">
|
||||||
<legend>Si es un evento</legend>
|
<legend>Si es un evento</legend>
|
||||||
<p class="muted small">
|
<p class="muted small">
|
||||||
Pon la fecha y será un evento: aparecerá en la agenda del sitio, con el
|
Marca <strong>Evento</strong> arriba y rellena al menos la fecha. El
|
||||||
día y el lugar destacados, y se podrá añadir al calendario del móvil.
|
evento aparecerá en la agenda del sitio y se podrá añadir al
|
||||||
Déjala vacía y es un artículo normal.
|
calendario del móvil.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<label for="event_date">Fecha del evento</label>
|
<label for="event_date">Fecha del evento</label>
|
||||||
|
|||||||
@ -21,7 +21,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr><th>Título</th>{% if meta.dated %}<th>Fecha</th>{% endif %}{% if meta.dated %}<th>Evento</th>{% endif %}<th></th></tr>
|
<tr><th>Título</th>{% if meta.dated %}<th>Fecha</th>{% endif %}<th>Categorías</th><th></th></tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for item in items %}
|
{% for item in items %}
|
||||||
@ -31,10 +31,7 @@
|
|||||||
<div class="muted small mono">{{ item.name }}</div>
|
<div class="muted small mono">{{ item.name }}</div>
|
||||||
</td>
|
</td>
|
||||||
{% if meta.dated %}<td>{{ item.date }}</td>{% endif %}
|
{% if meta.dated %}<td>{{ item.date }}</td>{% endif %}
|
||||||
{# The column that used to hold the categories. An event date is the
|
<td>{{ item.categories }}</td>
|
||||||
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
|
{# 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
|
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
|
table cell: it leaves the row's layout and draws its bottom border
|
||||||
|
|||||||
@ -36,6 +36,6 @@
|
|||||||
<p class="muted small">
|
<p class="muted small">
|
||||||
Este evento sólo se ve desde el área de miembros. Para anunciar algo a todo
|
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>
|
el mundo, usa <a href="{{ url_for('submissions.index') }}">Publicaciones</a>
|
||||||
poniéndole una fecha de evento.
|
con la categoría «Evento».
|
||||||
</p>
|
</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
<div class="card__meta">
|
<div class="card__meta">
|
||||||
<span class="tag tag--{{ item.state }}">{{ labels[item.state] }}</span>
|
<span class="tag tag--{{ item.state }}">{{ labels[item.state] }}</span>
|
||||||
<span>{{ person(item.author, item.author_login) }}</span> · <time>{{ item.created_at }}</time>
|
<span>{{ person(item.author, item.author_login) }}</span> · <time>{{ item.created_at }}</time>
|
||||||
{% if item.event_date %} · <span>Evento el {{ item.event_date }}</span>{% endif %}
|
{% if item.categories %} · <span>{{ item.categories }}</span>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if item.description %}<p class="muted">{{ item.description }}</p>{% endif %}
|
{% if item.description %}<p class="muted">{{ item.description }}</p>{% endif %}
|
||||||
{% if item.photo_name %}
|
{% if item.photo_name %}
|
||||||
|
|||||||
@ -24,14 +24,26 @@
|
|||||||
value="{{ fields.description if fields else '' }}">
|
value="{{ fields.description if fields else '' }}">
|
||||||
<p class="muted small">Una o dos líneas: es lo que se ve en los listados.</p>
|
<p class="muted small">Una o dos líneas: es lo que se ve en los listados.</p>
|
||||||
|
|
||||||
{# An event's own date, which is not the day the post goes up. The date is
|
<fieldset class="choices">
|
||||||
also what makes this an event: there is nothing to tick first, so there is
|
<legend>Categorías</legend>
|
||||||
no way to say "this is an event" and then not say when. #}
|
{% 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. #}
|
||||||
<fieldset class="fieldset">
|
<fieldset class="fieldset">
|
||||||
<legend>Si es un evento</legend>
|
<legend>Si es un evento</legend>
|
||||||
<p class="muted small">
|
<p class="muted small">
|
||||||
Pon la fecha y será un evento: aparecerá en la agenda del sitio, con el
|
Marca <strong>Evento</strong> arriba y rellena al menos la fecha. El
|
||||||
día y el lugar destacados. Déjala vacía y es un artículo normal.
|
evento aparecerá en la agenda del sitio y se podrá añadir al
|
||||||
|
calendario del móvil.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<label for="event_date">Fecha del evento</label>
|
<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):
|
def test_the_frontmatter_marks_an_authored_source(repo, editor, post):
|
||||||
publish(post, description="Un resumen.")
|
publish(post, categories="Gastronomía", description="Un resumen.")
|
||||||
path, = repo.files
|
path, = repo.files
|
||||||
fm, body = translate.split_frontmatter(repo.files[path].decode())
|
fm, body = translate.split_frontmatter(repo.files[path].decode())
|
||||||
assert fm["lang"] == "es"
|
assert fm["lang"] == "es"
|
||||||
assert fm["manual_translation"] is False
|
assert fm["manual_translation"] is False
|
||||||
assert "categories" not in fm # the taxonomy is gone, not emptied
|
assert fm["categories"] == ["Gastronomía"]
|
||||||
assert "translated_from" not in fm # what makes it a source, not output
|
assert "translated_from" not in fm # what makes it a source, not output
|
||||||
assert not translate.is_generated(fm)
|
assert not translate.is_generated(fm)
|
||||||
assert body.strip() == "Texto del artículo."
|
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
|
import yaml
|
||||||
post("/comunidad/contenido/post/nuevo",
|
post("/comunidad/contenido/post/nuevo",
|
||||||
{"title": "Feria de otoño", "body": "Ven.", "date": "2026-10-03",
|
{"title": "Feria de otoño", "body": "Ven.", "date": "2026-10-03",
|
||||||
"event_date": "2026-10-24",
|
"categories": ["Evento", "Comunidad"], "event_date": "2026-10-24",
|
||||||
"event_time": "18:30", "event_location": "Plaza de Ottakring"})
|
"event_time": "18:30", "event_location": "Plaza de Ottakring"})
|
||||||
|
|
||||||
path, = repo.files
|
path, = repo.files
|
||||||
@ -574,23 +574,21 @@ def test_an_event_carries_its_own_date_and_an_ics(repo, editor, post):
|
|||||||
assert front["outputs"] == ["HTML", "ics"]
|
assert front["outputs"] == ["HTML", "ics"]
|
||||||
|
|
||||||
|
|
||||||
def test_a_post_with_no_event_date_is_simply_an_article(repo, editor, post):
|
def test_the_evento_category_without_a_date_is_refused(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",
|
response = post("/comunidad/contenido/post/nuevo",
|
||||||
{"title": "Algún día", "body": "Texto.", "date": "2026-10-03"})
|
{"title": "Algún día", "body": "Texto.", "date": "2026-10-03",
|
||||||
|
"categories": ["Evento"]})
|
||||||
|
|
||||||
assert response.status_code == 302
|
assert response.status_code == 400
|
||||||
path, = repo.files
|
assert "necesita fecha" in response.get_data(as_text=True)
|
||||||
front = yaml.safe_load(repo.files[path].decode().split("---")[1])
|
assert repo.files == {}
|
||||||
assert "event_date" not in front
|
|
||||||
|
|
||||||
|
|
||||||
def test_a_nonsense_hour_is_refused(repo, editor, post):
|
def test_a_nonsense_hour_is_refused(repo, editor, post):
|
||||||
response = post("/comunidad/contenido/post/nuevo",
|
response = post("/comunidad/contenido/post/nuevo",
|
||||||
{"title": "Feria", "body": "Texto.", "date": "2026-10-03",
|
{"title": "Feria", "body": "Texto.", "date": "2026-10-03",
|
||||||
"event_date": "2026-10-24", "event_time": "25:99"})
|
"categories": ["Evento"], "event_date": "2026-10-24",
|
||||||
|
"event_time": "25:99"})
|
||||||
|
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
assert repo.files == {}
|
assert repo.files == {}
|
||||||
@ -601,7 +599,7 @@ def test_an_ordinary_post_carries_no_event_lines(repo, editor, post):
|
|||||||
import yaml
|
import yaml
|
||||||
post("/comunidad/contenido/post/nuevo",
|
post("/comunidad/contenido/post/nuevo",
|
||||||
{"title": "Un artículo", "body": "Texto.", "date": "2026-10-03",
|
{"title": "Un artículo", "body": "Texto.", "date": "2026-10-03",
|
||||||
"event_date": ""})
|
"categories": ["Cultura"], "event_date": "2026-10-24"})
|
||||||
|
|
||||||
path, = repo.files
|
path, = repo.files
|
||||||
front = yaml.safe_load(repo.files[path].decode().split("---")[1])
|
front = yaml.safe_load(repo.files[path].decode().split("---")[1])
|
||||||
@ -614,7 +612,7 @@ def test_an_event_keeps_its_date_when_edited(repo, editor, post, client):
|
|||||||
repo.files["content/post/2026-10-03-feria.es.md"] = (
|
repo.files["content/post/2026-10-03-feria.es.md"] = (
|
||||||
"---\ntitle: Feria\ndate: 2026-10-03\nlang: es\nmanual_translation: false\n"
|
"---\ntitle: Feria\ndate: 2026-10-03\nlang: es\nmanual_translation: false\n"
|
||||||
"event_date: '2026-10-24'\nevent_time: '18:30'\n"
|
"event_date: '2026-10-24'\nevent_time: '18:30'\n"
|
||||||
"event_location: La plaza\n---\n\nVen.\n").encode("utf-8")
|
"event_location: La plaza\ncategories:\n- Evento\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)
|
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
|
assert 'value="2026-10-24"' in body
|
||||||
@ -622,7 +620,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",
|
post("/comunidad/contenido/post/editar/2026-10-03-feria.es.md",
|
||||||
{"title": "Feria", "body": "Ven pronto.", "date": "2026-10-03",
|
{"title": "Feria", "body": "Ven pronto.", "date": "2026-10-03",
|
||||||
"event_date": "2026-10-24",
|
"categories": ["Evento"], "event_date": "2026-10-24",
|
||||||
"event_time": "18:30", "event_location": "La plaza",
|
"event_time": "18:30", "event_location": "La plaza",
|
||||||
"sha": repo._sha(repo.files["content/post/2026-10-03-feria.es.md"])})
|
"sha": repo._sha(repo.files["content/post/2026-10-03-feria.es.md"])})
|
||||||
|
|
||||||
|
|||||||
@ -319,43 +319,3 @@ 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",
|
create_app({"SECRET_KEY": "x", "DB_PATH": path, "OWNER_LOGIN": "salvador",
|
||||||
"UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True})
|
"UPLOAD_DIR": str(tmp_path / "uploads"), "TESTING": True})
|
||||||
db.close()
|
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,10 +73,11 @@ 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
|
"""The whole point of the table. If this ever commits, the post is on
|
||||||
vienalatina.com before anybody has read it."""
|
vienalatina.com before anybody has read it."""
|
||||||
sign_in(maria)
|
sign_in(maria)
|
||||||
propose(post, description="Una feria")
|
propose(post, description="Una feria", categories=["Comunidad"])
|
||||||
|
|
||||||
row = only_submission(db)
|
row = only_submission(db)
|
||||||
assert (row["state"], row["title"]) == ("pending", "Feria en Ottakring")
|
assert (row["state"], row["title"], row["categories"]) == (
|
||||||
|
"pending", "Feria en Ottakring", "Comunidad")
|
||||||
assert repo.files == {}
|
assert repo.files == {}
|
||||||
assert repo.commits == []
|
assert repo.commits == []
|
||||||
|
|
||||||
@ -188,7 +189,7 @@ def test_approving_commits_once_under_the_author_is_name(
|
|||||||
"""Attribution is the reason `write_file` takes an author at all. A post
|
"""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."""
|
approved by Luisa but written by María has to say María in git."""
|
||||||
sign_in(maria)
|
sign_in(maria)
|
||||||
propose(post)
|
propose(post, categories=["Comunidad"])
|
||||||
submission_id = only_submission(db)["id"]
|
submission_id = only_submission(db)["id"]
|
||||||
|
|
||||||
sign_in(luisa)
|
sign_in(luisa)
|
||||||
@ -204,11 +205,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,
|
def test_the_approved_file_is_what_the_pipeline_expects(repo, db, post, maria,
|
||||||
luisa, sign_in):
|
luisa, sign_in):
|
||||||
"""The same contract the editor's own tests hold it to: a Spanish source
|
"""The same contract the editor's own tests hold it to: Spanish source, no
|
||||||
with no `translated_from`."""
|
`translated_from`, categories as a list."""
|
||||||
import yaml
|
import yaml
|
||||||
sign_in(maria)
|
sign_in(maria)
|
||||||
propose(post, description="Una feria")
|
propose(post, categories=["Comunidad", "Cultura"], description="Una feria")
|
||||||
submission_id = only_submission(db)["id"]
|
submission_id = only_submission(db)["id"]
|
||||||
|
|
||||||
sign_in(luisa)
|
sign_in(luisa)
|
||||||
@ -219,7 +220,7 @@ def test_the_approved_file_is_what_the_pipeline_expects(repo, db, post, maria,
|
|||||||
front = yaml.safe_load(text.split("---")[1])
|
front = yaml.safe_load(text.split("---")[1])
|
||||||
assert front["lang"] == "es"
|
assert front["lang"] == "es"
|
||||||
assert front["manual_translation"] is False
|
assert front["manual_translation"] is False
|
||||||
assert "categories" not in front
|
assert front["categories"] == ["Comunidad", "Cultura"]
|
||||||
assert front["description"] == "Una feria"
|
assert front["description"] == "Una feria"
|
||||||
assert "translated_from" not in front
|
assert "translated_from" not in front
|
||||||
assert "empanadas" in text
|
assert "empanadas" in text
|
||||||
@ -476,7 +477,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."""
|
site is the one the member described, dated when it happens."""
|
||||||
import yaml
|
import yaml
|
||||||
sign_in(maria)
|
sign_in(maria)
|
||||||
propose(post, event_date="2026-11-07",
|
propose(post, categories=["Evento"], event_date="2026-11-07",
|
||||||
event_time="20:00", event_location="Sala Ottakring")
|
event_time="20:00", event_location="Sala Ottakring")
|
||||||
submission_id = only_submission(db)["id"]
|
submission_id = only_submission(db)["id"]
|
||||||
|
|
||||||
@ -491,13 +492,10 @@ def test_a_member_can_propose_an_event_and_it_keeps_its_date(
|
|||||||
assert front["author"] == "Maria"
|
assert front["author"] == "Maria"
|
||||||
|
|
||||||
|
|
||||||
def test_a_proposal_with_a_nonsense_event_date_is_refused(db, post, maria, sign_in):
|
def test_an_event_proposal_without_a_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)
|
sign_in(maria)
|
||||||
|
|
||||||
response = propose(post, event_date="el martes")
|
response = propose(post, categories=["Evento"])
|
||||||
|
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
assert db.execute("SELECT COUNT(*) AS n FROM submissions").fetchone()["n"] == 0
|
assert db.execute("SELECT COUNT(*) AS n FROM submissions").fetchone()["n"] == 0
|
||||||
|
|||||||
@ -207,48 +207,3 @@ 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"):
|
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"
|
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,11 +21,9 @@ defaultContentLanguageInSubdir: false
|
|||||||
permalinks:
|
permalinks:
|
||||||
post: "/:year/:month/:day/:slug/"
|
post: "/:year/:month/:day/:slug/"
|
||||||
|
|
||||||
# No taxonomies. An empty map rather than no `taxonomies` key at all: leaving
|
taxonomies:
|
||||||
# the key out restores Hugo's own defaults, which are `tags` and `categories` —
|
category: "categories"
|
||||||
# so deleting the block built the very pages it was meant to remove. This turns
|
tag: "tags"
|
||||||
# them off, and /categories/… and /tags/ fall through to the site's 404.
|
|
||||||
taxonomies: {}
|
|
||||||
|
|
||||||
languages:
|
languages:
|
||||||
es:
|
es:
|
||||||
@ -34,21 +32,22 @@ languages:
|
|||||||
weight: 1
|
weight: 1
|
||||||
params:
|
params:
|
||||||
description: "Comunidad latinoamericana en Viena — turismo, cultura, gastronomía, comunidad y comercio."
|
description: "Comunidad latinoamericana en Viena — turismo, cultura, gastronomía, comunidad y comercio."
|
||||||
# Only Inicio lives here. Everything after it is built from the pages
|
# Only the two ends of the menu live here. Everything between them is built
|
||||||
# themselves by partials/header.html — so a page published from the members
|
# from the pages themselves by partials/header.html — so a page published
|
||||||
# area appears on the site, with its own translated title, instead of
|
# from the members area appears on the site, with its own translated title,
|
||||||
# needing three edits in this file. Weight decides the side: under 5 goes
|
# instead of needing three edits in this file. Weight decides the side:
|
||||||
# before the pages, 5 or more after them.
|
# 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:
|
menus:
|
||||||
main:
|
main:
|
||||||
- name: "Inicio"
|
- name: "Inicio"
|
||||||
url: "/"
|
url: "/"
|
||||||
weight: 1
|
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:
|
de:
|
||||||
languageCode: "de"
|
languageCode: "de"
|
||||||
languageName: "Deutsch"
|
languageName: "Deutsch"
|
||||||
@ -60,6 +59,9 @@ languages:
|
|||||||
- name: "Start"
|
- name: "Start"
|
||||||
url: "/de/"
|
url: "/de/"
|
||||||
weight: 1
|
weight: 1
|
||||||
|
- name: "Community"
|
||||||
|
url: "/comunidad/"
|
||||||
|
weight: 9
|
||||||
pt-br:
|
pt-br:
|
||||||
languageCode: "pt-BR"
|
languageCode: "pt-BR"
|
||||||
languageName: "Português (Brasil)"
|
languageName: "Português (Brasil)"
|
||||||
@ -71,6 +73,9 @@ languages:
|
|||||||
- name: "Início"
|
- name: "Início"
|
||||||
url: "/pt-br/"
|
url: "/pt-br/"
|
||||||
weight: 1
|
weight: 1
|
||||||
|
- name: "Comunidade"
|
||||||
|
url: "/comunidad/"
|
||||||
|
weight: 9
|
||||||
|
|
||||||
params:
|
params:
|
||||||
# The picture a share card falls back on when a post or page has none, and the
|
# The picture a share card falls back on when a post or page has none, and the
|
||||||
|
|||||||
@ -264,6 +264,7 @@ title: "Artículo de prueba"
|
|||||||
date: 2026-08-01
|
date: 2026-08-01
|
||||||
lang: es
|
lang: es
|
||||||
manual_translation: false
|
manual_translation: false
|
||||||
|
categories: [Comunidad]
|
||||||
---
|
---
|
||||||
|
|
||||||
Esto es una prueba del flujo de traducción automática en el Grätzl.
|
Esto es una prueba del flujo de traducción automática en el Grätzl.
|
||||||
@ -806,7 +807,7 @@ profile:
|
|||||||
```sh
|
```sh
|
||||||
sudo caddy validate --config /etc/caddy/Caddyfile
|
sudo caddy validate --config /etc/caddy/Caddyfile
|
||||||
sudo systemctl reload caddy
|
sudo systemctl reload caddy
|
||||||
for path in / /de/ /pt-br/ /page/acerca/ /page/agenda/ /robots.txt /comunidad/ /noexiste; do
|
for path in / /de/ /pt-br/ /page/acerca/ /categories/ /robots.txt /comunidad/ /noexiste; do
|
||||||
printf '%-20s %s\n' "$path" "$(curl -s -o /dev/null -w '%{http_code}' https://vienalatina.com$path)"
|
printf '%-20s %s\n' "$path" "$(curl -s -o /dev/null -w '%{http_code}' https://vienalatina.com$path)"
|
||||||
done
|
done
|
||||||
```
|
```
|
||||||
@ -931,22 +932,16 @@ 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
|
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.
|
WordPress: hover and `:focus-within`, inline on a phone, no script.
|
||||||
|
|
||||||
Only *Inicio* remains in `config.yaml`. Weight under 5 puts a menu entry before
|
Only *Inicio* and *Comunidad* remain in `config.yaml`. Weight under 5 puts a menu
|
||||||
the pages, 5 or more after them. *Comunidad* used to be the entry at weight 9 and
|
entry before the pages, 5 or more after them.
|
||||||
is a button in the bar now — see §11.19.
|
|
||||||
|
|
||||||
### 11.15b Two calendars
|
### 11.15b Two calendars
|
||||||
|
|
||||||
**Public events are posts carrying an `event_date`**, with two more fields of
|
**Public events are posts** in the **Evento** category, with three fields of
|
||||||
their own: `event_time` and `event_location`. The post's own `date` is when it
|
their own: `event_date`, `event_time` and `event_location`. The post's own `date`
|
||||||
was announced — usually weeks earlier, and what Hugo sorts the blog by — so the
|
is when it was announced — usually weeks earlier, and what Hugo sorts the blog by
|
||||||
event's date cannot be the same field.
|
— 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
|
||||||
**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.
|
moderator approves them.
|
||||||
|
|
||||||
An event's page leads with the day, the time and the place, shows its picture
|
An event's page leads with the day, the time and the place, shows its picture
|
||||||
@ -1079,42 +1074,6 @@ 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
|
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.
|
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
|
## 12. Make Gitea look like the site
|
||||||
|
|
||||||
Members sign in to `/comunidad/` through Gitea, so Gitea's sign-in form and its
|
Members sign in to `/comunidad/` through Gitea, so Gitea's sign-in form and its
|
||||||
|
|||||||
@ -57,7 +57,9 @@ def build_provider():
|
|||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
CONTENT_DIR = REPO_ROOT / "content"
|
CONTENT_DIR = REPO_ROOT / "content"
|
||||||
|
|
||||||
# Frontmatter strings translated alongside the body.
|
# 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.
|
||||||
# `event_location` is deliberately absent: an address is how somebody finds the
|
# `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.
|
# place, and a translated street or venue name is worse than an untranslated one.
|
||||||
# `event_date` and `event_time` are data, not prose.
|
# `event_date` and `event_time` are data, not prose.
|
||||||
|
|||||||
@ -168,13 +168,6 @@ img { max-width: 100%; height: auto; }
|
|||||||
|
|
||||||
.lang-btn:hover { color: var(--text, #1a0d09); }
|
.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"] {
|
.lang-btn[aria-pressed="true"] {
|
||||||
color: var(--brand, #c0391c);
|
color: var(--brand, #c0391c);
|
||||||
background: var(--brand-softer, #fdf1ed);
|
background: var(--brand-softer, #fdf1ed);
|
||||||
@ -294,52 +287,6 @@ img { max-width: 100%; height: auto; }
|
|||||||
color: var(--muted, #5c3d37);
|
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 */
|
/* Hamburger — hidden on desktop, visible on mobile */
|
||||||
.site-bar__hamburger {
|
.site-bar__hamburger {
|
||||||
display: none;
|
display: none;
|
||||||
@ -372,19 +319,14 @@ img { max-width: 100%; height: auto; }
|
|||||||
transition: transform 200ms ease, opacity 200ms ease;
|
transition: transform 200ms ease, opacity 200ms ease;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Animated X when open.
|
/* Animated X when open */
|
||||||
Through :has(), because the ☰ sits in the bar and the checkbox that holds the
|
.site-bar__hamburger[aria-expanded="true"] .hamburger-line:nth-child(1) {
|
||||||
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);
|
transform: translateY(7.5px) rotate(45deg);
|
||||||
}
|
}
|
||||||
.site-bar:has(.site-menu__state:checked) .hamburger-line:nth-child(2) {
|
.site-bar__hamburger[aria-expanded="true"] .hamburger-line:nth-child(2) {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
}
|
}
|
||||||
.site-bar:has(.site-menu__state:checked) .hamburger-line:nth-child(3) {
|
.site-bar__hamburger[aria-expanded="true"] .hamburger-line:nth-child(3) {
|
||||||
transform: translateY(-7.5px) rotate(-45deg);
|
transform: translateY(-7.5px) rotate(-45deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -438,18 +380,7 @@ img { max-width: 100%; height: auto; }
|
|||||||
background: var(--surface, #fff);
|
background: var(--surface, #fff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The switcher at the foot of the mobile panel — the second copy. Hidden on
|
/* On mobile/tablet the nav is collapsed and toggled by the hamburger */
|
||||||
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) {
|
@media (max-width: 768px) {
|
||||||
.site-bar__pages {
|
.site-bar__pages {
|
||||||
display: none;
|
display: none;
|
||||||
@ -459,40 +390,14 @@ img { max-width: 100%; height: auto; }
|
|||||||
box-shadow: 0 4px 16px rgba(60, 20, 10, 0.08);
|
box-shadow: 0 4px 16px rgba(60, 20, 10, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
.site-menu__state:checked ~ .site-bar__pages {
|
.site-bar__pages.is-open {
|
||||||
display: flex;
|
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 {
|
.page-nav {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
overflow: visible;
|
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 {
|
.page-nav li a {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
{{/* Section and term listings — article-card markup from the WP theme feed. */}}
|
{{/* Category / archive listing — article-card markup from the WP theme feed. */}}
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<main class="feed">
|
<main class="feed">
|
||||||
<h1 class="feed__title">{{ .Title }}</h1>
|
<h1 class="feed__title">{{ .Title }}</h1>
|
||||||
@ -6,6 +6,9 @@
|
|||||||
{{ range .Pages }}
|
{{ range .Pages }}
|
||||||
<article class="article-card">
|
<article class="article-card">
|
||||||
<div class="article-card__meta">
|
<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>
|
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 Jan 2006" }}</time>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||||
|
|||||||
@ -7,6 +7,9 @@
|
|||||||
<header class="article-single__head">
|
<header class="article-single__head">
|
||||||
<div>
|
<div>
|
||||||
<div class="article-card__meta">
|
<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" }}">
|
<time datetime="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}">
|
||||||
{{ .Date.Format "2 Jan 2006" }}
|
{{ .Date.Format "2 Jan 2006" }}
|
||||||
</time>
|
</time>
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
{{ range first 20 (where .Site.RegularPages "Section" "post") }}
|
{{ range first 20 (where .Site.RegularPages "Section" "post") }}
|
||||||
<article class="article-card">
|
<article class="article-card">
|
||||||
<div class="article-card__meta">
|
<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>
|
<time datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "2 Jan 2006" }}</time>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||||
|
|||||||
@ -1,26 +1,27 @@
|
|||||||
{{/* BreadcrumbList — where this page sits, for a search result and for an answer
|
{{/* BreadcrumbList — where this page sits, for a search result and for an answer
|
||||||
engine deciding what a page is about.
|
engine deciding what a page is about.
|
||||||
|
|
||||||
Two levels: Inicio → this. An article used to carry its category in the
|
Two levels for a page (Inicio → this), three for an article (Inicio → its
|
||||||
middle; there are no categories any more, and a post is a child of the home
|
category → this). Nothing is rendered visibly: the site is shallow enough
|
||||||
page. Nothing is rendered visibly: the site is shallow enough that a visible
|
that a visible trail would be clutter, while the machine-readable one still
|
||||||
trail would be clutter, while the machine-readable one still answers "what
|
answers "what is this page part of".
|
||||||
is this page part of".
|
|
||||||
|
|
||||||
A subpage says Inicio → its parent → itself, read from the same `parent`
|
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. */}}
|
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) }}
|
{{ $items := slice (dict "@type" "ListItem" "position" 1 "name" "Inicio" "item" .Site.Home.Permalink) }}
|
||||||
{{ $position := 2 }}
|
{{ $position := 2 }}
|
||||||
|
|
||||||
{{ if ne .Section "post" }}
|
{{ 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 }}
|
||||||
{{ with .Params.parent }}
|
{{ with .Params.parent }}
|
||||||
{{ $base := . }}
|
{{ $base := . }}
|
||||||
{{ range where $.Site.RegularPages "Section" "page" }}
|
{{ range where $.Site.RegularPages "Section" "page" }}
|
||||||
{{ with .File }}{{ if eq .ContentBaseName $base }}
|
{{ with .File }}{{ if eq .ContentBaseName $base }}
|
||||||
{{ $items = $items | append (dict "@type" "ListItem" "position" $position "name" $.Page.Title "item" $.Permalink) }}
|
{{ $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 }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|||||||
@ -22,48 +22,10 @@
|
|||||||
</a>
|
</a>
|
||||||
|
|
||||||
<nav class="site-bar__nav" aria-label="Idioma">
|
<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" . }}
|
{{ partial "lang-switcher.html" . }}
|
||||||
</nav>
|
</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>
|
</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
|
{{/* 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
|
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
|
published from the members area never appeared on the site at all — and
|
||||||
@ -135,12 +97,5 @@
|
|||||||
</li>
|
</li>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</ul>
|
</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>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
|
|||||||
@ -57,6 +57,7 @@
|
|||||||
<meta property="article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05-07:00" }}">
|
<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" }}">
|
<meta property="article:modified_time" content="{{ .Lastmod.Format "2006-01-02T15:04:05-07:00" }}">
|
||||||
{{ with .Params.author }}<meta property="article:author" content="{{ . }}">{{ end }}
|
{{ 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:card" content="{{ if $image }}summary_large_image{{ else }}summary{{ end }}">
|
||||||
<meta name="twitter:title" content="{{ .Title }}">
|
<meta name="twitter:title" content="{{ .Title }}">
|
||||||
|
|||||||
@ -18,8 +18,6 @@
|
|||||||
"next" (dict "es" "Mes siguiente" "de" "Nächster Monat" "pt-br" "Próximo mês")
|
"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.")
|
"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")
|
"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 -}}
|
{{- $entry := index $words .key -}}
|
||||||
{{- if $entry -}}
|
{{- if $entry -}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user