From 015288aeb492d883d386ac154079a3c704c34a97 Mon Sep 17 00:00:00 2001 From: morozovsk Date: Thu, 14 Jun 2012 04:55:38 +0400 Subject: [PATCH] 0.0.1 --- index.js | 11 ++++++++++- package.json | 7 +++---- samples/sample-without-modules/index.js | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index bee63ff..880570a 100755 --- a/index.js +++ b/index.js @@ -3,6 +3,15 @@ module.exports.controllers = {} module.exports.models = {} module.exports.init = function(app) { + if (app.set('applicationDirectory') === undefined) app.set('applicationDirectory', '/app/'); + if (app.set('moduleDirectory') === undefined) app.set('moduleDirectory', '/modules/'); + if (app.set('controllerDirectory') === undefined) app.set('controllerDirectory', '/controllers/'); + if (app.set('modelDirectory') === undefined) app.set('modelDirectory', '/models/'); + if (app.set('viewDirectory') === undefined) app.set('viewDirectory', '/views/'); + if (app.set('defaultModule') === undefined) app.set('defaultModule', 'index'); + if (app.set('defaultController') === undefined) app.set('defaultController', 'index'); + if (app.set('defaultAction') === undefined) app.set('defaultAction', 'index'); + module.exports.app = app; var util = require('util'); var path = require('path'); @@ -126,7 +135,7 @@ module.exports.init = function(app) { } var _render = function () { - return response.render(request.params.controller + '/' + request.params.action, controller._locals()); + return response.render(path.join(request.params.controller, request.params.action), controller._locals()); } var _json = function () { diff --git a/package.json b/package.json index c5d305b..127cccd 100755 --- a/package.json +++ b/package.json @@ -1,14 +1,13 @@ { "name": "mvc", "description": "mvc for expess", - "version": "0.0.2", + "version": "0.0.3", "homepage": "https://github.com/morozovsk/mvc", "repository": "https://github.com/morozovsk/mvc", "author": "morozovsk (https://github.com/morozovsk)", - "keywords": ["mvc", "zf", "zend", "php", "express", "expressjs", "framework", "sinatra", "web", "rest", "restful", "router"], + "keywords": ["mvc", "express", "expressjs", "connect", "framework", "zf", "zend", "php"], "engines": { "node": "*" }, "dependencies": { - "express": "*", - "ejs": "*" + "express": "*" } } \ No newline at end of file diff --git a/samples/sample-without-modules/index.js b/samples/sample-without-modules/index.js index 39e2917..3287670 100644 --- a/samples/sample-without-modules/index.js +++ b/samples/sample-without-modules/index.js @@ -16,10 +16,10 @@ app.configure(function(){ app.set('moduleDirectory', '/modules/'); app.set('controllerDirectory', '/controllers/'); app.set('modelDirectory', '/models/'); + app.set('viewDirectory', '/views/'); app.set('defaultModule', 'index'); app.set('defaultController', 'index'); app.set('defaultAction', 'index'); - app.set('viewDirectory', '/views/'); app.use(express.bodyParser()); app.use(express.cookieParser('secret')); app.use(express.session({secret: 'secret'}));