Corrected mistake : swapped controllers.js and posts.js

This commit is contained in:
Thomas FORGIONE 2015-05-19 18:09:46 +02:00
parent 2e2617e5de
commit 4e95713556
2 changed files with 11 additions and 11 deletions

View File

@ -7,27 +7,26 @@ var fs = require('fs');
module.exports = function(parent, options){ module.exports = function(parent, options){
var verbose = options.verbose; var verbose = options.verbose;
fs.readdirSync(__dirname + '/../controllers').forEach(function(name){
fs.readdirSync(__dirname + '/../posts').forEach(function(name){
// index.js in controller, with function as pages (views.py for django) // index.js in controller, with function as pages (views.py for django)
var obj = require('./../posts/' + name + '/index'); var obj = require('./../controllers/' + name + '/index');
// urls.js, just like django urls.py // urls.js, just like django urls.py
var urls = require('./../posts/' + name + '/urls'); var urls = require('./../controllers/' + name + '/urls');
var name = obj.name || name; var name = obj.name || name;
var app = express(); var app = express();
// allow specifying the view engine // allow specifying the view engine
if (obj.engine) app.set('view engine', obj.engine); if (obj.engine) app.set('view engine', obj.engine);
app.set('views', __dirname + '/../posts/' + name + '/views'); app.set('views', __dirname + '/../controllers/' + name + '/views');
// generate routes based // generate routes based
// on the exported methods // on the exported methods
verbose && console.log('\t' + name + ':'); verbose && console.log('\t' + name + ':');
for (var key in urls) { for (var key in urls) {
app.post(key, obj[urls[key]]); app.get(key, obj[urls[key]]);
console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]);
} }
console.log(); console.log();

View File

@ -7,26 +7,27 @@ var fs = require('fs');
module.exports = function(parent, options){ module.exports = function(parent, options){
var verbose = options.verbose; var verbose = options.verbose;
fs.readdirSync(__dirname + '/../controllers').forEach(function(name){
fs.readdirSync(__dirname + '/../posts').forEach(function(name){
// index.js in controller, with function as pages (views.py for django) // index.js in controller, with function as pages (views.py for django)
var obj = require('./../controllers/' + name + '/index'); var obj = require('./../posts/' + name + '/index');
// urls.js, just like django urls.py // urls.js, just like django urls.py
var urls = require('./../controllers/' + name + '/urls'); var urls = require('./../posts/' + name + '/urls');
var name = obj.name || name; var name = obj.name || name;
var app = express(); var app = express();
// allow specifying the view engine // allow specifying the view engine
if (obj.engine) app.set('view engine', obj.engine); if (obj.engine) app.set('view engine', obj.engine);
app.set('views', __dirname + '/../controllers/' + name + '/views'); app.set('views', __dirname + '/../posts/' + name + '/views');
// generate routes based // generate routes based
// on the exported methods // on the exported methods
verbose && console.log('\t' + name + ':'); verbose && console.log('\t' + name + ':');
for (var key in urls) { for (var key in urls) {
app.get(key, obj[urls[key]]); app.post(key, obj[urls[key]]);
console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]); console.log('\t\t' + key + ' -> ' + name + '.' + urls[key]);
} }
console.log(); console.log();