From 8b426edf1b6d4de0ec825da8a34b1df7b51212db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 30 Apr 2020 18:37:03 +0200 Subject: Update ical parts to use app context. --- module/output/ical.scm | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'module/output') diff --git a/module/output/ical.scm b/module/output/ical.scm index 822d929d..8388bfc1 100644 --- a/module/output/ical.scm +++ b/module/output/ical.scm @@ -2,6 +2,7 @@ :use-module (ice-9 format) :use-module (ice-9 match) :use-module (util) + :use-module (util app) :use-module (vcomponent) :use-module (vcomponent datetime) :use-module (srfi srfi-1) @@ -139,10 +140,6 @@ ;; TODO place these somewhere better (define *prodid* "-//hugo//Calparse 0.9//EN") -(define *zoneinfo* (apply read-zoneinfo - ;; TODO move this to config, and figure out - ;; how to best acquire/bundle zoneinfo. - (glob "~/down/tz/{africa,antartica,asia,australasia,europe,northamerica,southamerica,backward}"))) ;; TODO tzid prop on dtstart vs tz field in datetime object ;; how do we keep these two in sync? @@ -156,7 +153,7 @@ (add-child! cal event) (awhen (prop (attr* event 'DTSTART) 'TZID) - (add-child! cal (zoneinfo->vtimezone *zoneinfo* it))) + (add-child! cal (zoneinfo->vtimezone (getf (current-app) 'zoneinfo) it))) (unless (attr event 'UID) (set! (attr event 'UID) @@ -205,7 +202,7 @@ CALSCALE:GREGORIAN\r (let ((tz-names (get-tz-names events))) (for-each component->ical-string ;; TODO we realy should send the earliest event from each timezone here. - (map (lambda (name) (zoneinfo->vtimezone *zoneinfo* name (car events))) + (map (lambda (name) (zoneinfo->vtimezone (getf (current-app) 'zoneinfo) name (car events))) tz-names))) (for-each component->ical-string events) @@ -214,15 +211,11 @@ CALSCALE:GREGORIAN\r ;; TODO add support for running without a range limiter, emiting all objects. -;; list x list x list x time x time → -(define-public (ical-main calendars regular-events repeating-events start end) - +(define-public (ical-main start end) (print-components-with-fake-parent - (append (filter-sorted (lambda (ev) ((in-date-range? start end) - (as-date (attr ev 'DTSTART)))) - regular-events) + (append (fixed-events-in-range start end) ;; TODO RECCURENCE-ID exceptions ;; We just dump all repeating objects, since it's much cheaper to do ;; it this way than to actually figure out which are applicable for ;; the given date range. - repeating-events))) + (getf (current-app) 'repeating-events)))) -- cgit v1.2.3 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/output/html.scm | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'module/output') 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 From aa44c16ce953c090b2eb3ce580c60fa8934a7720 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 30 Apr 2020 19:17:35 +0200 Subject: Change call signature for [gs]etf. --- module/output/html.scm | 8 ++++---- module/output/ical.scm | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'module/output') diff --git a/module/output/html.scm b/module/output/html.scm index 740be7b9..702d229d 100644 --- a/module/output/html.scm +++ b/module/output/html.scm @@ -748,8 +748,8 @@ (define-method (html-chunked-main count start-date chunk-length) - (define calendars (getf app 'calendars)) - (define events (getf app 'event-set)) + (define calendars (getf 'calendars)) + (define events (getf 'event-set)) ;; TODO This still doesn't account for PWD, file existing but is of ;; wrong type, html directory existing but static symlink missing, @@ -786,8 +786,8 @@ (define-method (html-table-main count start-date) - (define calendars (getf app 'calendars)) - (define events (getf app 'event-set)) + (define calendars (getf 'calendars)) + (define events (getf 'event-set)) ;; TODO same file creation as in html-chunked-main (stream-for-each diff --git a/module/output/ical.scm b/module/output/ical.scm index 8388bfc1..098d4e90 100644 --- a/module/output/ical.scm +++ b/module/output/ical.scm @@ -153,7 +153,7 @@ (add-child! cal event) (awhen (prop (attr* event 'DTSTART) 'TZID) - (add-child! cal (zoneinfo->vtimezone (getf (current-app) 'zoneinfo) it))) + (add-child! cal (zoneinfo->vtimezone (getf 'zoneinfo) it))) (unless (attr event 'UID) (set! (attr event 'UID) @@ -202,7 +202,7 @@ CALSCALE:GREGORIAN\r (let ((tz-names (get-tz-names events))) (for-each component->ical-string ;; TODO we realy should send the earliest event from each timezone here. - (map (lambda (name) (zoneinfo->vtimezone (getf (current-app) 'zoneinfo) name (car events))) + (map (lambda (name) (zoneinfo->vtimezone (getf 'zoneinfo) name (car events))) tz-names))) (for-each component->ical-string events) @@ -218,4 +218,4 @@ CALSCALE:GREGORIAN\r ;; We just dump all repeating objects, since it's much cheaper to do ;; it this way than to actually figure out which are applicable for ;; the given date range. - (getf (current-app) 'repeating-events)))) + (getf 'repeating-events)))) -- cgit v1.2.3