This commit is contained in:
2026-08-23 14:13:18 -05:00
parent 789bf91eed
commit 866f243f1b
37 changed files with 1761 additions and 58 deletions
+14 -5
View File
@@ -10,8 +10,10 @@ import (
// scanning details (sql.Null*) out of the .html files.
type ArtistView struct {
ID string
Name string
ID string
Name string
Bio string
CoverArtID string
}
type AlbumView struct {
@@ -32,10 +34,15 @@ type SongRow struct {
TrackNumber int64
DurationSeconds float64
Starred bool
IsAdmin bool
}
func toArtistView(a *database.Artist) ArtistView {
return ArtistView{ID: a.ID, Name: a.Name}
v := ArtistView{ID: a.ID, Name: a.Name, Bio: a.Bio}
if a.CoverArtID.Valid {
v.CoverArtID = a.CoverArtID.String
}
return v
}
func toAlbumView(db *sql.DB, a *database.Album) AlbumView {
@@ -56,12 +63,14 @@ func toAlbumView(db *sql.DB, a *database.Album) AlbumView {
// toSongRow builds a display row for a song, given its owning album (may
// be nil for albumless tracks) and the current user (for the starred
// flag; pass "" userID to skip that lookup).
func toSongRow(db *sql.DB, s *database.Song, album *database.Album, userID string) SongRow {
// flag; pass "" userID to skip that lookup, and isAdmin=false to hide
// the row's "Edit" link).
func toSongRow(db *sql.DB, s *database.Song, album *database.Album, userID string, isAdmin bool) SongRow {
row := SongRow{
ID: s.ID,
Title: s.Title,
DurationSeconds: 0,
IsAdmin: isAdmin,
}
if s.TrackNumber.Valid {
row.TrackNumber = s.TrackNumber.Int64