Merge branch 'claude/relaxed-faraday-h4zd09' of https://github.com/pablovolenski/vienalatina
This commit is contained in:
commit
5c27494059
@ -58,6 +58,30 @@ def test_every_key_in_the_catalogue_is_used():
|
|||||||
assert not orphans, f"defined but never shown: {orphans}"
|
assert not orphans, f"defined but never shown: {orphans}"
|
||||||
|
|
||||||
|
|
||||||
|
def test_every_theme_call_site_passes_the_page_explicitly():
|
||||||
|
"""`$.Site.Language.Lang`, never `.Site.Language.Lang`.
|
||||||
|
|
||||||
|
Inside a `{{ with }}` the dot is whatever that block holds — `.Params.author`
|
||||||
|
is a string, `.Params.faq` is a slice — and `.Site` on a string is an
|
||||||
|
execution error, not a wrong word. Two call sites shipped exactly that way,
|
||||||
|
and the build only went red on a post that happened to carry an `author`:
|
||||||
|
every post in the test fixture had neither, so a clean build proved nothing.
|
||||||
|
|
||||||
|
`$` is the page in every context, so the rule is "always `$.`" rather than
|
||||||
|
"think about where you are", and this is what holds it.
|
||||||
|
"""
|
||||||
|
offenders = []
|
||||||
|
for path in THEME.rglob("*"):
|
||||||
|
if not path.is_file() or path.suffix in (".css", ".js", ".toml"):
|
||||||
|
continue
|
||||||
|
for line_no, line in enumerate(path.read_text(encoding="utf-8").splitlines(), 1):
|
||||||
|
if 't.html"' in line and re.search(r'"lang"\s+\.', line):
|
||||||
|
offenders.append(f"{path.relative_to(THEME)}:{line_no}")
|
||||||
|
assert not offenders, (
|
||||||
|
"these pass `.Site…` to t.html instead of `$.Site…`, which fails the "
|
||||||
|
f"build inside a `with`: {offenders}")
|
||||||
|
|
||||||
|
|
||||||
def test_the_theme_and_the_catalogue_agree_on_the_public_defaults():
|
def test_the_theme_and_the_catalogue_agree_on_the_public_defaults():
|
||||||
"""Two copies, deliberately — Hugo reads the repository and the members area
|
"""Two copies, deliberately — Hugo reads the repository and the members area
|
||||||
reads its own image, and neither can read the other's file. The same trade
|
reads its own image, and neither can read the other's file. The same trade
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
<article class="article-card">
|
<article class="article-card">
|
||||||
<div class="article-card__meta">
|
<div class="article-card__meta">
|
||||||
<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>
|
||||||
{{ if .Params.ai_generated }}<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" .Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
{{ if .Params.ai_generated }}<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" $.Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }}</span>{{ end }}
|
||||||
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}</span>{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||||
<p class="article-card__excerpt">{{ .Description | default (.Summary | plainify | truncate 200) }}</p>
|
<p class="article-card__excerpt">{{ .Description | default (.Summary | plainify | truncate 200) }}</p>
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
nothing. */}}
|
nothing. */}}
|
||||||
{{ with .Params.author }}
|
{{ with .Params.author }}
|
||||||
<span class="article-card__by">
|
<span class="article-card__by">
|
||||||
{{ partial "t.html" (dict "key" "by" "lang" .Site.Language.Lang) }}
|
{{ partial "t.html" (dict "key" "by" "lang" $.Site.Language.Lang) }}
|
||||||
{{ with $.Params.author_url }}
|
{{ with $.Params.author_url }}
|
||||||
<a href="{{ . | relURL }}">{{ $.Params.author }}</a>
|
<a href="{{ . | relURL }}">{{ $.Params.author }}</a>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
@ -33,11 +33,11 @@
|
|||||||
into the German and Portuguese siblings by itself, which is right:
|
into the German and Portuguese siblings by itself, which is right:
|
||||||
a translated post was still machine-written. */}}
|
a translated post was still machine-written. */}}
|
||||||
{{ if .Params.ai_generated }}
|
{{ if .Params.ai_generated }}
|
||||||
<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" .Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}</span>
|
<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" $.Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }}</span>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{/* And whether somebody put it at the top on purpose, so a reader
|
{{/* And whether somebody put it at the top on purpose, so a reader
|
||||||
arriving from the home page knows why it was first. */}}
|
arriving from the home page knows why it was first. */}}
|
||||||
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}</span>{{ end }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
@ -96,7 +96,7 @@
|
|||||||
cannot see is exactly what search engines penalise. */}}
|
cannot see is exactly what search engines penalise. */}}
|
||||||
{{ with .Params.faq }}
|
{{ with .Params.faq }}
|
||||||
<section class="faq">
|
<section class="faq">
|
||||||
<h2>{{ partial "t.html" (dict "key" "faq" "lang" .Site.Language.Lang) }}</h2>
|
<h2>{{ partial "t.html" (dict "key" "faq" "lang" $.Site.Language.Lang) }}</h2>
|
||||||
<dl>
|
<dl>
|
||||||
{{ range . }}
|
{{ range . }}
|
||||||
{{ $parts := split . "|" }}
|
{{ $parts := split . "|" }}
|
||||||
@ -112,7 +112,7 @@
|
|||||||
{{ partial "share.html" . }}
|
{{ partial "share.html" . }}
|
||||||
|
|
||||||
<a class="back-link" href="{{ .Site.Home.Permalink }}">
|
<a class="back-link" href="{{ .Site.Home.Permalink }}">
|
||||||
{{ partial "t.html" (dict "key" "back" "lang" .Site.Language.Lang) }}
|
{{ partial "t.html" (dict "key" "back" "lang" $.Site.Language.Lang) }}
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
{{/* Only on this template: the home page and the lists carry no share
|
{{/* Only on this template: the home page and the lists carry no share
|
||||||
|
|||||||
@ -5,8 +5,8 @@
|
|||||||
<article class="article-card">
|
<article class="article-card">
|
||||||
<div class="article-card__meta">
|
<div class="article-card__meta">
|
||||||
<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>
|
||||||
{{ if .Params.ai_generated }}<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" .Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
{{ if .Params.ai_generated }}<span class="tag-ai" title="{{ partial "t.html" (dict "key" "aifull" "lang" $.Site.Language.Lang) }}">{{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }}</span>{{ end }}
|
||||||
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}</span>{{ end }}
|
{{ if .Params.pinned }}<span class="tag-pin">{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}</span>{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
<h2 class="article-card__title"><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
|
||||||
<p class="article-card__excerpt">{{ .Description | default (.Summary | plainify | truncate 200) }}</p>
|
<p class="article-card__excerpt">{{ .Description | default (.Summary | plainify | truncate 200) }}</p>
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
sans-serif, keeping the site free of third-party requests (GDPR). */}}
|
sans-serif, keeping the site free of third-party requests (GDPR). */}}
|
||||||
<header class="site-bar">
|
<header class="site-bar">
|
||||||
<div class="site-bar__inner">
|
<div class="site-bar__inner">
|
||||||
<a class="site-bar__brand" href="{{ .Site.Home.Permalink }}" aria-label="{{ partial "t.html" (dict "key" "home" "lang" .Site.Language.Lang) }}">
|
<a class="site-bar__brand" href="{{ .Site.Home.Permalink }}" aria-label="{{ partial "t.html" (dict "key" "home" "lang" $.Site.Language.Lang) }}">
|
||||||
{{/* The logo uploaded in Gestión → Marca, and the site's name in
|
{{/* The logo uploaded in Gestión → Marca, and the site's name in
|
||||||
letters when there is none. The alt text is the name either way,
|
letters when there is none. The alt text is the name either way,
|
||||||
so a reader who does not see the picture reads the same thing.
|
so a reader who does not see the picture reads the same thing.
|
||||||
@ -36,7 +36,7 @@
|
|||||||
who has an account needs to find the door at a glance, and 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,
|
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. */}}
|
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>
|
<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
|
{{/* 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 —
|
checkbox it drives lives below, as a sibling of the menu it opens —
|
||||||
@ -63,7 +63,7 @@
|
|||||||
so the menu opens from a keyboard. The ☰ above is aria-hidden because it
|
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. */}}
|
would otherwise be read a second time as the same control. */}}
|
||||||
<input id="site-menu" class="site-menu__state" type="checkbox"
|
<input id="site-menu" class="site-menu__state" type="checkbox"
|
||||||
aria-label="{{ partial "t.html" (dict "key" "menu" "lang" .Site.Language.Lang) }}">
|
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
|
||||||
|
|||||||
@ -1,11 +1,26 @@
|
|||||||
{{- /* The handful of words the templates themselves say.
|
{{- /* The handful of words the templates themselves say.
|
||||||
|
|
||||||
Everything else on this site is content and arrives already translated by
|
Everything else on this site is content and arrives already translated by
|
||||||
the pipeline. These are the labels around it — "Lugar", "Hoy" — and there
|
the pipeline. These are the labels around it — "Lugar", "Compartir" — and
|
||||||
are eleven of them, which is a table rather than a reason to install i18n
|
they are a table rather than a reason to install i18n files and a
|
||||||
files and a translation workflow for the theme.
|
translation workflow for the theme.
|
||||||
|
|
||||||
|
What is below is the *default*. Gestión → Textos can say something else,
|
||||||
|
and that is read first, out of data/ui.yaml. The same defaults also live
|
||||||
|
in apps/board/strings/sitio.yaml so the screen can show them as
|
||||||
|
placeholders — two copies, unavoidably, because Hugo reads the repository
|
||||||
|
and the members area reads its own image and neither can read the other's
|
||||||
|
file. test_strings.py fails if they drift, the way brand.FACTORY is held
|
||||||
|
to the two `:root` blocks.
|
||||||
|
|
||||||
|
Usage: {{ partial "t.html" (dict "key" "place" "lang" $.Site.Language.Lang) }}
|
||||||
|
|
||||||
|
**`$.` and never a bare `.`** Inside a `{{ with }}` the dot is whatever
|
||||||
|
that block holds — a string, a slice — and `.Site` on a string fails the
|
||||||
|
build rather than producing a wrong word. Two call sites shipped that way
|
||||||
|
and the build only broke on a post that happened to carry an `author`.
|
||||||
|
`$` is the page everywhere, and a test holds every call site to it.
|
||||||
|
|
||||||
Usage: {{ partial "t.html" (dict "key" "place" "lang" .Site.Language.Lang) }}
|
|
||||||
An unknown key returns itself, so a typo is visible on the page instead of
|
An unknown key returns itself, so a typo is visible on the page instead of
|
||||||
rendering as nothing. */ -}}
|
rendering as nothing. */ -}}
|
||||||
{{- $words := dict
|
{{- $words := dict
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user