Split app into subpages, persist ingame time, and add 14-month dashboard calendar

This commit is contained in:
Kai
2026-02-16 12:53:35 +01:00
parent 5c37a7ba43
commit 5528d3e688
15 changed files with 1522 additions and 1145 deletions

49
cmd/server/helpers.go Normal file
View File

@@ -0,0 +1,49 @@
package main
import (
"errors"
"net/http"
"net/url"
"strconv"
"strings"
)
func mustInt(v string, fallback int) int {
n, err := strconv.Atoi(strings.TrimSpace(v))
if err != nil {
return fallback
}
return n
}
func mustInt64(v string, fallback int64) int64 {
n, err := strconv.ParseInt(strings.TrimSpace(v), 10, 64)
if err != nil {
return fallback
}
return n
}
func parseInt64List(values []string) ([]int64, error) {
var out []int64
for _, v := range values {
id := mustInt64(v, 0)
if id <= 0 {
return nil, errors.New("invalid id")
}
out = append(out, id)
}
return out, nil
}
func placeholders(n int) string {
parts := make([]string, 0, n)
for i := 0; i < n; i++ {
parts = append(parts, "?")
}
return strings.Join(parts, ",")
}
func redirectWithMessage(w http.ResponseWriter, r *http.Request, path, key, val string) {
http.Redirect(w, r, path+"?"+key+"="+url.QueryEscape(val), http.StatusSeeOther)
}