summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Kiessling <mittagessen@l.unchti.me>2012-01-23 15:38:57 +0100
committerBenjamin Kiessling <mittagessen@l.unchti.me>2012-01-23 15:38:57 +0100
commit623d5ec42150b761cb7b3b56c7b7b9eaaf5c1e23 (patch)
treec0a7dbed8e777841d31e10e9ef861d51db01f036
parentd09390b08727af716fbe99c3639381ae432e5481 (diff)
More unambiguous names in configuration
-rw-r--r--config.js10
-rw-r--r--frontend.js6
-rw-r--r--main.js2
-rw-r--r--model_fs.js15
4 files changed, 16 insertions, 17 deletions
diff --git a/config.js b/config.js
index b98e4d2..af59e85 100644
--- a/config.js
+++ b/config.js
@@ -1,8 +1,8 @@
exports.modelBackend = 'fs';
exports.Config = {
- dir: 'slideshows' ,
- template: 'template.html',
- description: 'desc.js',
- events: 'events.js',
- defaultSlides: 'default'
+ rootDir: 'slideshows' ,
+ templateFile: 'template.html',
+ descriptionFile: 'desc.js',
+ eventFile: 'events.js',
+ ignoreDotFiles: 'false'
};
diff --git a/frontend.js b/frontend.js
index 30b5457..8c3d4d6 100644
--- a/frontend.js
+++ b/frontend.js
@@ -14,7 +14,7 @@ exports.start = function(config) {
slideset = req.params.id;
model.getSlides(slideset, function(err, slides) {
if(err) { throw err; }
- fs.readFile(path.join(__dirname, config.dir, slides['template']) , function(err,data) {
+ fs.readFile(path.join(__dirname, config.rootDir, slides['template']) , function(err,data) {
if(err) { res.end(body); }
var body = data.toString();
var slideStr = '';
@@ -25,10 +25,10 @@ exports.start = function(config) {
slideStr = slideStr +'<li><img src="/'+media+'">';
}
if(slides['slides'][slide]['head'].length > 0) {
- var head = sanitize(slides['slides'][slide]['head']).xss();
+ var head = slides['slides'][slide]['head'];
slideStr = slideStr+'<div class="slideDesc"><div class="slideHead">'+head+'</div>';
if(slides['slides'][slide]['text'].length > 0) {
- var text = sanitize(slides['slides'][slide]['text']).xss();
+ var text = slides['slides'][slide]['text'];
slideStr = slideStr+'<div class="slideText">'+text+'</div>';
}
slideStr = slideStr + '</div>';
diff --git a/main.js b/main.js
index 29f47c4..8ba061e 100644
--- a/main.js
+++ b/main.js
@@ -14,7 +14,7 @@ var app = express.createServer();
app.use(express.logger());
app.use(express.staticCache());
-app.use(express.static(path.join(__dirname, config.Config.dir)));
+app.use(express.static(path.join(__dirname, config.Config.rootDir)));
config.Config.app = app;
diff --git a/model_fs.js b/model_fs.js
index 1a36986..de2f56f 100644
--- a/model_fs.js
+++ b/model_fs.js
@@ -21,24 +21,23 @@ exports.start = function(config) {
exports.rebuildFiles = function() {
- walker = walk.walk(configuration.dir, { followLinks: false });
+ console.log('rebuilding...');
+ walker = walk.walk(configuration.rootDir, { followLinks: false });
var newSlides = {};
walker.on("directories", function (root, dirAr, next) {
var lastDir = path.join(__dirname, root).split('/');
if((lastDir.length - __dirname.split('/').length) < 2) {
dirAr.forEach(function(dir) {
- newSlides[dir.name] = { name: dir.name, template:
- path.join(configuration.defaultSlides,
- configuration.template) , slides: []};
+ newSlides[dir.name] = { name: dir.name, template: '', slides: []};
});
}
next();
}).on("file", function(root, fileStats, next) {
- if(fileStats.name == configuration.description || fileStats.name == configuration.events) {
+ if(fileStats.name == configuration.descriptionFile || fileStats.name == configuration.eventFile) {
next();
}
- else if(fileStats.name == configuration.template) {
+ else if(fileStats.name == configuration.templateFile) {
var lastDir = root.split('/');
newSlides[lastDir[lastDir.length - 1]]['template'] = path.join(lastDir[lastDir.length - 1], fileStats.name);
next();
@@ -65,7 +64,7 @@ exports.rebuildFiles = 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) {
+ fs.readFile(path.join(__dirname, configuration.rootDir, slideset, configuration.descriptionFile), function(err, data) {
if(err) { setSlides(slideset, newSlides[slideset], function(err) { if(err) { throw err}}); return; }
var descs = JSON.parse(data.toString());
for(var file in newSlides[slideset]['slides']) {
@@ -85,7 +84,7 @@ exports.rebuildFiles = function() {
}
/* collect events and adds them to the slideset */
var collectEvents = function(slideset) {
- fs.readFile(path.join(__dirname, configuration.dir, slideset, configuration.events), function(err, data) {
+ fs.readFile(path.join(__dirname, configuration.rootDir, slideset, configuration.eventFile), function(err, data) {
if(err) { return; }
try {
var events = JSON.parse(data.toString());