summaryrefslogtreecommitdiff
path: root/internal/web/server.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/server.go')
-rw-r--r--internal/web/server.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/internal/web/server.go b/internal/web/server.go
index 110dae7..d8b451a 100644
--- a/internal/web/server.go
+++ b/internal/web/server.go
@@ -156,16 +156,17 @@ func resolveQuery(cfg config.Config, r *http.Request) (date, lectionary string,
// 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.
-func loadSections(cfg config.Config, lectionary, date string, all bool, versions []string) ([]liturgy.Section, []string, error) {
+// always match what was actually loadable. dayInfo is the day's celebration
+// identity (see liturgy.DayInfo), zero when the source carried 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
- versions = render.EffectiveVersions(versions, lectionary, cfg.Offline)
- secs, err := readings.Load(cfg, readings.Options{
+ effVersions = render.EffectiveVersions(versions, lectionary, cfg.Offline)
+ secs, dayInfo, err = readings.Load(cfg, readings.Options{
Date: date,
Offline: cfg.Offline,
All: all,
})
- return secs, versions, err
+ return secs, dayInfo, effVersions, err
}
// indexData is what templates/index.html ranges/branches over.
@@ -208,8 +209,8 @@ func indexHandler(cfg config.Config) http.HandlerFunc {
theme = cfg.WebTheme
}
- secs, loadVersions, err := loadSections(cfg, lectionary, date, all, versions)
- reading := renderOrError(secs, loadVersions, lectionary, display, cfg.UILanguage, err)
+ secs, dayInfo, loadVersions, err := loadSections(cfg, lectionary, date, all, versions)
+ reading := renderOrError(secs, loadVersions, lectionary, display, cfg.UILanguage, dayInfo, err)
// Check the boxes for the versions actually rendered (loadVersions),
// not the raw request: traditional/offline substitute pl->wuj, so the
@@ -258,8 +259,8 @@ func readingsHandler(cfg config.Config) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
date, lectionary, all, versions, display := resolveQuery(cfg, r)
- secs, loadVersions, err := loadSections(cfg, lectionary, date, all, versions)
- reading := renderOrError(secs, loadVersions, lectionary, display, cfg.UILanguage, err)
+ secs, dayInfo, loadVersions, err := loadSections(cfg, lectionary, date, all, versions)
+ reading := renderOrError(secs, loadVersions, lectionary, display, cfg.UILanguage, dayInfo, err)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
io.WriteString(w, string(reading))
@@ -271,14 +272,14 @@ func readingsHandler(cfg config.Config) http.HandlerFunc {
// paragraph, localised via lang -- readings.Load errors are expected in
// normal operation (an unpublished date, no network while online, ...) so
// the pane should show them, not 500.
-func renderOrError(secs []liturgy.Section, versions []string, lectionary, display, lang string, err error) template.HTML {
+func renderOrError(secs []liturgy.Section, versions []string, lectionary, display, lang string, dayInfo liturgy.DayInfo, err error) template.HTML {
if err != nil {
return template.HTML(`<p class="error">` + template.HTMLEscapeString(err.Error()) + `</p>`)
}
if len(secs) == 0 {
return template.HTML(`<p class="error">` + template.HTMLEscapeString(i18n.Get(lang).NoReadingsDay) + `</p>`)
}
- return RenderReadings(secs, versions, lectionary, display, lang)
+ return RenderReadings(secs, versions, lectionary, display, lang, dayInfo)
}
// themeCSSHandler serves one theme's stylesheet: the requested name, or