1

Nouveau thème pour 2026

This commit is contained in:
2026-02-21 01:50:39 +01:00
parent 27dd5f86e6
commit a7f539ceb4
67 changed files with 6137 additions and 21 deletions

View File

@@ -0,0 +1,115 @@
{{- $isExternal := strings.HasPrefix .Destination "http" -}}
{{- $parsed := urls.Parse .Destination -}}
{{- $host := $parsed.Host -}}
{{- $path := $parsed.Path -}}
{{- $query := $parsed.RawQuery -}}
{{- $page := .Page -}}
{{- $site := $page.Site -}}
{{- $aff := index $site.Data.affiliates.sites $host -}}
{{- $isAffiliated := false -}}
{{- $newURL := .Destination -}}
{{- $customClass := "" -}}
{{- if reflect.IsMap . -}}
{{- if isset . "Class" -}}
{{- with (index . "Class") -}}
{{- $customClass = . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if and $isExternal $aff -}}
{{- $isAffiliated = true -}}
{{- if $query -}}
{{- $newURL = printf "%s://%s%s?%s&%s=%s" $parsed.Scheme $host $path $query $aff.param $aff.value -}}
{{- else -}}
{{- $newURL = printf "%s://%s%s?%s=%s" $parsed.Scheme $host $path $aff.param $aff.value -}}
{{- end -}}
{{- end -}}
{{- $internalPage := "" -}}
{{- $internalPageFound := false -}}
{{- if not $isExternal -}}
{{- if strings.HasPrefix .Destination "/" -}}
{{- with $site.GetPage .Destination -}}
{{- $internalPage = . -}}
{{- $internalPageFound = true -}}
{{- end -}}
{{- else if and $path (ne $path "") -}}
{{- with $page.GetPage $path -}}
{{- $internalPage = . -}}
{{- $internalPageFound = true -}}
{{- end -}}
{{- end -}}
{{- if and (not $internalPageFound) $path (ne $path "") -}}
{{- with $site.GetPage $path -}}
{{- $internalPage = . -}}
{{- $internalPageFound = true -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $report := dict -}}
{{- if fileExists "tools/cache/external_links.yaml" -}}
{{- $report = transform.Unmarshal (readFile "tools/cache/external_links.yaml") -}}
{{- end -}}
{{- $deadList := default (slice) (index $report "links") -}}
{{- $entriesMap := default (dict) (index $report "entries") -}}
{{- $cacheEntry := index $entriesMap .Destination -}}
{{- $deadInfo := dict -}}
{{- $isDeadLink := false -}}
{{- with (first 1 (where $deadList "url" .Destination)) -}}
{{- $deadInfo = index . 0 -}}
{{- $isDeadLink = true -}}
{{- end -}}
{{- $titleParts := slice -}}
{{- if $isAffiliated -}}
{{- $titleParts = $titleParts | append "Lien affilié" -}}
{{- else if $isExternal -}}
{{- $titleParts = $titleParts | append "Lien externe" -}}
{{- end -}}
{{- if and (not $isExternal) $internalPageFound -}}
{{- $internalTitle := $internalPage.LinkTitle | default $internalPage.Title -}}
{{- with $internalPage.Date -}}
{{- $internalTitle = printf "%s (%s)" $internalTitle (. | time.Format "02/01/2006") -}}
{{- end -}}
{{- $titleParts = $titleParts | append $internalTitle -}}
{{- else -}}
{{- with .Title -}}
{{- $titleParts = $titleParts | append . -}}
{{- end -}}
{{- end -}}
{{- if $isDeadLink -}}
{{- $deadDetails := slice -}}
{{- with (index $cacheEntry "checkedAt") -}}
{{- $deadDetails = $deadDetails | append (printf "inaccessible depuis le %s" (time.Format "02/01/2006" (time .))) -}}
{{- end -}}
{{- with (index $cacheEntry "errorType") -}}
{{- $deadDetails = $deadDetails | append (printf "raison %s" .) -}}
{{- end -}}
{{- with (index $deadInfo "status") -}}
{{- $deadDetails = $deadDetails | append (printf "statut %v" .) -}}
{{- end -}}
{{- if gt (len $deadDetails) 0 -}}
{{- $titleParts = $titleParts | append (printf "(%s)" (delimit $deadDetails " ; ")) -}}
{{- end -}}
{{- end -}}
{{- $titleValue := delimit $titleParts " - " -}}
{{- $linkClasses := slice -}}
{{- if $isExternal -}}
{{- $linkClasses = $linkClasses | append "link-external" -}}
{{- end -}}
{{- if $isAffiliated -}}
{{- $linkClasses = $linkClasses | append "link-affiliated" -}}
{{- end -}}
{{- with $customClass -}}
{{- range (split . " ") -}}
{{- if ne . "" -}}
{{- $linkClasses = $linkClasses | append . -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- $classValue := delimit $linkClasses " " -}}
<a href="{{- $newURL -}}"{{ with $classValue }} class="{{- . -}}"{{ end }}{{ with $titleValue }} title="{{- . -}}"{{ end }}{{ if $isExternal }} rel="noreferrer noopener"{{ end }}>{{- strings.TrimSpace .Text | safeHTML -}}</a>{{- "" -}}

View File

@@ -0,0 +1,81 @@
{{- $w := .Params.weather -}}
{{- if or (not $w) (eq (len $w) 0) -}}
{{- return -}}
{{- end -}}
{{- $date := .Date -}}
{{- $hour := (time $date).Hour -}}
{{- $isNight := false -}}
{{- if or (lt $hour 6) (ge $hour 18) -}}
{{- $isNight = true -}}
{{- end -}}
{{- $precip := $w.precipitations -}}
{{- $wind := $w.wind_speed -}}
{{- $humidity := $w.humidity -}}
{{- $illum := $w.illuminance -}}
{{- $icon := "clear-day.svg" -}}
{{- if $isNight -}}
{{- $icon = "clear-night.svg" -}}
{{- end -}}
{{- if $precip -}}
{{- $icon = "rain.svg" -}}
{{- else if and $wind (ge $wind 45) -}}
{{- $icon = "wind.svg" -}}
{{- else if and $humidity (ge $humidity 90) (or (not $illum) (lt $illum 80)) -}}
{{- $icon = "fog.svg" -}}
{{- else if and $humidity (ge $humidity 75) -}}
{{- if $isNight -}}
{{- $icon = "partly-cloudy-night.svg" -}}
{{- else -}}
{{- $icon = "cloudy.svg" -}}
{{- end -}}
{{- end -}}
{{- $label := "Météo" -}}
{{- if eq $icon "clear-day.svg" -}}{{- $label = "Grand soleil" -}}{{- end -}}
{{- if eq $icon "clear-night.svg" -}}{{- $label = "Ciel dégagé" -}}{{- end -}}
{{- if eq $icon "partly-cloudy-day.svg" -}}{{- $label = "Partiellement nuageux" -}}{{- end -}}
{{- if eq $icon "partly-cloudy-night.svg" -}}{{- $label = "Partiellement nuageux" -}}{{- end -}}
{{- if eq $icon "cloudy.svg" -}}{{- $label = "Nuageux" -}}{{- end -}}
{{- if eq $icon "drizzle.svg" -}}{{- $label = "Bruine" -}}{{- end -}}
{{- if eq $icon "rain.svg" -}}{{- $label = "Pluvieux" -}}{{- end -}}
{{- if eq $icon "snow.svg" -}}{{- $label = "Neige" -}}{{- end -}}
{{- if eq $icon "thunderstorms-day.svg" -}}{{- $label = "Orage" -}}{{- end -}}
{{- if eq $icon "fog.svg" -}}{{- $label = "Brouillard" -}}{{- end -}}
{{- if eq $icon "wind.svg" -}}{{- $label = "Vent fort" -}}{{- end -}}
{{- $sources := slice -}}
{{- with $w.source -}}
{{- if reflect.IsSlice . -}}
{{- $sources = . -}}
{{- else -}}
{{- $sources = slice . -}}
{{- end -}}
{{- end -}}
<section>
<h2>Météo observée</h2>
<p>
<img src="/icons/weather/{{ $icon }}" alt="{{ $label }}" title="{{ $label }}" loading="lazy">
<strong>{{ printf "%s à %s" (time.Format "02/01/2006" $date) (time.Format ":time_short" $date) }}</strong>
</p>
<dl>
{{- with $w.temperature -}}<div><dt>Température</dt><dd>{{ printf "%.1f" (mul . 1.0) }} °C</dd></div>{{- end -}}
{{- with $w.humidity -}}<div><dt>Humidité</dt><dd>{{ printf "%.0f" (mul . 1.0) }} %</dd></div>{{- end -}}
{{- with $w.pressure -}}<div><dt>Pression</dt><dd>{{ printf "%.0f" (mul . 1.0) }} hPa</dd></div>{{- end -}}
{{- with $w.illuminance -}}<div><dt>Luminosité</dt><dd>{{ printf "%.0f" (mul . 1.0) }} lx</dd></div>{{- end -}}
{{- with $w.wind_speed -}}<div><dt>Vent</dt><dd>{{ printf "%.1f" (mul . 1.0) }} km/h</dd></div>{{- end -}}
{{- with $w.wind_direction -}}<div><dt>Direction</dt><dd>{{ printf "%.0f" (mul . 1.0) }}°</dd></div>{{- end -}}
</dl>
{{- if gt (len $sources) 0 -}}
<p>
Sources:
{{- range $i, $source := $sources -}}
{{- if gt $i 0 -}}, {{- end -}}{{ $source }}
{{- end -}}
</p>
{{- end -}}
</section>