huge blog refactor

tidying up data structures; improvements to blog admin UI/UX, etc.
This commit is contained in:
ari melody 2025-11-08 12:54:31 +00:00
parent eaa2f6587d
commit 0c2aaa0b38
Signed by: ari
GPG key ID: CF99829C92678188
18 changed files with 432 additions and 239 deletions

View file

@ -109,19 +109,8 @@ func adminIndexHandler(app *model.AppState) http.Handler {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
var latestBlogPost *BlogPost = nil
if len(blogPosts) > 0 {
author, err := controller.GetAccountByID(app.DB, blogPosts[0].AuthorID)
if err != nil {
fmt.Fprintf(os.Stderr, "WARN: Failed to pull latest blog post author %s: %v\n", blogPosts[0].AuthorID, err)
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
latestBlogPost = &BlogPost{
BlogPost: blogPosts[0],
Author: author,
}
}
var latestBlogPost *model.BlogPost = nil
if len(blogPosts) > 0 { latestBlogPost = blogPosts[0] }
blogCount, err := controller.GetBlogPostCount(app.DB, false)
if err != nil {
fmt.Fprintf(os.Stderr, "WARN: Failed to pull blog post count: %v\n", err)
@ -137,7 +126,7 @@ func adminIndexHandler(app *model.AppState) http.Handler {
ArtistCount int
Tracks []*model.Track
TrackCount int
BlogPost *BlogPost
LatestBlogPost *model.BlogPost
BlogCount int
}
@ -149,7 +138,7 @@ func adminIndexHandler(app *model.AppState) http.Handler {
ArtistCount: artistCount,
Tracks: tracks,
TrackCount: trackCount,
BlogPost: latestBlogPost,
LatestBlogPost: latestBlogPost,
BlogCount: blogCount,
})
if err != nil {