Changed files to clean
This commit is contained in:
parent
ee3bf01ab0
commit
571d4b3167
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var express = require('express');
|
||||
var fs = require('fs');
|
||||
|
||||
module.exports = function(parent, options){
|
||||
var verbose = options.verbose;
|
||||
|
||||
fs.readdirSync(__dirname + '/../posts').forEach(function(name){
|
||||
|
||||
// index.js in controller, with function as pages (views.py for django)
|
||||
var obj = require('./../posts/' + name + '/index');
|
||||
|
||||
// urls.js, just like django urls.py
|
||||
var urls = require('./../posts/' + name + '/urls');
|
||||
var name = obj.name || name;
|
||||
var app = express();
|
||||
|
||||
// allow specifying the view engine
|
||||
if (obj.engine) app.set('view engine', obj.engine);
|
||||
app.set('views', __dirname + '/../posts/' + name + '/views');
|
||||
|
||||
// generate routes based
|
||||
// on the exported methods
|
||||
|
||||
verbose && console.log('\t' + name + ':');
|
||||
for (var key in urls) {
|
||||
app.post(key, obj[urls[key]]);
|
||||
console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]);
|
||||
}
|
||||
console.log();
|
||||
|
||||
// mount the app
|
||||
parent.use(app);
|
||||
});
|
||||
};
|
|
@ -34,32 +34,4 @@ module.exports = function(parent, options){
|
|||
// mount the app
|
||||
parent.use(app);
|
||||
});
|
||||
|
||||
fs.readdirSync(__dirname + '/../posts').forEach(function(name){
|
||||
|
||||
// index.js in controller, with function as pages (views.py for django)
|
||||
var obj = require('./../posts/' + name + '/index');
|
||||
|
||||
// urls.js, just like django urls.py
|
||||
var urls = require('./../posts/' + name + '/urls');
|
||||
var name = obj.name || name;
|
||||
var app = express();
|
||||
|
||||
// allow specifying the view engine
|
||||
if (obj.engine) app.set('view engine', obj.engine);
|
||||
app.set('views', __dirname + '/../posts/' + name + '/views');
|
||||
|
||||
// generate routes based
|
||||
// on the exported methods
|
||||
|
||||
verbose && console.log('\t' + name + ':');
|
||||
for (var key in urls) {
|
||||
app.post(key, obj[urls[key]]);
|
||||
console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]);
|
||||
}
|
||||
console.log();
|
||||
|
||||
// mount the app
|
||||
parent.use(app);
|
||||
});
|
||||
};
|
|
@ -35,13 +35,18 @@ app.use(function(req, res, next) {
|
|||
res.locals.alertCookie = false;
|
||||
} else {
|
||||
res.locals.alertCookie = true;
|
||||
res.cookie('alreadyCame', true);
|
||||
res.cookie('alreadyCame', true, {maxAge: 604800000}); // One week in ms
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
// Load controllers
|
||||
require('./lib/boot')(app, { verbose: !module.parent });
|
||||
console.log("Loading controllers :");
|
||||
require('./lib/controllers')(app, { verbose: !module.parent });
|
||||
|
||||
// Load post to log data from user study
|
||||
console.log("Loading posts :");
|
||||
require('./lib/posts')(app, { verbose: !module.parent });
|
||||
|
||||
app.use('/static', express.static('static'));
|
||||
|
||||
|
|
Loading…
Reference in New Issue