aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-07-08 02:21:28 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-07-08 02:21:28 +0200
commitc6e2bf633d435e52813f03da0691a99a91890c7a (patch)
treebd5d141e1b60ddd9f62c21ce5d85ce46f9fe87e2
parentAdd HTML button for removing elements. (diff)
downloadcalp-c6e2bf633d435e52813f03da0691a99a91890c7a.tar.gz
calp-c6e2bf633d435e52813f03da0691a99a91890c7a.tar.xz
Move save-event to own module.
This hopefully resolves theh problems with (output ical) having bootstraping problems.
-rw-r--r--module/output/vdir.scm39
-rw-r--r--module/vcomponent.scm30
2 files changed, 39 insertions, 30 deletions
diff --git a/module/output/vdir.scm b/module/output/vdir.scm
new file mode 100644
index 00000000..5c70f28e
--- /dev/null
+++ b/module/output/vdir.scm
@@ -0,0 +1,39 @@
+;;; Commentary:
+;;; Module for writing components to the vdir storage format.
+;;; Currently also has some cases for "big" icalendar files,
+;;; but those are currently unsupported.
+;;; Code:
+
+(define-module (output vdir)
+ :use-module (util)
+ :use-modules (output ical)
+ :use-modules (vcomponent)
+ )
+
+(define / file-name-separator-string)
+
+(define-public (save-event event)
+ (define calendar (parent event))
+ (case (prop calendar 'X-HNH-SOURCETYPE)
+ [(file)
+ (error "Importing into direct calendar files not supported")]
+
+ [(vdir)
+ (let* ((uid (or (prop event 'UID) (uuidgen)))
+ ;; copy to enusre writable string
+ (tmpfile (string-copy (string-append (prop calendar 'X-HNH-DIRECTORY)
+ / ".calp-" uid "XXXXXX")))
+ (port (mkstemp! tmpfile)))
+ (set! (prop event 'UID) uid)
+ (with-output-to-port port
+ (lambda () (print-components-with-fake-parent (list event))))
+ ;; does close flush?
+ (force-output port)
+ (close-port port)
+ (rename-file tmpfile (string-append (prop calendar 'X-HNH-DIRECTORY)
+ / uid ".ics"))
+ uid)]
+
+ [else
+ (error "Source of calendar unknown, aborting.")
+ ]))
diff --git a/module/vcomponent.scm b/module/vcomponent.scm
index 5987c542..9b5f944c 100644
--- a/module/vcomponent.scm
+++ b/module/vcomponent.scm
@@ -63,9 +63,6 @@
-;;; TODO vcomponent should NOT depend on output
-(use-modules (output ical))
-
;;; TODO both add- and remove-event sometimes crash with
;;;;; Warning: Unwind-only `stack-overflow' exception; skipping pre-unwind handler.
;;; I belive this is due to how getf and setf work.
@@ -128,30 +125,3 @@
#f))
-(define / file-name-separator-string)
-
-(define-public (save-event event)
- (define calendar (parent event))
- (case (prop calendar 'X-HNH-SOURCETYPE)
- [(file)
- (error "Importing into direct calendar files not supported")]
-
- [(vdir)
- (let* ((uid (or (prop event 'UID) (uuidgen)))
- ;; copy to enusre writable string
- (tmpfile (string-copy (string-append (prop calendar 'X-HNH-DIRECTORY)
- / ".calp-" uid "XXXXXX")))
- (port (mkstemp! tmpfile)))
- (set! (prop event 'UID) uid)
- (with-output-to-port port
- (lambda () (print-components-with-fake-parent (list event))))
- ;; does close flush?
- (force-output port)
- (close-port port)
- (rename-file tmpfile (string-append (prop calendar 'X-HNH-DIRECTORY)
- / uid ".ics"))
- uid)]
-
- [else
- (error "Source of calendar unknown, aborting.")
- ]))