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>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
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(),
|
||||
}})
|
||||
}
|
||||
Reference in New Issue
Block a user