From a7536c3af8318014a60d8c07562200d7488e9c6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 17 Oct 2022 19:02:23 +0200 Subject: Add /everything.ics endpoint. Endpoint returns all events in interval. Used to sync to other calendars. --- module/calp/server/routes.scm | 12 ++++++++++++ module/vcomponent/formats/ical/output.scm | 4 +++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm index 925b22b5..b4901900 100644 --- a/module/calp/server/routes.scm +++ b/module/calp/server/routes.scm @@ -142,6 +142,17 @@ `((content-type image/svg+xml)) (call-with-input-file "static/calendar.svg" read-string))) + (GET "/everything.ics" (start end) + (let ((start (or start (date- (current-date) (date day: 14)))) + (end (or end (date+ (current-date) (date year: 1))))) + (let ((events (append + (fixed-events-in-range global-event-object start end) + (get-repeating-events global-event-object)))) + (format (current-error-port) "Collected ~a events~%" (length events)) + (return '((content-type text/calendar)) + (with-output-to-string + (lambda () (print-components-with-fake-parent events))))))) + ;; TODO any exception in this causes the whole page to fail ;; It would be much better if most of the page could still make it. (GET "/week/:start-date.html" (start-date html) @@ -343,6 +354,7 @@ (return (build-response code: 404) (format #f (G_ "No component with UID=~a found.") uid)))) + (GET "/search/text" (q) (return (build-response code: 302 diff --git a/module/vcomponent/formats/ical/output.scm b/module/vcomponent/formats/ical/output.scm index e4fad90a..4d37dff6 100644 --- a/module/vcomponent/formats/ical/output.scm +++ b/module/vcomponent/formats/ical/output.scm @@ -168,7 +168,9 @@ ;; If we have alternatives, splice them in here. (cond [(prop component '-X-HNH-ALTERNATIVES) - => (lambda (alts) (hash-map->list (lambda (_ comp) (component->ical-string comp)) + => (lambda (alts) (hash-map->list (lambda (_ comp) + (unless (eq? component comp) + (component->ical-string comp))) alts))])) -- cgit v1.2.3