mongoose-manager
Advanced tools
Comparing version 0.1.14 to 0.1.15
@@ -1,3 +0,2 @@ | ||
var express = require('express'), | ||
routes = require('./routes'), | ||
var routes = require('./routes'), | ||
async = require('async'), | ||
@@ -7,3 +6,2 @@ utils = require('./utils'), | ||
pluralize = require('pluralize'), | ||
ejsLocals = require('ejs-locals'), | ||
_ = require('underscore'); | ||
@@ -18,5 +16,8 @@ | ||
function Admin(models, options){ | ||
if (!options.secret){ | ||
console.log("No cookie secret set. You should set options.secret for proper cookie encryption."); | ||
} | ||
this.models = _asObject(models); | ||
this.app = this._createApp(); | ||
this.options = _.extend(require('./defaults').defaults, options); | ||
this.app = this._createApp(this.options); | ||
this.extraMenus = []; | ||
@@ -78,3 +79,3 @@ routes.init(this); | ||
var fields = utils.getFields(this.getModel(modelName)); | ||
var fields = utils.getFields(this.getModel(modelName).schema); | ||
@@ -96,31 +97,4 @@ if (limit) { | ||
Admin.prototype._createApp = function() { | ||
var app = express(); | ||
Admin.prototype._createApp = require('./express'); | ||
// all environments | ||
app.engine('html', ejsLocals); | ||
app.set('view engine', 'html'); | ||
app.set('views', __dirname + '/../views'); | ||
app.use(express.favicon()); | ||
app.use(express.static(__dirname + '/../public', {'maxAge': 0})); | ||
app.use(express.logger('dev')); | ||
app.use(express.bodyParser()); | ||
app.use(express.methodOverride()); | ||
app.use(express.cookieParser('benki-admin-cookie-secret')); | ||
app.use(express.session()); | ||
app.use(require('connect-flash')()); | ||
app.use(require('../views/helpers').init(this)); | ||
app.use(app.router); | ||
_.extend(require('ejs').filters, require('../views/filters')); | ||
// development only | ||
if ('development' == app.get('env')) { | ||
app.use(express.errorHandler()); | ||
} | ||
return app; | ||
}; | ||
function _asObject(models){ | ||
@@ -127,0 +101,0 @@ var modelsByName = {}; |
@@ -63,3 +63,3 @@ var async = require('async'), | ||
res.redirect(utils.url(req, model.modelName, document.id)); | ||
res.redirect(utils.url(req, model.modelName, document._id)); | ||
}); | ||
@@ -66,0 +66,0 @@ } |
@@ -54,4 +54,4 @@ var _ = require('underscore'); | ||
exports.getFields = function(document){ | ||
var virtualFields = _.map(document.schema.virtuals, function(value){ | ||
exports.getFields = function(schema){ | ||
var virtualFields = _.map(schema.virtuals, function(value){ | ||
return value.path; | ||
@@ -62,3 +62,3 @@ }).filter(function(p){ | ||
var fields = _.map(document.schema.paths, function(value){ | ||
var fields = _.map(schema.paths, function(value){ | ||
return value.path; | ||
@@ -65,0 +65,0 @@ }).filter(exports.isNotTechnical); |
{ | ||
"name": "mongoose-manager", | ||
"version": "0.1.14", | ||
"version": "0.1.15", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "example": "supervisor --force-watch -i public,views example/app.js" |
@@ -28,4 +28,4 @@ $(function(){ | ||
templateSelector = $ol.data('template'), | ||
i = $ol.find('.form-group').length, | ||
html = $(templateSelector).text().replace('{{i}}', i); | ||
i = $ol.find('>.form-group').length, | ||
html = $(templateSelector).text().replace(/{{i}}/gi, i); | ||
$ol.append(html); | ||
@@ -32,0 +32,0 @@ updateCount($ol); |
@@ -20,3 +20,6 @@ # mongoose-manager | ||
]; | ||
var admin = new Admin(models); | ||
var options = { | ||
secret: 'a secret string to use for cookie encryption' // replace this by a specific string for your app | ||
}; | ||
var admin = new Admin(models, options); | ||
@@ -23,0 +26,0 @@ // an express app is now available in admin.app |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
57353
42
1048
39
4