aboutsummaryrefslogtreecommitdiff
path: root/module/output
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-05-01 13:08:25 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-05-01 13:08:25 +0200
commit29cb0b9eb8e544d0f2b07eb202d90bed4f20eeea (patch)
tree92c5f2a5271911930a15e58df862273b3a755e5d /module/output
parentServer server any subdir under static. (diff)
parentChange call signature for [gs]etf. (diff)
downloadcalp-29cb0b9eb8e544d0f2b07eb202d90bed4f20eeea.tar.gz
calp-29cb0b9eb8e544d0f2b07eb202d90bed4f20eeea.tar.xz
Merge branch 'app'.
The app objects both makes the whole program sort of behave like one class in some object oriented languages, with an implicitly (actually hiddenly explicitly) passed 'app' argument to all methods. Multiple concurrent apps should be supported, but is of now untested. The app is also configured to lazily bind all its fields, which means that almost all loading is now lazy!
Diffstat (limited to 'module/output')
-rw-r--r--module/output/html.scm14
-rw-r--r--module/output/ical.scm19
2 files changed, 18 insertions, 15 deletions
diff --git a/module/output/html.scm b/module/output/html.scm
index 8a932fd0..702d229d 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 '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,
;; 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 'calendars))
+ (define events (getf 'event-set))
+
;; TODO same file creation as in html-chunked-main
(stream-for-each
(lambda (start-of-month)
diff --git a/module/output/ical.scm b/module/output/ical.scm
index 822d929d..098d4e90 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 '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 '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 'repeating-events))))