summaryrefslogtreecommitdiff
path: root/model_fs.js
diff options
context:
space:
mode:
authorBenjamin Kiessling <mittagessen@l.unchti.me>2011-11-29 16:37:10 +0100
committerBenjamin Kiessling <mittagessen@l.unchti.me>2011-11-29 16:37:10 +0100
commitcc25e22f481c0c80528d3fbc9631d46a4aae8eb1 (patch)
tree9f701b46f72afdded831dab6c95deac8440fbac7 /model_fs.js
parent33679681d5fe8eabfc847c94cd8d8bb341859cc1 (diff)
Enable Ical event support
Diffstat (limited to 'model_fs.js')
-rw-r--r--model_fs.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/model_fs.js b/model_fs.js
index 6c64211..14cb4b5 100644
--- a/model_fs.js
+++ b/model_fs.js
@@ -17,7 +17,6 @@ exports.start = function(config) {
watcher.on('fileCreated', exports.rebuildFiles);
watcher.on('fileModified', exports.rebuildFiles);
exports.rebuildFiles();
-
};
exports.rebuildFiles = function() {
@@ -86,27 +85,32 @@ exports.rebuildFiles = function() {
}
/* collect events and adds them to the slideset */
var collectEvents = function(slideset) {
- fs.readFile(path.join(__dirname, configuration.dir, 'default', configuration.events), function(err, data) {
+ fs.readFile(path.join(__dirname, configuration.dir, slideset, configuration.events), function(err, data) {
if(err) { throw err; }
var events = JSON.parse(data.toString());
if(events['type'] == 'text') {
- files[slideset]['events'] = events['events'];
+ setEvents(slideset, events['events'], function(err) {
+ if(err) { throw err; }
+ });
} else if(events['type'] == 'ical') {
- var compEv = [];
ical.fromURL(events['url'], {}, function(err, data) {
+ if(err) { throw err; }
+ var compEv = [];
for (var k in data) {
if (data.hasOwnProperty(k)) {
var ev = data[k];
if(ev.start && ev.summary) {
- compEv.push({
- date:
- ev.start,
- text:
- ev.summary
- });
+ var curDate = new Date(ev.start);
+ if(typeof compEv[curDate.toDateString()] == "undefined") {
+ compEv[curDate.toDateString()] = [];
+ }
+ compEv[curDate.toDateString()].push({time: curDate.toTimeString(), text: ev.summary});
}
}
}
+ setEvents(slideset, compEv, function(err) {
+ if(err) { throw err; }
+ });
});
}
});