summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--model_fs.js63
1 files changed, 35 insertions, 28 deletions
diff --git a/model_fs.js b/model_fs.js
index 8a4aa13..6c64211 100644
--- a/model_fs.js
+++ b/model_fs.js
@@ -64,6 +64,7 @@ exports.rebuildFiles = function() {
next();
}).on("end", function() {
for(var slideset in newSlides) {
+ /* collects descriptions and adds them to the slideset */
var collectDescs = function(slideset) {
fs.readFile(path.join(__dirname, configuration.dir, slideset, configuration.description), function(err, data) {
if(err) { throw err; }
@@ -80,52 +81,56 @@ exports.rebuildFiles = function() {
}
}
}
- exports.addSlides(slideset, newSlides[slideset], function(err) { if(err) { throw err; }});
- fs.readFile(path.join(__dirname, configuration.dir, 'default', configuration.events), function(err, data) {
- var events = JSON.parse(data.toString());
- if(events['type'] == 'text') {
- files[slideset]['events'] = events['events'];
- } else if(events['type'] == 'ical') {
- var compEv = [];
- ical.fromURL(events['url'], {}, function(err, data) {
- 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
- });
- }
+ setSlides(slideset, newSlides[slideset], function(err) { if(err) { throw err; }});
+ });
+ }
+ /* 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) {
+ if(err) { throw err; }
+ var events = JSON.parse(data.toString());
+ if(events['type'] == 'text') {
+ files[slideset]['events'] = events['events'];
+ } else if(events['type'] == 'ical') {
+ var compEv = [];
+ ical.fromURL(events['url'], {}, function(err, data) {
+ 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
+ });
}
}
- });
- }
- });
+ }
+ });
+ }
});
}
collectDescs(slideset);
+ collectEvents(slideset);
}
});
};
-exports.setEvents = function(slideset, events, cb) {
+var setEvents = function(slideset, events, cb) {
- var found = 0;
for (var searchset in files) {
if(!files.hasOwnProperty(searchset)) { continue; }
if(files[searchset].name == slideset) {
files[searchset]['events'] = events;
- found = 1;
+ cb(null);
+ return;
}
}
- if(found) { cb('Couldn\'t find slideset'); }
- else { cb(null); }
+ cb('Couldn\'t find slideset');
};
-exports.addSlides = function(slideName, newSlides, cb) {
+var setSlides = function(slideName, newSlides, cb) {
files[slideName] = newSlides;
cb(null);
};
@@ -136,8 +141,10 @@ exports.getSlides = function(slideset, cb) {
if(!files.hasOwnProperty(searchset)) { continue; }
if(files[searchset].name == slideset) {
cb(null, files[searchset]);
+ return;
}
}
+ cb('Couldn\'t find slideset');
};
exports.getAllSlides = function(cb) {