sort desc by date

This commit is contained in:
Bel LaPointe
2024-09-19 12:24:00 -04:00
parent 93aecf47c6
commit 5b67d5c5f0
2 changed files with 8 additions and 4 deletions

View File

@@ -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 {