aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-05-04 20:09:44 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-05-04 20:09:44 +0200
commit29fd746dd3c16509c15c297bad108e7877489a47 (patch)
tree00a49469d9c82a17c67c7eebcc8702f13c8539cb
parentReplace direct output to current-error-port with warnings. (diff)
downloadcalp-29fd746dd3c16509c15c297bad108e7877489a47.tar.gz
calp-29fd746dd3c16509c15c297bad108e7877489a47.tar.xz
Add ability to download ics in entirety.
-rw-r--r--TODO6
-rw-r--r--module/entry-points/ical.scm2
-rw-r--r--module/entry-points/server.scm8
-rw-r--r--module/output/ical.scm14
4 files changed, 18 insertions, 12 deletions
diff --git a/TODO b/TODO
index 94c853eb..c6651cd6 100644
--- a/TODO
+++ b/TODO
@@ -32,12 +32,6 @@ Handle systems with bad `cal' programs
HTML
====
-Exportera ICS i helhet knapp
-----------------------------
-
-Exprotera ICS rullande?
------------------------
-
Mycket små events
-----------------
diff --git a/module/entry-points/ical.scm b/module/entry-points/ical.scm
index 7e780d89..32db38e0 100644
--- a/module/entry-points/ical.scm
+++ b/module/entry-points/ical.scm
@@ -30,4 +30,4 @@
(print-arg-help opt-spec)
(throw 'return))
- (ical-main start end))
+ (print-events-in-interval start end))
diff --git a/module/entry-points/server.scm b/module/entry-points/server.scm
index f1a5466d..919dc936 100644
--- a/module/entry-points/server.scm
+++ b/module/entry-points/server.scm
@@ -120,13 +120,15 @@
headers: `((location . ,location)))
""))
- ;; TODO export all events in interval
(GET "/calendar" (start end)
(return '((content-type text/calendar))
(with-output-to-string
(lambda ()
- (ical-main (parse-iso-date start)
- (parse-iso-date end))))))
+ (if (or start end)
+ (print-events-in-interval
+ (aif start (parse-iso-date it) (current-date))
+ (aif end (parse-iso-date it) (current-date)))
+ (print-all-events))))))
;; TODO this fails if there's a period in the uid.
(GET "/calendar/:uid{.*}.ics" (uid)
diff --git a/module/output/ical.scm b/module/output/ical.scm
index aa1d030b..e1da95ec 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 exceptions)
:use-module (util app)
:use-module (vcomponent)
:use-module (vcomponent datetime)
@@ -152,6 +153,7 @@
(add-child! cal event)
(awhen (prop (attr* event 'DTSTART) 'TZID)
+ ;; TODO this is broken
(add-child! cal (zoneinfo->vtimezone (getf 'zoneinfo) it)))
(unless (attr event 'UID)
@@ -209,8 +211,16 @@ CALSCALE:GREGORIAN\r
(print-footer))
-;; TODO add support for running without a range limiter, emiting all objects.
-(define-public (ical-main start end)
+(define-method (print-all-events)
+ (print-components-with-fake-parent
+ (append (getf 'fixed-events)
+ ;; 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.
+ (getf 'repeating-events))))
+
+(define-method (print-events-in-interval start end)
(print-components-with-fake-parent
(append (fixed-events-in-range start end)
;; TODO RECCURENCE-ID exceptions