From 8af5d4a53c083ded3b3648cd9cb24f35e54a4ee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Sun, 16 Feb 2020 17:21:29 +0100 Subject: Add count parameter to chunked html. --- module/entry-points/html.scm | 5 ++++- module/output/html.scm | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) (limited to 'module') diff --git a/module/entry-points/html.scm b/module/entry-points/html.scm index 16306031..a5cd7303 100644 --- a/module/entry-points/html.scm +++ b/module/entry-points/html.scm @@ -15,6 +15,7 @@ '((from (value #t) (single-char #\F)) (to (value #t) (single-char #\T)) (file (value #t) (single-char #\f)) + (count (value #t)) (chunked))) (define (main args) @@ -24,6 +25,8 @@ (define end (cond [(option-ref opts 'to #f) => parse-freeform-date] [else (date+ start (date month: 1)) ])) + (define count (and=> (option-ref opts 'count "12") string->number)) + (define-values (calendars events) (load-calendars calendar-files: (cond [(option-ref opts 'file #f) => list] @@ -32,5 +35,5 @@ ((@ (srfi srfi-41) stream->list) events) (if (option-ref opts 'chunked #f) - (html-chunked-main calendars events start) + (html-chunked-main count calendars events start) (html-generate calendars events start end))) diff --git a/module/output/html.scm b/module/output/html.scm index b016d977..ba09c0ed 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -354,7 +354,7 @@ ,@(stream->list (stream-map fmt-day evs))))))))) -(define-public (html-chunked-main calendars events start-date) +(define-public (html-chunked-main count calendars events start-date) ;; NOTE Something here isn't thread safe. ;; TODO make it thread safe (stream-for-each @@ -366,7 +366,7 @@ (lambda () (apply html-generate calendars events pair))))) (let ((ms (month-stream start-date))) (stream-take - 12 (stream-zip + count (stream-zip ms (stream-map (lambda (d) (date- d (date day: 1))) ; last in month (stream-cdr ms)))) ))) -- cgit v1.2.3