From c74486cbb2efda112dc2631aa3ed84824fc61c8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 30 Apr 2020 18:41:39 +0200 Subject: Update HTML to use app. --- module/entry-points/html.scm | 17 ++++------------- module/output/html.scm | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/module/entry-points/html.scm b/module/entry-points/html.scm index 70fbde42..d80de3b5 100644 --- a/module/entry-points/html.scm +++ b/module/entry-points/html.scm @@ -4,7 +4,7 @@ :use-module (util) :use-module (util time) :use-module (util config) - :use-module (vcomponent) + ;; :use-module (vcomponent) :use-module (datetime) :use-module (datetime util) :use-module (ice-9 getopt-long) @@ -30,26 +30,17 @@ (define style (string->symbol (option-ref opts 'style "wide"))) - (define-values (calendars events) - (cond [(option-ref opts 'file #f) => (compose load-calendars list)] - [else (load-calendars)])) - - - (report-time! "Calendars loaded") - (case style - [(unchunked) - (html-generate calendars events start end render-calendar)] [(wide) ; previously `chunked' - (html-chunked-main count calendars events start (date month: 1))] + (html-chunked-main count start (date month: 1))] [(week) ;; TODO The small calendar is always centered on months, it might ;; be a good idea to instead center it on the current week, meaning ;; that the active row is always in the center - (html-chunked-main count calendars events + (html-chunked-main count (start-of-week start (get-config 'week-start)) (date day: 7))] [(table) - (html-table-main count calendars events start)] + (html-table-main count start)] [else (error "Unknown html style: ~a" style)])) diff --git a/module/output/html.scm b/module/output/html.scm index 8a932fd0..740be7b9 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -7,6 +7,7 @@ #:use-module (vcomponent group) #:use-module (vcomponent datetime) #:use-module (util) + #:use-module (util app) #:use-module (util exceptions) #:use-module (util config) #:use-module (util tree) @@ -745,7 +746,11 @@ ,@(stream->list (stream-map fmt-day evs)))))))) -(define-public (html-chunked-main count calendars events start-date chunk-length) +(define-method (html-chunked-main count start-date chunk-length) + + (define calendars (getf app 'calendars)) + (define events (getf app 'event-set)) + ;; TODO This still doesn't account for PWD, file existing but is of ;; wrong type, html directory existing but static symlink missing, ;; static being a different file type, and probably something else @@ -778,7 +783,12 @@ (cdr ms)))))))) -(define-public (html-table-main count calendars events start-date) + +(define-method (html-table-main count start-date) + + (define calendars (getf app 'calendars)) + (define events (getf app 'event-set)) + ;; TODO same file creation as in html-chunked-main (stream-for-each (lambda (start-of-month) -- cgit v1.2.3