From 8c56c9da55934f03c840ae795832879bdd5f9a87 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Sat, 17 Oct 2026 14:05:05 -0400 Subject: [PATCH] refactor(cards): SSR series and tag pages through the builder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both BrowseDetail surfaces hand-rolled bare 4-field literals (badges dropped) and patched the nil-slice with []BookInfo{} seeds after. BookCardsFromMediaItems feeds GetSeriesBooks/GetBooksByTag rows — cards gain format_group + badge on the series and tag pages, and the two seed blocks die with the adapter's non-nil empties. Conflict stamping at these sites was already adjacent and is preserved. --- internal/router/frontend.go | 32 +++----------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) diff --git a/internal/router/frontend.go b/internal/router/frontend.go index e85bc709..7492e8fb 100644 --- a/internal/router/frontend.go +++ b/internal/router/frontend.go @@ -241,20 +241,7 @@ func registerFrontendRoutes(cfg *Config) { log.Printf("GetSeriesBooks failed: %v", err) errorMsg = "Error loading series books" } else { - bookInfoList = make([]handlers.BookInfo, 0, len(books)) - for _, item := range books { - itemUUID, _ := uuid.FromBytes(item.ID.Bytes[0:16]) - bookInfoList = append(bookInfoList, handlers.BookInfo{ - MediaItemID: itemUUID.String(), - Title: item.Title, - Author: textToString(item.Author), - CoverImagePath: utils.ResolveMediaURL(item.LibraryID, item.CoverImagePath), - }) - } - } - - if bookInfoList == nil { - bookInfoList = []handlers.BookInfo{} + bookInfoList = handlers.BookCardsFromMediaItems(books, handlers.LibraryTypeMap(c.Request().Context(), cfg.Queries)) } seriesUserUUID, _ := uuid.Parse(user.ID) @@ -295,23 +282,10 @@ func registerFrontendRoutes(cfg *Config) { log.Printf("GetBooksByTag failed: %v", err) errorMsg = "Error loading tag books" } else { - bookInfoList = make([]handlers.BookInfo, 0, len(books)) - for _, item := range books { - itemUUID, _ := uuid.FromBytes(item.ID.Bytes[0:16]) - bookInfoList = append(bookInfoList, handlers.BookInfo{ - MediaItemID: itemUUID.String(), - Title: item.Title, - Author: textToString(item.Author), - CoverImagePath: utils.ResolveMediaURL(item.LibraryID, item.CoverImagePath), - }) - } + bookInfoList = handlers.BookCardsFromMediaItems(books, handlers.LibraryTypeMap(c.Request().Context(), cfg.Queries)) } } - if bookInfoList == nil { - bookInfoList = []handlers.BookInfo{} - } - tagUserUUID, _ := uuid.Parse(user.ID) bookInfoList = handlers.MarkActiveConflicts(c.Request().Context(), cfg.Queries, pgtype.UUID{Bytes: tagUserUUID, Valid: true}, bookInfoList) @@ -1298,7 +1272,7 @@ func registerFrontendRoutes(cfg *Config) { LibraryName: p.LibraryName, SHA256: p.FileSha256, SHAShort: p.FileSha256[:16] + "…", - CreatedAt: p.CreatedAt.Time.In(utils.UserLocation(user.Timezone)).Format("Jan 2, 2006"), + CreatedAt: p.CreatedAt.Time.In(utils.UserLocation(user.Timezone)).Format("Jan 2, 2006"), Items: []templates.HashConflictItemData{}, }