aboutsummaryrefslogtreecommitdiff
path: root/module
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-03-02 00:53:52 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2020-03-02 00:53:52 +0100
commite7662fef8cecbaba59b85d45db9c13ae2236ec78 (patch)
tree45bfe7322e37e2da9b49e9fb72e47c15e603f374 /module
parentHTML broke stuff out into functions. (diff)
downloadcalp-e7662fef8cecbaba59b85d45db9c13ae2236ec78.tar.gz
calp-e7662fef8cecbaba59b85d45db9c13ae2236ec78.tar.xz
Move actual calendar render into own callback function.
Diffstat (limited to 'module')
-rw-r--r--module/entry-points/html.scm2
-rw-r--r--module/output/html.scm19
2 files changed, 14 insertions, 7 deletions
diff --git a/module/entry-points/html.scm b/module/entry-points/html.scm
index 2486fc52..c08dd72d 100644
--- a/module/entry-points/html.scm
+++ b/module/entry-points/html.scm
@@ -34,4 +34,4 @@
(if (option-ref opts 'chunked #f)
(html-chunked-main count calendars events start)
- (html-generate calendars events start end)))
+ (html-generate calendars events start end render-calendar)))
diff --git a/module/output/html.scm b/module/output/html.scm
index 714390ff..2b59b820 100644
--- a/module/output/html.scm
+++ b/module/output/html.scm
@@ -303,12 +303,22 @@
(define repo-url (make-parameter "https://git.hornquist.se"))
+
+(define-public (render-calendar event-groups)
+ `(div (@ (class "calendar"))
+ ,(time-marker-div)
+ (div (@ (class "days"))
+ ,@(stream->list (stream-map lay-out-day event-groups)))))
+
+
;;; NOTE
;;; The side bar filters all earlier events for each day to not create repeats,
;;; and the html-generate procedure also filters, but instead to find earlier eventns.
;;; All this filtering is probably slow, and should be looked into.
-(define-public (html-generate calendars events start-date end-date)
+
+
+(define-public (html-generate calendars events start-date end-date render-calendar)
;; TODO maybe don't do this again for every month
(define evs (get-groups-between (group-stream events)
start-date end-date))
@@ -350,10 +360,7 @@
(div (@ (class "root"))
(main
;; Actuall calendar
- (div (@ (class "calendar"))
- ,(time-marker-div)
- (div (@ (class "days"))
- ,@(stream->list (stream-map lay-out-day evs))))
+ ,(render-calendar evs)
;; Page footer
(footer (span "Page generated " ,(date->string (current-date)))
@@ -401,7 +408,7 @@
(let ((fname (format #f "./html/~a.html" (date->string (car pair) "~1"))))
(format (current-error-port) "Writing to [~a]~%" fname)
(with-output-to-file fname
- (lambda () (apply html-generate calendars events pair)))))
+ (lambda () (html-generate calendars events (car pair) (cadr pair) render-calendar)))))
(let ((ms (month-stream start-date)))
(stream-take
count (stream-zip