From 5b67d5c5f0b410ad5e15d717bc418394b8aeedce Mon Sep 17 00:00:00 2001 From: Bel LaPointe <153096461+breel-render@users.noreply.github.com> Date: Thu, 19 Sep 2024 12:24:00 -0400 Subject: [PATCH] sort desc by date --- cmd/ui/index.html.tmpl | 5 +++-- cmd/ui/main.go | 7 +++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/ui/index.html.tmpl b/cmd/ui/index.html.tmpl index 0572b72..fba1c5c 100644 --- a/cmd/ui/index.html.tmpl +++ b/cmd/ui/index.html.tmpl @@ -6,10 +6,11 @@
{{ range .Series }} -
+
{{ .Thumbnail }} -

{{ .Thumbnail }}

+ {{ .Thumbnail }} +
{{ end }} diff --git a/cmd/ui/main.go b/cmd/ui/main.go index cfd57d5..3331511 100644 --- a/cmd/ui/main.go +++ b/cmd/ui/main.go @@ -13,6 +13,7 @@ import ( "os" "os/signal" "path" + "slices" "strings" "syscall" @@ -49,7 +50,6 @@ func Run(ctx context.Context, args []string) error { Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if strings.HasPrefix(r.URL.Path, "/media/") { http.StripPrefix("/media/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - log.Println(r.URL.Path, "vs", *d) http.FileServer(http.Dir(*d)).ServeHTTP(w, r) })).ServeHTTP(w, r) return @@ -88,11 +88,14 @@ func Run(ctx context.Context, args []string) error { for _, v := range seriesByKey { series = append(series, v) } + slices.SortFunc(series, func(a, b Series) int { + return -1 * strings.Compare(path.Base(a.Thumbnail), path.Base(b.Thumbnail)) + }) if err := tmpl.Execute(w, map[string]any{ "Series": series, }); err != nil { - log.Println(err, *d) + log.Println(err) } }), BaseContext: func(net.Listener) context.Context {