Add per-feed visibility settings panel

Visitors can hide individual feeds via a gear-icon panel in the header.
Preferences live in localStorage; the server ships the full source list
(name + channel) as window.PETE_SOURCES so the panel lists every feed,
grouped by channel, regardless of what's on the current page.
This commit is contained in:
prosolis
2026-05-26 17:15:46 -07:00
parent 92d700f2bb
commit a15025089d
6 changed files with 207 additions and 15 deletions

View File

@@ -40,17 +40,24 @@ var channels = []Channel{
{Slug: "foss", Title: "FOSS", Theme: "foss", Emoji: "🐧", Blurb: "Kernel, distros, and the wider free and open source software world."},
}
// SourceInfo is the trimmed view of a configured feed for the settings panel.
type SourceInfo struct {
Name string `json:"name"`
Channel string `json:"channel"`
}
// Server is the HTTP server for Pete's web UI.
type Server struct {
cfg config.WebConfig
srv *http.Server
tpls map[string]*template.Template // keyed by page name (e.g. "index", "channel")
cfg config.WebConfig
sources []SourceInfo
srv *http.Server
tpls map[string]*template.Template // keyed by page name (e.g. "index", "channel")
}
// New builds the server. Templates are parsed once at startup. Each page
// gets its own template set sharing layout.html + _card.html, which avoids
// `main` define collisions between pages.
func New(cfg config.WebConfig) (*Server, error) {
func New(cfg config.WebConfig, sources []config.SourceConfig) (*Server, error) {
pages := []string{"index", "channel", "weather"}
tpls := make(map[string]*template.Template, len(pages))
for _, p := range pages {
@@ -64,7 +71,14 @@ func New(cfg config.WebConfig) (*Server, error) {
}
tpls[p] = t
}
s := &Server{cfg: cfg, tpls: tpls}
infos := make([]SourceInfo, 0, len(sources))
for _, sc := range sources {
if !sc.Enabled || sc.Name == "" {
continue
}
infos = append(infos, SourceInfo{Name: sc.Name, Channel: sc.DirectRoute})
}
s := &Server{cfg: cfg, sources: infos, tpls: tpls}
mux := http.NewServeMux()
staticSub, err := fs.Sub(staticFS, "static")