Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed bugs and trying to get those initializers working.

  • Loading branch information...
commit c38906bc38ee81c36bc8c93262c7354707b78a42 1 parent b31f97f
@tbergeron authored
View
2  core.js
@@ -1,4 +1,4 @@
-var moduleLoader = require("ncore/modules/moduleLoader");
+var moduleLoader = require("ncore/modules/moduleLoader");
// todo: put this somewhere else
process.env['MONGODB_HOST'] = 'linux.brainpad.org';
View
2  modules/app/controllers/home.js
@@ -1,5 +1,5 @@
module.exports = {
- initialize: function(req, res) {
+ initialize: function(req, res) {
console.log('Testing initializers');
},
View
29 modules/app/routes.js
@@ -1,4 +1,4 @@
-var getAction = require('../libs/helpers').getAction;
+var bindAll = require("pd").bindAll;
module.exports = {
registerRoutes: function(app) {
@@ -8,18 +8,18 @@ module.exports = {
project = this.controllers.project;
// home
- app.get('/', home.index);
+ app.get('/', handle(home.index, this));
// users
- app.post('/users/login', user.login);
- app.get('/users/logout', user.logout);
+ app.post('/users/login', handle(user.login, this));
+ app.get('/users/logout', handle(user.logout, this));
// projects
- app.get('/projects', project.list);
- app.get('/projects/new', project.new);
- app.get('/projects/edit/:project_code', project.edit);
- app.post('/projects/edit', project.edit);
- //app.get('/projects/delete/:project_code', projectController.delete);
+ app.get('/projects', handle(project.list, this));
+ app.get('/projects/new', handle(project.new, this));
+ app.get('/projects/edit/:project_code', handle(project.edit, this));
+ app.post('/projects/edit', handle(project.edit, this));
+ app.get('/projects/delete/:project_code', handle(project.delete, this));
// projects' milestones
//app.get('/projects/:project_code/milestones/new', this.controllers.milestone.new);
@@ -27,4 +27,13 @@ module.exports = {
//app.post('/projects/:project_code/milestones/edit', this.controllers.milestone.edit);
//app.get('/projects/:project_code/milestones/delete/:milestone_code', this.controllers.milestone.delete);
}
-};
+};
+
+function handle(action, self) {
+ return function(req, res) {
+ bindAll({}, self, action, {
+ req: req,
+ res: res
+ }).initialize();
+ };
+}
View
3  modules/dependency.json
@@ -5,8 +5,7 @@
"./libs/app.js": {
"configure": "./libs/configure.js",
"routes": "./app/routes.js",
- "partials": "./libs/partials.js",
- "controllers": ["./app/controllers"]
+ "partials": "./libs/partials.js"
},
"./app/routes.js": {
"controllers": ["./app/controllers/"]
View
8 modules/libs/app.js
@@ -14,14 +14,6 @@ module.exports = {
helpers.registerHandlebarsHelpers(hbs);
- Object.keys(this.controllers).forEach(function (name) {
- var controller = this.controllers[name];
-
- if (typeof controller.initialize === 'function') {
- controller.initialize();
- }
- }, this);
-
server.on('request', app);
}
};
View
9 package.json
@@ -10,21 +10,12 @@
},
"dependencies": {
"ncore": "1.3.10",
-<<<<<<< HEAD
"handlebars": "1.0.5beta",
"mongojs": "0.3.2",
"pd": "0.6.3",
"mongo-col": "0.1.7",
"path": "0.4.9",
"consolidate": "0.2.0"
-=======
- "handlebars": "*",
- "mongojs": "*",
- "pd": "*",
- "mongo-col": "*",
- "path": "*",
- "consolidate": "*"
->>>>>>> 565c6a6443e5b65b30c905b6d55248a270876cc5
},
"devDependencies": {
"mocha": "1.0.1",
Please sign in to comment.
Something went wrong with that request. Please try again.