use variables instead of scratches which became possible by Hugo 0.49

lektura
max.mehl 2018-11-06 11:16:13 +01:00
parent f5f055d1cf
commit 720e3cb99e
No known key found for this signature in database
GPG Key ID: 2704E4AB371E2E92
2 changed files with 12 additions and 12 deletions

View File

@ -1,13 +1,13 @@
{{ $.Scratch.Set "langext" "" }}
{{ $langext := "" }}
{{ if or (eq .Lang "de") (eq .Lang "fr") (eq .Lang "it") (eq .Lang "pt") (eq .Lang "ru") }}
{{ $.Scratch.Add "langext" (printf "_%s" .Lang) }}
{{ $langext = (printf "_%s" .Lang) }}
{{ end }}
<center>
<video controls="controls" poster="/img/poster.jpg" crossorigin="crossorigin" width="100%">
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$.Scratch.Get "langext"}}_desktop.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' media="screen and (min-device-width:1000px)" />
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$.Scratch.Get "langext"}}_desktop.webm" type='video/webm; codecs="vp9, opus"' media="screen and (min-device-width:1000px)" />
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$.Scratch.Get "langext"}}_mobile.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' media="screen and (max-device-width:999px)" />
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$.Scratch.Get "langext"}}_mobile.webm" type='video/webm; codecs="vp9, opus"' media="screen and (max-device-width:999px)" />
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$langext}}_desktop.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' media="screen and (min-device-width:1000px)" />
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$langext}}_desktop.webm" type='video/webm; codecs="vp9, opus"' media="screen and (min-device-width:1000px)" />
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$langext}}_mobile.mp4" type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"' media="screen and (max-device-width:999px)" />
<source src="https://download.fsfe.org/videos/pmpc/pmpc{{$langext}}_mobile.webm" type='video/webm; codecs="vp9, opus"' media="screen and (max-device-width:999px)" />
<track src="https://publiccode.eu/video-subs/webvtt/pmpc_en.vtt" kind="subtitles" srclang="en" label="English">
<track src="https://publiccode.eu/video-subs/webvtt/pmpc_de.vtt" kind="subtitles" srclang="de" label="Deutsch">

View File

@ -1,17 +1,17 @@
{{- $.Scratch.Set "allgood" true -}} <!-- "allgood" will say whether all translations are fine -->
{{- $allgood := true -}} <!-- "allgood" will say whether all translations are fine -->
{{- range .Site.Pages -}} <!-- range through all pages -->
{{- $.Scratch.Set "uptodate" true -}} <!-- reset uptodate var -->
{{- $uptodate := true -}} <!-- reset uptodate var -->
{{- $main_date := .Lastmod -}} <!-- last modification date of EN file -->
{{- range .Translations -}} <!-- range through all translations of .Page -->
{{- if and (.IsTranslated) (.IsPage) -}}
{{- $i18n_date := .Lastmod -}}
{{- if ($main_date.After $i18n_date) -}} <!-- EN .Lastmod is newer than .Lastmod of translation -->
{{- $.Scratch.Set "uptodate" false -}} <!-- at least one translation failed -->
{{- $.Scratch.Set "allgood" false -}} <!-- at least one translation failed -->
{{- $uptodate = false -}} <!-- at least one translation failed -->
{{- $allgood = false -}} <!-- at least one translation failed -->
{{- end -}}
{{- end -}}
{{- end -}}
{{- if eq ($.Scratch.Get "uptodate") false }} <!-- if at least one translation failed -->
{{- if eq $uptodate false }} <!-- if at least one translation failed -->
<h3><a href="{{ .Permalink }}">{{ .File.Path }}</a></h3>
<table class="transstatus">
<thead><tr>
@ -42,6 +42,6 @@
{{- end -}}
{{- end -}}
{{- if eq ($.Scratch.Get "allgood") true -}}
{{- if eq $allgood true -}}
<p style="text-align:center;">Everything is up to date! &#128077;</p>
{{- end -}}