Files
supermarket/internal/web/about.go
T
davidandClaude Opus 5.5 7a857c7346 Phase 9, part 1: editions and their settings
SUPERMARKET_MODE picks local (the default), server or multi. internal/config
reads and checks every setting the editions need (database, secret key,
storage, the app's own mail, an https address), reporting all problems at
once. supermarket config prints them without passwords; supermarket
secret-key makes a key. Settings -> About shows the edition. Server and
multi-tenant are checked but refuse to start until they're built.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 06:55:30 -07:00

45 lines
976 B
Go

package web
import (
"net/http"
"os"
"supermarket/internal/config"
"supermarket/internal/db"
)
// config is how this Supermarket is run: the local edition's defaults when
// none was given (tests).
func (s *Server) config() *config.Config {
if s.Config != nil {
return s.Config
}
c, _ := config.Load(func(k string) string {
switch k {
case config.EnvData, config.EnvHostData:
return s.DataDir
case config.EnvPublicURL:
return s.PublicURL
case config.EnvMode:
return ""
}
return os.Getenv(k)
})
return c
}
type aboutData struct {
Edition config.Edition
Version string
Schema int
Items []config.Item
}
// aboutPage shows the edition and how it's run (Settings → About).
func (s *Server) aboutPage(w http.ResponseWriter, r *http.Request) {
c := s.config()
s.render(w, r, "about", page{Title: "About", Nav: "settings/about", Data: aboutData{
Edition: c.Edition, Version: s.Version, Schema: db.Schema(), Items: c.Summary(),
}})
}