Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

formage

Package Overview
Dependencies
Maintainers
3
Versions
158
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

formage - npm Package Compare versions

Comparing version 1.0.2 to 1.5.0

.slugignore

104

example/app.js

@@ -0,90 +1,46 @@

'use strict';
Error.stackTraceLimit = Infinity;
var express = require('express'),
mongoose = require('mongoose'),
models = require('./models.js'),
forms = require('../forms.js');
http = require('http'),
path = require('path');
mongoose.connect('mongodb://localhost/forms_test');
require('../CompileTempletes.js');
var app = express();
app.use(express.bodyParser());
app.use(express.methodOverride());
app.set('views', require('path').join(__dirname, 'views'));
app.use(express.static(require('path').join(__dirname, '..', 'static')));
app.configure('all', function(){
app.set('port', process.env.PORT || 8080);
app.set('mongo', process.env.MONGO_URL || 'mongodb://localhost/formage-admin-example');
app.set("view options", { layout: false, pretty: true });
//var adm = new admin.Admin('/admin',app);
app.use(express.favicon());
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.cookieParser('magical secret admin'));
app.use(express.cookieSession({cookie: { maxAge: 1000 * 60 * 60 * 24 }}));
app.use(express.static(path.join(__dirname, 'public')));
app.use(app.router);
});
//adm.register_admin('books',new admin.MongooseAdminResource(models.Book,{list_fields:['id','name','author']}));
//adm.register_admin('authors',new admin.MongooseAdminResource(models.Author,{list_fields:['id','name']}));
app.get('/', function (req, res) {
res.redirect('/new');
app.configure('development', function() {
app.use(express.errorHandler());
});
app.all('/new', function (req, res) {
var form = new forms.MongooseForm(req, {
empty: function (err) {
res.render('form.ejs', {form: form});
},
success: function (err, result) {
res.send('saved');
},
error: function (err) {
res.render('form.ejs', {form: form});
}
}, models.Book);
require('mongoose').connect(app.get('mongo'));
//require('./admin')(app);
var formage = require('../index');
var admin = formage.init(app, express, require('./models'), {
title: 'Formage-Admin Example'
});
//app.post('/new',function(req,res)
//{
// var form = new forms.MongooseForm(req,{},models.Book);
// form.is_valid(function(err,valid)
// {
// if(valid)
// {
// form.save(function(err,ent)
// {
// console.log(ent);
// res.send('saved');
// });
// }
// else
// {
// form.render_ready(function(err)
// {
// res.render('form.ejs',{form:form});
// });
// }
// });
//});
admin.registerAdminUserModel();
app.post('/edit', function (req, res) {
models.Book.findOne({}, function (err, book) {
var form = new forms.MongooseForm(req, {instance: book}, models.Book);
form.is_valid(function (err, valid) {
if (valid) {
form.save(function (err, ent) {
console.log(ent);
res.send('saved');
});
}
else {
form.render_ready(function (err) {
res.render('form.ejs', {form: form});
});
}
});
});
app.get('/', function(req, res){
res.redirect('/admin');
});
app.get('/edit', function (req, res) {
models.Book.findOne({}, function (err, book) {
var form = new forms.MongooseForm(req, {instance: book, exclude: ['genre']}, models.Book);
form.render_ready(function (err) {
res.render('form.ejs', {form: form});
});
});
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
app.listen(80);
console.log('up');
exports.app = app;
'use strict';
if (!module.parent) {
console.log("Do not call formage directly. require()-ing is required.");
process.exit(1);
}
if (!module.parent) console.error('Please don\'t call me directly.I am just the main app\'s minion.') || process.process.exit(1);
var path = require('path');
var MongooseAdmin = require('./MongooseAdmin.js'),
path = require('path'),
routes = require('./routes'),
express = require.main.require('express'),
ckeditorPath = require('node-ckeditor');
module.exports.common = require('./common');
module.exports.types = require('./mongoose-types');
module.exports.forms = require('./forms');
module.exports.fields = require('./fields');
module.exports.widgets = require('./widgets');
module.exports.statics_path = path.join(__dirname, 'public');
module.mongoose_module = require.main.require('mongoose');
exports.version = require(path.join(__dirname, 'package.json')).version;
exports.forms = require('./forms');
exports.init = require('./init');
exports.loadApi = require('./AdminForm').loadApi;
exports.AdminForm = require('./AdminForm').AdminForm;
module.exports.setAmazonCredentials = module.exports.fields.setAmazonCredentials;
// Create the admin singleton object
exports.createAdmin = function(app, options) {
options = options || {};
var root = '/' + (options.root || 'admin');
module.exports.serve_static = function(app, express) {
app.use('/', express.static(module.exports.statics_path));
console.log('\x1b[36mformage-admin\x1b[0m at path', root);
var admin = MongooseAdmin.singleton = new MongooseAdmin(app, root);
routes(MongooseAdmin, app, root);
return admin;
};
module.exports.loadTypes = function (mongoose) {
module.mongoose_module = module.exports.mongoose_module = module.exports.mongoose_module || mongoose;
exports.types.loadTypes(mongoose);
// Serve static files
exports.serve_static = function (app, express, options) {
options = options || {};
options.root = options.root || 'admin';
if (module._is_serving_static) return;
module._is_serving_static = true;
app.use('/' + options.root, express.static(path.join(__dirname, '/public')));
app.use('/' + options.root + '/ckeditor', express.static(ckeditorPath));
};
module.exports.register_models = function (models) {
module.models = module.exports.models = models;
module.exports.forms.set_models(models);
var types_loaded;
exports.loadTypes = function () {
if (types_loaded) return;
types_loaded = true;
exports.forms.loadTypes();
};
module.exports.registerModel = function (name, model) {
module.exports.forms.registerModel(name, model);
exports.register_models = function (models) {
if (this._models_registered) return;
this._models_registered = true;
exports.forms.forms.set_models(models);
};
exports.set_amazon_credentials = module.exports.forms.set_amazon_credentials;
{
"name": "formage",
"description": "Forms creation from fields or from mongoose models",
"version": "1.0.2",
"description": "Admin GUI addon for mongoose and non mongoose projects on Express.js",
"version": "1.5.0",
"main": "index.js",
"author": {
"name": "Ishai Jaffe",
"email": "ishai@empeeric.com"
"name": "Etai Peretz",
"email": "etai@empeeric.com",
"url": "http://www.empeeric.com/"
},
"contributors": [{
"name": "Ishai Jaffe",
"email": "ishai@bablic.com"
},
{
"name": "Refael Ackermann",
"email": "refael@empeeric.com",
"url": "http://www.empeeric.com/"
},
{
"name": "Alon Valadji",
"email": "alon@empeeric.com",
"url": "http://www.empeeric.com/"
}
],
"dependencies": {
"sji": "",
"underscore": "",
"lodash": "",
"async": "",
"cloudinary": ""
"cloudinary": "",
"nodestrum": "",
"node-ckeditor": ""
},
"devDependencies": {
"jade": "",
"express": "",
"ejs": ""
"mongoose": ""
},
"main": "index",
"bundleDependencies": [
"sji",
"nodestrum"
],
"keywords": [
"formage",
"admin",
"forms",
"mongoose",
"django"
"mongoose-gui"
],
"repository": {
"type": "git",
"url": "git@github.com:etaypere/formage.git"
"url": "https://github.com/Empeeric/formage.git"
},
"bugs": {
"url": "https://github.com/Empeeric/formage/issues"
},
"directories": {
"example": "./example"
},
"engines": {
"node": ">= 0.8.0",
"npm": ">= 1.0.0"
"node": ">= 0.10.12",
"npm": ">= 1.2.28"
}
}

@@ -1,10 +0,63 @@

Formage
=======
![](http://i.imgur.com/9vVHCPY.png) Formage Admin
=============
Form mage, forked from [forms](https://github.com/caolan/forms),
used mainly by [formage-admin](https://github.com/Empeeric/formage-admin).
[Bootstraped](http://twitter.github.com/bootstrap/) admin forms for [Mongoose](http://mongoosejs.com/),
originally forked from [mongoose-admin](https://github.com/marccampbell/mongoose-admin).
<hr />
Usage
-----
`npm install formage-admin`
```javascript
var admin = require('formage-admin').init(app, express);
```
Also, look at `\example` directory.
Some Options
------------
```javascript
// model options
model.label = 'My Songs';
model.singular = 'Song';
model.static = {
js: [ '/js/songs.js' ],
css: ['/css/songs.css' ]
};
model.formage = {
filters: ['artist', 'year'],
// Additional actions on this model
actions: [
{
value: 'release',
label: 'Release',
func: function (user, ids, callback) {
console.log('You just released songs ' + ids);
callback();
}
}
],
// list of fields to be displayed by formage for this model
list: ['number', 'title', 'album', 'artist', 'year'],
// list of order fields
order_by: ['-year', 'album', 'number'],
// list of fields that must be populated (see http://mongoosejs.com/docs/api.html#document_Document-populate)
list_populate: ['album']
};
// one-document models
model.single = true;
// field options
field.label = 'Song Title';
```
Sponsors
========
<a id="stormlogo" href="http://www.jetbrains.com/webstorm/" alt="Smart IDE for web development with HTML Editor, CSS &amp; JavaScript support" title="Smart IDE for web development with HTML Editor, CSS &amp; JavaScript support">
![](http://i.imgur.com/ynQ6c.png)
</a>

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc