diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:52:13 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-28 12:52:13 +0200 |
| commit | 44472bbe31475a3c672ae003d928d7caffb4b50a (patch) | |
| tree | e74bae03c61b62479ef4f68b046e3345618933c8 /internal/web/server.go | |
| parent | 626f2275438a37e5cd2efb5964281b9bef5ce8cc (diff) | |
| parent | 7b220084cf3951c8cde0582efdfcf628afc64336 (diff) | |
| download | lectio-44472bbe31475a3c672ae003d928d7caffb4b50a.tar.gz lectio-44472bbe31475a3c672ae003d928d7caffb4b50a.zip | |
Merge branch 'of-offline-migration': offline daily view, remove scrapers
Diffstat (limited to 'internal/web/server.go')
| -rw-r--r-- | internal/web/server.go | 52 |
1 files changed, 8 insertions, 44 deletions
diff --git a/internal/web/server.go b/internal/web/server.go index fce0f22..6e76d3f 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -35,7 +35,7 @@ import ( // bibleVersions is the fixed, Themes-independent list of scripture versions // the web UI's checkboxes offer -- independent of any one cfg.Versions, so // every visitor sees the same five choices regardless of their config file. -var bibleVersions = []string{"bt", "wuj", "vul", "grb", "drb"} +var bibleVersions = []string{"wuj", "vul", "grb", "drb"} // server holds the live, mutable config + book table so /settings can apply // changes to the running process. All handlers read a snapshot via get()/table(). @@ -142,17 +142,6 @@ 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. @@ -202,35 +191,19 @@ 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 } -// loadSections runs the readings router for one request: date/lectionary -// override cfg, all controls part filtering, and versions is swapped via -// render.OfflineVersions -- when cfg.Offline (any lectionary needs the -// network-free set), or when lectionary is "traditional" (pl is the -// niedziela.pl modern scrape, meaningless for missalemeum) -- before being -// handed back to the caller for rendering, so the caller's column labels -// always match what was actually loadable. dayInfo is the day's celebration -// identity (see liturgy.DayInfo), zero when the source carried none. +// loadSections computes one request's readings offline: date/lectionary +// override cfg, all controls part filtering, and versions is passed through +// render.EffectiveVersions (which maps any legacy "bt" to "wuj") so the +// caller's column labels always match what was actually loadable. dayInfo is +// the day's celebration identity (see liturgy.DayInfo), zero when none. func loadSections(cfg config.Config, lectionary, date string, all bool, versions []string) (secs []liturgy.Section, dayInfo liturgy.DayInfo, effVersions []string, err error) { cfg.Lectionary = lectionary effVersions = render.EffectiveVersions(versions, lectionary, cfg.Offline) - secs, dayInfo, err = readings.Load(cfg, readings.Options{ - Date: date, - Offline: cfg.Offline, - All: all, - }) + secs, dayInfo, err = readings.Load(cfg, readings.Options{Date: date, All: all}) return secs, dayInfo, effVersions, err } @@ -406,7 +379,7 @@ func calendarHandler(cfg config.Config) http.HandlerFunc { var days []export.CalendarDay for d := first; int(d.Month()) == month; d = d.AddDate(0, 0, 1) { cd := export.CalendarDay{Day: d.Day()} - if secs, info, lerr := readings.Load(cfg, readings.Options{Date: d.Format("2006-01-02"), Offline: cfg.Offline, All: false}); lerr == nil { + if secs, info, lerr := readings.Load(cfg, readings.Options{Date: d.Format("2006-01-02"), All: false}); lerr == nil { cd.Name = info.Name cd.Colour = info.Colour cd.Citation = readings.GospelCitation(secs) @@ -799,7 +772,6 @@ func settingsPost(s *server) http.HandlerFunc { cfg := s.get() // start from live cfg so Parts/SchemaVersion are preserved cfg.Lectionary = normLect(r.PostForm.Get("lectionary"), cfg.Lectionary) - cfg.TraditionalLang = pickLang(r.PostForm.Get("traditional_lang"), cfg.TraditionalLang) cfg.UILanguage = config.NormalizeUILanguage(r.PostForm.Get("ui_language")) cfg.SiglaStyle = config.NormalizeSiglaStyle(r.PostForm.Get("sigla_style")) cfg.WebDisplay = config.NormalizeDisplay(r.PostForm.Get("web_display")) @@ -865,14 +837,6 @@ func normLect(v, def string) string { return def } -// pickLang returns v if it is "pl"/"en", else def. -func pickLang(v, def string) string { - if v == "pl" || v == "en" { - return v - } - return def -} - func atoiOr(s string, def int) int { if n, err := strconv.Atoi(strings.TrimSpace(s)); err == nil { return n |
