From 4072e9888c94f661e6e10ab7db59403490313b30 Mon Sep 17 00:00:00 2001 From: julien Date: Fri, 20 Jun 2025 16:40:04 +0200 Subject: [PATCH] up --- renders/renders.go | 7 ++++--- templates/_file_detail.pages.tmpl | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/renders/renders.go b/renders/renders.go index 3a96e01..31fd881 100644 --- a/renders/renders.go +++ b/renders/renders.go @@ -28,7 +28,6 @@ var ( ) func init() { - // 1. Définissez votre FuncMap funcMap := template.FuncMap{ "hasSuffix": strings.HasSuffix, "ext": func(name string) string { @@ -36,13 +35,15 @@ func init() { }, "split": strings.Split, "trimPrefix": strings.TrimPrefix, + // nouveau helper pour convertir bytes -> kilobytes + "toKB": func(size int64) float64 { + return float64(size) / 1024 + }, } - // 2. Parsez tous les templates EN UNE FOIS, en injectant le FuncMap templates = template.Must( template.New(""). Funcs(funcMap). - // ajuste le chemin vers vos .pages.tmpl ParseGlob("./templates/*.pages.tmpl"), ) } diff --git a/templates/_file_detail.pages.tmpl b/templates/_file_detail.pages.tmpl index d1d1f6d..7333e98 100644 --- a/templates/_file_detail.pages.tmpl +++ b/templates/_file_detail.pages.tmpl @@ -2,7 +2,7 @@ {{ with .Entry }}

{{ .Name }}

Type : {{ ext .Name }}

-

Taille : {{ printf "%.1f KB" (float64 .Size/1024) }}

+

Taille : {{ printf "%.1f KB" (toKB .Size) }}

Modifié le : {{ .ModTime.Format "02 Jan 2006 15:04" }}

{{ if and (not .IsDir) (or (hasSuffix .Name ".jpg") (hasSuffix .Name ".png")) }}