From 623d5ec42150b761cb7b3b56c7b7b9eaaf5c1e23 Mon Sep 17 00:00:00 2001 From: Benjamin Kiessling Date: Mon, 23 Jan 2012 15:38:57 +0100 Subject: More unambiguous names in configuration --- config.js | 10 +++++----- frontend.js | 6 +++--- main.js | 2 +- model_fs.js | 15 +++++++-------- 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 +'
  • '; } if(slides['slides'][slide]['head'].length > 0) { - var head = sanitize(slides['slides'][slide]['head']).xss(); + var head = slides['slides'][slide]['head']; slideStr = slideStr+'
    '+head+'
    '; if(slides['slides'][slide]['text'].length > 0) { - var text = sanitize(slides['slides'][slide]['text']).xss(); + var text = slides['slides'][slide]['text']; slideStr = slideStr+'
    '+text+'
    '; } slideStr = slideStr + '
    '; 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()); -- cgit v1.2.1