diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2026-07-20 11:10:21 +0200 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2026-07-20 11:10:21 +0200 |
| commit | 9f52bec00561d7d481b79a38fa02586626b4b5cd (patch) | |
| tree | 405566b391ce43743aa997a213d06371658fdcb7 /src/Main.hs | |
| parent | 72379334b9efa362e7083963b75bb6e69530298d (diff) | |
Prev/next buttons on calendar-day
Thanks jreicher for suggesting!
Diffstat (limited to 'src/Main.hs')
| -rw-r--r-- | src/Main.hs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Main.hs b/src/Main.hs index 78098af..a06aef8 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -16,7 +16,7 @@ import Data.Map.Strict qualified as Map import Data.Text (Text) import Data.Text qualified as T import Data.Text.Encoding qualified as TE -import Data.Time (Day, toGregorian, fromGregorianValid) +import Data.Time (Day, toGregorian, fromGregorianValid, addDays) import System.Directory (listDirectory) import System.Environment import System.Exit (die) @@ -145,7 +145,7 @@ pageCalendarDay conf index req alias datestr = Just "all" -> (CKAll, Just "ef=all; Path=/") Just "compr" -> (CKCompressed, Just "ef=compr; Path=/") _ -> (CKAll, Nothing) - events <- indexGetEventsDay index chan kind day + ((firstday, lastday), events) <- indexGetEventsDay index chan kind day mpagehighlight <- if | Just (TE.decodeASCII' -> Just eventID) <- query req "eid" -> do mevidx <- findEventIDLinear index chan kind eventID @@ -166,6 +166,12 @@ pageCalendarDay conf index req alias datestr = , efAll = kind == CKAll , efCompr = kind == CKCompressed , date = T.pack (ymdToString (dayToYMD day)) + , picker = CalendarPickerData + { prevpage = if firstday < day then Just (T.pack (ymdToString (dayToYMD (addDays (-1) day)))) + else Nothing + , nextpage = if day < lastday then Just (T.pack (ymdToString (dayToYMD (addDays 1 day)))) + else Nothing + } , events = [EventData { classlist = if mpagehighlight == Just dayidx |
