+ Saturday, February 7, 2026 · 6:30 PM
+Helios Gym
+597 Central Avenue, Sunnyvale, CA 94086
+All donations go to Sunnyvale Community Services. Thank you for your generosity!
+diff --git a/CLAUDE.md b/CLAUDE.md index dfcbcf2..7fbdaa8 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,8 +1,9 @@ +- Never change directories (no `cd`) - DO NOT add comments to code unless something is *incredibly* subtle - Use e.g. map[string]bool{} instead of make() wherever possible - Use all-lowercase log messages - Prepend log messages with [ERROR] if applicable -- Don't mention claude in commit messages. Keep them to a single, short, descriptive sentence +- Don't mention claude in commit messages (no Co-Authored-By). Keep them to a single, short, descriptive sentence - Always push after commiting - Use git add -A so you don't miss files when committing - Never use go build -- use go run instead diff --git a/main.go b/main.go index 7adcdfb..7ee4ca0 100644 --- a/main.go +++ b/main.go @@ -41,14 +41,33 @@ var events = map[string]eventInfo{ }, } +type SiteMode string + +const ( + SiteModeRSVP SiteMode = "rsvp" + SiteModeGive SiteMode = "give" +) + var ( - templates *template.Template - db *sql.DB + modeTemplates = map[SiteMode]*template.Template{} + domainModes = map[string]SiteMode{} + db *sql.DB ) func init() { - templates = template.Must(template.New("").ParseGlob("static/*.html")) - template.Must(templates.ParseGlob("static/*.js")) + for _, d := range strings.Split(os.Getenv("GIVE_DOMAINS"), ",") { + d = strings.TrimSpace(d) + if d != "" { + domainModes[d] = SiteModeGive + } + } + + for _, mode := range []SiteMode{SiteModeRSVP, SiteModeGive} { + dir := "static/" + string(mode) + "/" + modeTemplates[mode] = template.Must(template.New("").ParseGlob("static/shared/*.html")) + template.Must(modeTemplates[mode].ParseGlob(dir + "*.html")) + template.Must(modeTemplates[mode].ParseGlob(dir + "*.js")) + } var err error db, err = sql.Open("postgres", os.Getenv("PGCONN")) @@ -111,9 +130,12 @@ func handleStatic(w http.ResponseWriter, r *http.Request) { } name := strings.TrimPrefix(path, "/") + mode := getSiteMode(r) + tmpl := modeTemplates[mode] + staticDir := filepath.Join("static", string(mode)) if strings.HasSuffix(name, ".html") || strings.HasSuffix(name, ".js") { - t := templates.Lookup(name) + t := tmpl.Lookup(name) if t == nil { http.NotFound(w, r) return @@ -128,7 +150,7 @@ func handleStatic(w http.ResponseWriter, r *http.Request) { } if !strings.Contains(name, ".") { - t := templates.Lookup(name + ".html") + t := tmpl.Lookup(name + ".html") if t != nil { w.Header().Set("Content-Type", "text/html") t.Execute(w, templateData()) @@ -136,7 +158,7 @@ func handleStatic(w http.ResponseWriter, r *http.Request) { } } - http.ServeFile(w, r, filepath.Join("static", name)) + http.ServeFile(w, r, filepath.Join(staticDir, name)) } func templateData() map[string]any { @@ -155,6 +177,17 @@ func envMap() map[string]string { return m } +func getSiteMode(r *http.Request) SiteMode { + host := r.Host + if idx := strings.Index(host, ":"); idx != -1 { + host = host[:idx] + } + if mode, ok := domainModes[host]; ok { + return mode + } + return SiteModeRSVP +} + func handleGoogleCallback(w http.ResponseWriter, r *http.Request) { credential := r.FormValue("credential") if credential == "" { diff --git a/static/afac26-logo.png b/static/give/afac26-logo.png similarity index 100% rename from static/afac26-logo.png rename to static/give/afac26-logo.png diff --git a/static/give/afac26.html b/static/give/afac26.html new file mode 100644 index 0000000..e3d9604 --- /dev/null +++ b/static/give/afac26.html @@ -0,0 +1,203 @@ + + +
+ + +
+ Saturday, February 7, 2026 · 6:30 PM
+Helios Gym
+597 Central Avenue, Sunnyvale, CA 94086
+All donations go to Sunnyvale Community Services. Thank you for your generosity!
+