Extraire les partiels de calcul du thème 2026
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
{{- $page := . -}}
|
||||
{{- $firstPage := false -}}
|
||||
|
||||
{{- with $page.Params.dossier -}}
|
||||
{{- $dossierID := index . 0 -}}
|
||||
{{- if $dossierID -}}
|
||||
{{- $group := where site.RegularPages "Params.dossier" "intersect" (slice $dossierID) -}}
|
||||
{{- if gt (len $group) 0 -}}
|
||||
{{- $weighted := slice -}}
|
||||
{{- range $group -}}
|
||||
{{- if isset .Params "weight" -}}
|
||||
{{- $weighted = $weighted | append . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $candidates := $group -}}
|
||||
{{- if gt (len $weighted) 0 -}}
|
||||
{{- $sortedByWeight := sort $weighted "Weight" "asc" -}}
|
||||
{{- $minWeight := (index $sortedByWeight 0).Weight -}}
|
||||
{{- $candidates = where $sortedByWeight "Weight" $minWeight -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $sortedByDate := sort $candidates "Date" "asc" -}}
|
||||
{{- $firstDate := (index $sortedByDate 0).Date -}}
|
||||
{{- $sameDate := where $sortedByDate "Date" $firstDate -}}
|
||||
{{- $firstPage = index (sort $sameDate "RelPermalink" "asc") 0 -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $firstPage -}}
|
||||
@@ -1,145 +0,0 @@
|
||||
{{- $url := "" -}}
|
||||
{{- $report := partialCached "external-links-report.html" (dict) "default" -}}
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- with index . "URL" -}}
|
||||
{{- $url = . -}}
|
||||
{{- end -}}
|
||||
{{- with index . "Report" -}}
|
||||
{{- $report = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $entries := default (dict) (index $report "entries") -}}
|
||||
{{- $deadLinksMap := default (dict) (index $report "linksMap") -}}
|
||||
|
||||
{{- $host := "" -}}
|
||||
{{- with $url -}}
|
||||
{{- $host = . | replaceRE "^https?://([^/]+).*$" "$1" | replaceRE "^www\\." "" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $lookupURLs := slice -}}
|
||||
{{- with $url -}}
|
||||
{{- $lookupURLs = $lookupURLs | append . -}}
|
||||
{{- if strings.HasSuffix . "/" -}}
|
||||
{{- $withoutSlash := strings.TrimSuffix "/" . -}}
|
||||
{{- if ne $withoutSlash . -}}
|
||||
{{- $lookupURLs = $lookupURLs | append $withoutSlash -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- $lookupURLs = $lookupURLs | append (printf "%s/" .) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $entry := dict -}}
|
||||
{{- range $lookupURLs -}}
|
||||
{{- if and (eq (len $entry) 0) (isset $entries .) -}}
|
||||
{{- $entry = index $entries . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $deadInfo := dict -}}
|
||||
{{- range $lookupURLs -}}
|
||||
{{- if and (eq (len $deadInfo) 0) (isset $deadLinksMap .) -}}
|
||||
{{- $deadInfo = index $deadLinksMap . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $statusCode := 0 -}}
|
||||
{{- $statusRaw := "" -}}
|
||||
{{- $statusChecked := "" -}}
|
||||
{{- $statusErrorType := "" -}}
|
||||
{{- $statusTone := "unknown" -}}
|
||||
{{- $statusLabel := "État inconnu" -}}
|
||||
{{- $statusTitle := "" -}}
|
||||
{{- $statusManual := false -}}
|
||||
|
||||
{{- with index $entry "manualMarked" -}}
|
||||
{{- $statusManual = . -}}
|
||||
{{- end -}}
|
||||
{{- if and (not $statusManual) (gt (len $deadInfo) 0) -}}
|
||||
{{- with index $deadInfo "manualMarked" -}}
|
||||
{{- $statusManual = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if gt (len $entry) 0 -}}
|
||||
{{- with index $entry "status" -}}
|
||||
{{- $statusString := printf "%v" . -}}
|
||||
{{- if gt (len (findRE "^[0-9]+$" $statusString)) 0 -}}
|
||||
{{- $statusCode = int $statusString -}}
|
||||
{{- else -}}
|
||||
{{- $statusRaw = $statusString -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- with index $entry "checkedAt" -}}
|
||||
{{- $statusChecked = . -}}
|
||||
{{- end -}}
|
||||
{{- with index $entry "errorType" -}}
|
||||
{{- $statusErrorType = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $statusCode 0) (eq $statusRaw "") (gt (len $deadInfo) 0) -}}
|
||||
{{- with index $deadInfo "status" -}}
|
||||
{{- $statusString := printf "%v" . -}}
|
||||
{{- if gt (len (findRE "^[0-9]+$" $statusString)) 0 -}}
|
||||
{{- $statusCode = int $statusString -}}
|
||||
{{- else -}}
|
||||
{{- $statusRaw = $statusString -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $statusErrorType "") (gt (len $deadInfo) 0) -}}
|
||||
{{- with index $deadInfo "errorType" -}}
|
||||
{{- $statusErrorType = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (eq $statusChecked "") (gt (len $deadInfo) 0) -}}
|
||||
{{- with index $deadInfo "checkedAt" -}}
|
||||
{{- $statusChecked = . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $statusManual -}}
|
||||
{{- $statusTone = "dead" -}}
|
||||
{{- $statusLabel = "Supprimé" -}}
|
||||
{{- $statusTitle = "Lien marqué comme supprimé dans data/deletions.yaml" -}}
|
||||
{{- else if gt $statusCode 0 -}}
|
||||
{{- if lt $statusCode 400 -}}
|
||||
{{- $statusTone = "ok" -}}
|
||||
{{- $statusLabel = printf "OK %d" $statusCode -}}
|
||||
{{- else if lt $statusCode 500 -}}
|
||||
{{- $statusTone = "warn" -}}
|
||||
{{- $statusLabel = printf "Erreur %d" $statusCode -}}
|
||||
{{- $statusTitle = printf "Réponse HTTP %d lors de la dernière vérification" $statusCode -}}
|
||||
{{- else -}}
|
||||
{{- $statusTone = "dead" -}}
|
||||
{{- $statusLabel = printf "Erreur %d" $statusCode -}}
|
||||
{{- $statusTitle = printf "Réponse HTTP %d lors de la dernière vérification" $statusCode -}}
|
||||
{{- end -}}
|
||||
{{- else if ne $statusRaw "" -}}
|
||||
{{- $statusTone = "dead" -}}
|
||||
{{- $statusLabel = "Erreur" -}}
|
||||
{{- $statusTitle = printf "Erreur %s lors de la dernière vérification" (upper $statusRaw) -}}
|
||||
{{- else if ne $statusErrorType "" -}}
|
||||
{{- $statusTone = "dead" -}}
|
||||
{{- $statusLabel = "Erreur" -}}
|
||||
{{- $statusTitle = printf "Erreur %s lors de la dernière vérification" (upper $statusErrorType) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if and (ne $statusTitle "") (ne $statusChecked "") -}}
|
||||
{{- $statusTitle = printf "%s (vérifié le %s)" $statusTitle ((time $statusChecked) | time.Format "02/01/2006") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return dict
|
||||
"Host" $host
|
||||
"Code" $statusCode
|
||||
"Raw" $statusRaw
|
||||
"CheckedAt" $statusChecked
|
||||
"ErrorType" $statusErrorType
|
||||
"Tone" $statusTone
|
||||
"Label" $statusLabel
|
||||
"Title" $statusTitle
|
||||
-}}
|
||||
@@ -1,74 +0,0 @@
|
||||
{{- $reportPath := "data/external_links.yaml" -}}
|
||||
{{- $report := dict -}}
|
||||
|
||||
{{- if reflect.IsMap . -}}
|
||||
{{- with index . "ReportPath" -}}
|
||||
{{- $reportPath = . -}}
|
||||
{{- end -}}
|
||||
{{- with index . "Report" -}}
|
||||
{{- $report = . -}}
|
||||
{{- end -}}
|
||||
{{- else if . -}}
|
||||
{{- $report = . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if eq (len $report) 0 -}}
|
||||
{{- if eq $reportPath "data/external_links.yaml" -}}
|
||||
{{- with index site.Data "external_links" -}}
|
||||
{{- $report = . -}}
|
||||
{{- end -}}
|
||||
{{- else if fileExists $reportPath -}}
|
||||
{{- $report = transform.Unmarshal (readFile $reportPath) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $sourceLinks := slice -}}
|
||||
{{- with index $report "deadLinks" -}}
|
||||
{{- $sourceLinks = . -}}
|
||||
{{- end -}}
|
||||
{{- if and (eq (len $sourceLinks) 0) (isset $report "links") -}}
|
||||
{{- $sourceLinks = default (slice) (index $report "links") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $links := slice -}}
|
||||
{{- range $sourceLinks -}}
|
||||
{{- $code := "" -}}
|
||||
{{- if isset . "code" -}}
|
||||
{{- $rawCode := index . "code" -}}
|
||||
{{- if ne $rawCode nil -}}
|
||||
{{- $code = printf "%v" $rawCode -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $statusText := "" -}}
|
||||
{{- with index . "statusText" -}}
|
||||
{{- $statusText = printf "%v" . -}}
|
||||
{{- end -}}
|
||||
{{- if eq $statusText "" -}}
|
||||
{{- with index . "status" -}}
|
||||
{{- $statusText = printf "%v" . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- $status := "" -}}
|
||||
{{- with $code -}}
|
||||
{{- $status = . -}}
|
||||
{{- end -}}
|
||||
{{- if and (eq $status "") (ne $statusText "") -}}
|
||||
{{- $status = $statusText -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $links = $links | append (dict
|
||||
"url" (default "" (index . "url"))
|
||||
"code" $code
|
||||
"statusText" $statusText
|
||||
"status" $status
|
||||
"locations" (default (slice) (index . "locations"))
|
||||
"errorType" (default "" (index . "errorType"))
|
||||
"checkedAt" (default "" (index . "checkedAt"))
|
||||
) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return (dict
|
||||
"generatedAt" (default "" (index $report "generatedAt"))
|
||||
"entries" (default (dict) (index $report "entries"))
|
||||
"links" $links
|
||||
) -}}
|
||||
@@ -1,30 +0,0 @@
|
||||
{{- $page := . -}}
|
||||
{{- $isLead := true -}}
|
||||
{{- with $page.Params.dossier -}}
|
||||
{{- $dossierID := index . 0 -}}
|
||||
{{- if $dossierID -}}
|
||||
{{- $group := where site.RegularPages "Params.dossier" "intersect" (slice $dossierID) -}}
|
||||
{{- if gt (len $group) 1 -}}
|
||||
{{- $weighted := slice -}}
|
||||
{{- range $group -}}
|
||||
{{- if isset .Params "weight" -}}
|
||||
{{- $weighted = $weighted | append . -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $candidates := $group -}}
|
||||
{{- if gt (len $weighted) 0 -}}
|
||||
{{- $sortedByWeight := sort $weighted "Weight" "asc" -}}
|
||||
{{- $minWeight := (index $sortedByWeight 0).Weight -}}
|
||||
{{- $candidates = where $sortedByWeight "Weight" $minWeight -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $sortedByDate := sort $candidates "Date" "asc" -}}
|
||||
{{- $firstDate := (index $sortedByDate 0).Date -}}
|
||||
{{- $sameDate := where $sortedByDate "Date" $firstDate -}}
|
||||
{{- $firstPage := index (sort $sameDate "RelPermalink" "asc") 0 -}}
|
||||
{{- $isLead = eq $firstPage.File.Path $page.File.Path -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- if $isLead -}}true{{- end -}}
|
||||
@@ -1,19 +0,0 @@
|
||||
{{- $raw := printf "%v" . -}}
|
||||
{{- $trimmed := strings.TrimSpace $raw -}}
|
||||
{{- $result := dict
|
||||
"isURL" false
|
||||
"label" ""
|
||||
"url" ""
|
||||
-}}
|
||||
{{- if gt (len (findRE `(?i)^https?://[^[:space:]]+$` $trimmed)) 0 -}}
|
||||
{{- $parsedURL := urls.Parse $trimmed -}}
|
||||
{{- $host := replaceRE `:\d+$` "" $parsedURL.Host -}}
|
||||
{{- if ne $host "" -}}
|
||||
{{- $result = dict
|
||||
"isURL" true
|
||||
"label" $host
|
||||
"url" $trimmed
|
||||
-}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- return $result -}}
|
||||
@@ -1,32 +0,0 @@
|
||||
{{/* Préserve les GIF animés en évitant toute transformation Hugo. */}}
|
||||
{{- $image := .image -}}
|
||||
{{- if not $image -}}
|
||||
{{- errorf "media/process-image.html: missing image resource" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $action := .action -}}
|
||||
{{- if not $action -}}
|
||||
{{- errorf "media/process-image.html: missing image action for %q" $image.Name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $spec := .spec -}}
|
||||
{{- if not $spec -}}
|
||||
{{- errorf "media/process-image.html: missing image spec for %q" $image.Name -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $result := $image -}}
|
||||
{{- $subType := lower $image.MediaType.SubType -}}
|
||||
{{- if and (ne $subType "svg") (ne $subType "gif") -}}
|
||||
{{- $options := printf "%s webp q80" $spec -}}
|
||||
{{- if eq $action "Fill" -}}
|
||||
{{- $result = $image.Fill $options -}}
|
||||
{{- else if eq $action "Crop" -}}
|
||||
{{- $result = $image.Crop $options -}}
|
||||
{{- else if eq $action "Resize" -}}
|
||||
{{- $result = $image.Resize $options -}}
|
||||
{{- else -}}
|
||||
{{- errorf "media/process-image.html: unsupported image action %q for %q" $action $image.Name -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return $result -}}
|
||||
Reference in New Issue
Block a user