diff --git a/apps/board/tests/test_strings.py b/apps/board/tests/test_strings.py index 9bfb6c9..038d597 100644 --- a/apps/board/tests/test_strings.py +++ b/apps/board/tests/test_strings.py @@ -58,6 +58,30 @@ def test_every_key_in_the_catalogue_is_used(): 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(): """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 diff --git a/themes/vienalatina/layouts/_default/list.html b/themes/vienalatina/layouts/_default/list.html index d68ff95..6724b06 100644 --- a/themes/vienalatina/layouts/_default/list.html +++ b/themes/vienalatina/layouts/_default/list.html @@ -7,8 +7,8 @@
- {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}{{ end }} - {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}{{ end }} + {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }}{{ end }} + {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}{{ end }}

{{ .Title }}

{{ .Description | default (.Summary | plainify | truncate 200) }}

diff --git a/themes/vienalatina/layouts/_default/single.html b/themes/vienalatina/layouts/_default/single.html index 551b0f3..673b809 100644 --- a/themes/vienalatina/layouts/_default/single.html +++ b/themes/vienalatina/layouts/_default/single.html @@ -19,7 +19,7 @@ nothing. */}} {{ with .Params.author }} - {{ partial "t.html" (dict "key" "by" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "by" "lang" $.Site.Language.Lang) }} {{ with $.Params.author_url }} {{ $.Params.author }} {{ else }} @@ -33,11 +33,11 @@ into the German and Portuguese siblings by itself, which is right: a translated post was still machine-written. */}} {{ if .Params.ai_generated }} - {{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }} {{ end }} {{/* And whether somebody put it at the top on purpose, so a reader arriving from the home page knows why it was first. */}} - {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}{{ end }} + {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}{{ end }} @@ -96,7 +96,7 @@ cannot see is exactly what search engines penalise. */}} {{ with .Params.faq }}
-

{{ partial "t.html" (dict "key" "faq" "lang" .Site.Language.Lang) }}

+

{{ partial "t.html" (dict "key" "faq" "lang" $.Site.Language.Lang) }}

{{ range . }} {{ $parts := split . "|" }} @@ -112,7 +112,7 @@ {{ partial "share.html" . }} - {{ partial "t.html" (dict "key" "back" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "back" "lang" $.Site.Language.Lang) }} {{/* Only on this template: the home page and the lists carry no share diff --git a/themes/vienalatina/layouts/index.html b/themes/vienalatina/layouts/index.html index 2476fd5..817f334 100644 --- a/themes/vienalatina/layouts/index.html +++ b/themes/vienalatina/layouts/index.html @@ -5,8 +5,8 @@
- {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" .Site.Language.Lang) }}{{ end }} - {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" .Site.Language.Lang) }}{{ end }} + {{ if .Params.ai_generated }}{{ partial "t.html" (dict "key" "ai" "lang" $.Site.Language.Lang) }}{{ end }} + {{ if .Params.pinned }}{{ partial "t.html" (dict "key" "pinned" "lang" $.Site.Language.Lang) }}{{ end }}

{{ .Title }}

{{ .Description | default (.Summary | plainify | truncate 200) }}

diff --git a/themes/vienalatina/layouts/partials/header.html b/themes/vienalatina/layouts/partials/header.html index 3dfb0d7..3d74d0f 100644 --- a/themes/vienalatina/layouts/partials/header.html +++ b/themes/vienalatina/layouts/partials/header.html @@ -3,7 +3,7 @@ sans-serif, keeping the site free of third-party requests (GDPR). */}}
- + {{/* 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, 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 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. */}} - {{ partial "t.html" (dict "key" "community" "lang" .Site.Language.Lang) }} + {{ partial "t.html" (dict "key" "community" "lang" $.Site.Language.Lang) }} {{/* The ☰ itself. A