aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2021-01-12 21:05:13 +0100
committerHugo Hörnquist <hugo@lysator.liu.se>2021-01-12 21:05:13 +0100
commit0cefcb7ea6306d92faa0aee12a46761e92118b41 (patch)
tree4bc590dd46ea53b1a64a760aff43fbc706156e76
parentjcal_to_xcal now works. (diff)
downloadcalp-0cefcb7ea6306d92faa0aee12a46761e92118b41.tar.gz
calp-0cefcb7ea6306d92faa0aee12a46761e92118b41.tar.xz
Can create event with new interface.
-rw-r--r--module/calp/server/routes.scm5
-rw-r--r--static/server_connect.js43
2 files changed, 33 insertions, 15 deletions
diff --git a/module/calp/server/routes.scm b/module/calp/server/routes.scm
index 276513f5..16ab2662 100644
--- a/module/calp/server/routes.scm
+++ b/module/calp/server/routes.scm
@@ -185,6 +185,8 @@
;; (vcalendar
;; (vevent ...))))
;; @end example
+
+ ;; TODO
;; However, *PI* will probably be omited, and currently events
;; are sent without the vcalendar part. Earlier versions
;; Also omitted the icalendar part. And I'm not sure if the
@@ -197,7 +199,8 @@
(move-to-namespace
;; TODO Multiple event components
(car ((sxpath '(// IC:vevent))
- (xml->sxml data namespaces: '((IC . "urn:ietf:params:xml:ns:icalendar-2.0")))))
+ (xml->sxml data namespaces:
+ '((IC . "urn:ietf:params:xml:ns:icalendar-2.0")))))
#f))
(lambda (err port . args)
(return (build-response code: 400)
diff --git a/static/server_connect.js b/static/server_connect.js
index 6c4e4496..e86fc36e 100644
--- a/static/server_connect.js
+++ b/static/server_connect.js
@@ -32,11 +32,13 @@ async function create_event (event) {
data.append("cal", calendar);
// data.append("data", xml);
+ console.log(event);
+
+ let properties = [];
+
for (let prop of event.properties.ical_properties) {
let v = event.properties[prop];
if (v !== undefined) {
- [prop, {}, /*type*/, v];
- /* TODO , here */
let type = 'text';
let value;
@@ -49,7 +51,7 @@ async function create_event (event) {
} else {
type = 'date-time';
/* TODO TZ */
- value = v.format("~Y-~m~dT~H:~M:~S");
+ value = v.format("~Y-~m-~dT~H:~M:~S");
}
} else if (v === true || v === false) {
type = 'boolean';
@@ -58,33 +60,46 @@ async function create_event (event) {
/* TODO float or integer */
type = 'integer';
value = v;
+ } else if (v instanceof RRule) {
+ type = 'recur';
+ value = v.asJcal();
}
/* TODO period */
- /* TODO recur */
else {
/* text types */
+ value = v;
}
+ properties.push([prop, {}, type, value]);
}
}
let jcal =
['vcalendar',
- ['vevent',
- [
- ['summary', {}, 'text', 'Example summary'],
- ],
- []
- ]
+ [
+ /*
+ 'prodid' and 'version' are technically both required (RFC 5545,
+ 3.6 Calendar Components).
+ */
+ ],
+ [
+ /* vtimezone goes here */
+ ['vevent', properties, [/* alarms go here */]],]
];
+ console.log(jcal);
+ console.log(properties);
+
let doc = jcal_to_xcal(jcal);
console.log(doc);
+ let str = doc.childNodes[0].outerHTML;
+ console.log(str);
+ data.append("data", str);
- console.log(event.properties);
+ // console.log(event.properties);
- return;
+ // return;
let response = await fetch ( '/insert', {
method: 'POST',
@@ -108,12 +123,12 @@ async function create_event (event) {
*/
let parser = new DOMParser();
- let properties = parser
+ let return_properties = parser
.parseFromString(body, 'text/xml')
.children[0];
let child;
- while ((child = properties.firstChild)) {
+ while ((child = return_properties.firstChild)) {
let target = event.querySelector(
"vevent properties " + child.tagName);
if (target) {