diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-29 15:06:57 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-07-29 15:06:57 +0200 |
| commit | ae8af86660243b75db1d54bb0c8d26431bd17f52 (patch) | |
| tree | e3b8c469017ab25b83fa3f67807804b955b67e4f /internal/web/server.go | |
| parent | cd8b2f25f390d9d6d5a4d5cb27c4cd2ed8ab4073 (diff) | |
| download | lectio-ae8af86660243b75db1d54bb0c8d26431bd17f52.tar.gz lectio-ae8af86660243b75db1d54bb0c8d26431bd17f52.zip | |
web: reader link to the left, downloads into a "pobierz" disclosure
Finish the top-bar rework. The reader entry point now leads the controls
bar on the far left (it was in the right-hand cluster); settings stays in
the top-right cluster.
The flat "download: txt md pdf ยท kalendarz" strip becomes a single
"pobierz" summary that opens a small floating panel with two rows:
- a month calendar with its own month + year <select> pickers (localised
month names, both pre-selected from the shown date) and a PDF button
that hits /calendar?month=YYYY-MM;
- the shown day's readings as txt/md/pdf, labelled with the date.
The panel is absolutely positioned under the link so opening it doesn't
reflow the bar. indexData gains MonthOpts/YearOpts (a calOpt list); the
year picker is a small window around the shown year.
Diffstat (limited to 'internal/web/server.go')
| -rw-r--r-- | internal/web/server.go | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/internal/web/server.go b/internal/web/server.go index 7d9dfe5..f02bc12 100644 --- a/internal/web/server.go +++ b/internal/web/server.go @@ -219,6 +219,10 @@ type indexData struct { Display string Mono bool Reading template.HTML + // MonthOpts/YearOpts populate the "pobierz" panel's month-calendar + // download pickers (localised month names + a year window around the + // shown date). + MonthOpts, YearOpts []calOpt // L holds the localised control labels (lectionary/layout/theme/...), // set from i18n.Get(cfg.UILanguage) -- index.html references its // fields (e.g. {{.L.Lectionary}}) instead of hardcoded Polish text. @@ -232,6 +236,13 @@ type versionOpt struct { Checked bool } +// calOpt is one <option> in the pobierz panel's month or year picker. +type calOpt struct { + Val int + Label string + Sel bool +} + type themeOpt struct { Name string Selected bool @@ -276,6 +287,23 @@ func indexHandler(cfg config.Config) http.HandlerFunc { themeOpts = append(themeOpts, themeOpt{Name: name, Selected: name == theme}) } + // Month/year pickers for the "pobierz" panel's month-calendar download. + // Selected from the shown date; the year list is a small window around + // it so the shown year is always present and pre-selected. + labels := i18n.Get(cfg.UILanguage) + selYear, selMonth := 0, 0 + if t, err := time.Parse("2006-01-02", date); err == nil { + selYear, selMonth = t.Year(), int(t.Month()) + } + monthOpts := make([]calOpt, 0, 12) + for i, name := range labels.Months { + monthOpts = append(monthOpts, calOpt{Val: i + 1, Label: name, Sel: i+1 == selMonth}) + } + yearOpts := make([]calOpt, 0, 6) + for y := selYear - 2; y <= selYear+3; y++ { + yearOpts = append(yearOpts, calOpt{Val: y, Label: strconv.Itoa(y), Sel: y == selYear}) + } + data := indexData{ Date: date, PrevDate: shiftDate(date, -1), @@ -288,7 +316,9 @@ func indexHandler(cfg config.Config) http.HandlerFunc { Display: display, Mono: queryBool(r, "mono", cfg.WebMono), Reading: reading, - L: i18n.Get(cfg.UILanguage), + MonthOpts: monthOpts, + YearOpts: yearOpts, + L: labels, Lang: cfg.UILanguage, } |
