1

Amélioration de l'affichage

This commit is contained in:
2025-12-12 23:41:20 +01:00
parent 785a38427b
commit 6e0f8c6010
6 changed files with 55 additions and 54 deletions

View File

@@ -14,72 +14,68 @@
{{- $deadInfo := dict -}}
{{- $isDeadLink := false -}}
{{- with (first 1 (where $deadList "url" .Destination)) -}}
{{- $deadInfo = index . 0 -}}
{{- $isDeadLink = true -}}
{{- $deadInfo = index . 0 -}}
{{- $isDeadLink = true -}}
{{- end -}}
{{- $newURL := .Destination -}}
{{- if and $isExternal $aff -}}
{{- $param := $aff.param -}}
{{- $value := $aff.value -}}
{{- $isAffiliated = true -}}
{{- if $query -}}
{{- $newURL = printf "%s://%s%s?%s&%s=%s" $parsed.Scheme $host $path $query $param $value -}}
{{- else -}}
{{- $newURL = printf "%s://%s%s?%s=%s" $parsed.Scheme $host $path $param $value -}}
{{- end -}}
{{- $param := $aff.param -}}
{{- $value := $aff.value -}}
{{- $isAffiliated = true -}}
{{- if $query -}}
{{- $newURL = printf "%s://%s%s?%s&%s=%s" $parsed.Scheme $host $path $query $param $value -}}
{{- else -}}
{{- $newURL = printf "%s://%s%s?%s=%s" $parsed.Scheme $host $path $param $value -}}
{{- end -}}
{{- end -}}
{{- $titlePrefix := cond $isAffiliated "Lien affilié" (cond $isExternal "Lien externe" "") -}}
{{- $classes := slice -}}
{{- if $isExternal -}}
{{- $classes = $classes | append "external" -}}
{{- if $isAffiliated -}}
{{- $classes = $classes | append "affiliated" -}}
{{- end -}}
{{- $classes = $classes | append "external" -}}
{{- if $isAffiliated -}}
{{- $classes = $classes | append "affiliated" -}}
{{- end -}}
{{- end -}}
{{- if $isDeadLink -}}
{{- $statusRaw := index $deadInfo "status" -}}
{{- $statusCode := "" -}}
{{- with $statusRaw -}}
{{- $statusCode = printf "%v" . -}}
{{- end -}}
{{- if eq $statusCode "404" -}}
{{- $classes = $classes | append "dead" -}}
{{- else if gt (len $statusCode) 0 -}}
{{- $classes = $classes | append "problematic" -}}
{{- else -}}
{{- $classes = $classes | append "dead" -}}
{{- end -}}
{{- $statusRaw := index $deadInfo "status" -}}
{{- $statusCode := "" -}}
{{- with $statusRaw -}}
{{- $statusCode = printf "%v" . -}}
{{- end -}}
{{- if eq $statusCode "404" -}}
{{- $classes = $classes | append "dead" -}}
{{- else if gt (len $statusCode) 0 -}}
{{- $classes = $classes | append "problematic" -}}
{{- else -}}
{{- $classes = $classes | append "dead" -}}
{{- end -}}
{{- end -}}
{{- $titleParts := slice -}}
{{- with $titlePrefix -}}
{{- $titleParts = $titleParts | append . -}}
{{- $titleParts = $titleParts | append . -}}
{{- end -}}
{{- with .Title -}}
{{- $titleParts = $titleParts | append . -}}
{{- $titleParts = $titleParts | append . -}}
{{- 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 -}}
{{- with $deadDetails -}}
{{- $titleParts = $titleParts | append (printf "(%s)" (delimit . " ; ")) -}}
{{- end -}}
{{- $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 -}}
{{- with $deadDetails -}}
{{- $titleParts = $titleParts | append (printf "(%s)" (delimit . " ; ")) -}}
{{- end -}}
{{- end -}}
{{- $titleValue := delimit $titleParts " - " -}}
{{- $relAttr := "" -}}
{{- if $isExternal -}}
{{- $relAttr = "noreferrer noopener" -}}
{{- end -}}
<a href="{{ $newURL }}" title="{{ $titleValue }}"
{{- if gt (len $relAttr) 0 -}} rel="{{ $relAttr }}"{{- end -}}
{{- if gt (len $classes) 0 -}} class="{{ delimit $classes ` ` }}"{{- end -}}>
{{- .Text | safeHTML -}}
</a>
{{- /* */ -}}
{{- $relAttr = "noreferrer noopener" -}}
{{- end -}}<a href="{{ $newURL }}" title="{{ $titleValue }}" {{- if gt (len $relAttr) 0 -}} rel="{{ $relAttr }}" {{- end
-}} {{- if gt (len $classes) 0 -}} class="{{ delimit $classes ` ` }}" {{- end -}}>{{- .Text | safeHTML -}}</a>{{- /*
*/ -}}