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 @@ + + + + + + Donate - Applause for a Cause + + + +
+ + +
+ Applause for a Cause +

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!

+
+
+
Select a donation amount:
+
+ $25 + $50 + Other$ + $100 +
+
+ +
+
+
+
+ + + diff --git a/static/give/app.js b/static/give/app.js new file mode 120000 index 0000000..bcb2b7f --- /dev/null +++ b/static/give/app.js @@ -0,0 +1 @@ +../rsvp/app.js \ No newline at end of file diff --git a/static/favicon.png b/static/give/favicon.png similarity index 100% rename from static/favicon.png rename to static/give/favicon.png diff --git a/static/favicon.svg b/static/give/favicon.svg similarity index 100% rename from static/favicon.svg rename to static/give/favicon.svg diff --git a/static/give/index.html b/static/give/index.html new file mode 100644 index 0000000..e4ab748 --- /dev/null +++ b/static/give/index.html @@ -0,0 +1,46 @@ + + + + + + HCA Give + + + +
+

Events

+ {{template "event-afac26"}} +
+ + + diff --git a/static/_report.html b/static/rsvp/_report.html similarity index 100% rename from static/_report.html rename to static/rsvp/_report.html diff --git a/static/rsvp/afac26-logo.png b/static/rsvp/afac26-logo.png new file mode 100644 index 0000000..12c834a Binary files /dev/null and b/static/rsvp/afac26-logo.png differ diff --git a/static/afac26.html b/static/rsvp/afac26.html similarity index 99% rename from static/afac26.html rename to static/rsvp/afac26.html index 106f7e1..1a54b5c 100644 --- a/static/afac26.html +++ b/static/rsvp/afac26.html @@ -186,9 +186,9 @@ « Events