summaryrefslogtreecommitdiff
path: root/internal/web/server.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 14:38:12 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-07-24 14:38:12 +0200
commit35f98e0a8a0573d51a4412ec7f60c7de068acfe6 (patch)
tree52bafbc1b3f8dc4c20dd5db536849a4f66daeda5 /internal/web/server.go
parentc769f80475e99b1f810fbb6c29eade3cc43a3786 (diff)
downloadlectio-35f98e0a8a0573d51a4412ec7f60c7de068acfe6.tar.gz
lectio-35f98e0a8a0573d51a4412ec7f60c7de068acfe6.zip
web: drop phantom hidden bt for traditional on explicit submit, so 'no version -> nothing' works in trad too; v0.13.1
Diffstat (limited to 'internal/web/server.go')
-rw-r--r--internal/web/server.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/web/server.go b/internal/web/server.go
index 6393076..7c90e9e 100644
--- a/internal/web/server.go
+++ b/internal/web/server.go
@@ -107,6 +107,17 @@ func requestVersions(cfg config.Config, r *http.Request) []string {
return []string{cfg.DefaultVersion}
}
+// withoutVersion returns versions with every occurrence of drop removed.
+func withoutVersion(versions []string, drop string) []string {
+ kept := make([]string, 0, len(versions))
+ for _, v := range versions {
+ if v != drop {
+ kept = append(kept, v)
+ }
+ }
+ return kept
+}
+
// queryBool reads a truthy/falsy query param ("1"/"true"/"on"/"yes" vs.
// "0"/"false"/"off"/"no"), falling back to def when the param is absent or
// unrecognized.
@@ -156,6 +167,15 @@ func resolveQuery(cfg config.Config, r *http.Request) (date, lectionary string,
lectionary = requestLectionary(cfg, r)
all = queryBool(r, "all", cfg.All)
versions = requestVersions(cfg, r)
+ // "bt" (the niedziela modern scrape) is invalid for the traditional
+ // lectionary and is hidden in the form -- but a box hidden by CSS stays
+ // checked, so switching modern->traditional carries a phantom v=bt that
+ // EffectiveVersions would substitute to wuj, defeating "no version selected
+ // -> nothing". On an explicit form submit (vset) drop that phantom bt; a
+ // fresh visit (no vset) keeps bt so its bt->wuj default still shows.
+ if lectionary == "traditional" && r.URL.Query().Has("vset") {
+ versions = withoutVersion(versions, "bt")
+ }
display = requestDisplay(cfg, r)
return date, lectionary, all, versions, display
}