1
0
Fork 0

First steps towards generating a Foxx app

This commit is contained in:
Lucas Dohmen 2014-12-13 22:40:46 +01:00 committed by Michael Hackstein
parent 8914c18561
commit 93f520b723
3 changed files with 53 additions and 12 deletions

View File

@ -32,8 +32,7 @@
var FoxxController = require("org/arangodb/foxx").Controller,
controller = new FoxxController(applicationContext),
internal = require("internal"),
templateEngine = new (require("lib/foxxTemplateEngine").Engine)(applicationContext.foxxFilename("templates")),
fs = require("fs"),
TemplateEngine = require("lib/foxxTemplateEngine").Engine,
isDevMode = function() {
return internal.developmentMode;
};
@ -44,16 +43,24 @@ controller.get("/devMode", function(req, res) {
controller.post("/generate", function(req, res) {
var path,
name = "hansilein";
templateEngine;
if (isDevMode()) {
path = module.devAppPath();
} else {
path = module.appPath();
}
var folder = fs.join(path, name);
fs.makeDirectory(folder);
var manifest = fs.join(folder, "manifest.json");
fs.write(manifest, templateEngine.buildManifest({
author: "Peterle"
}));
templateEngine = new TemplateEngine({
applicationContext: applicationContext,
path: path,
name: 'fancyApp',
collectionNames: ['people'],
authenticated: false,
author: 'Bob the Builder',
description: 'This app is pretty fancy',
license: 'Do Whatever You Want'
});
templateEngine.write();
});

View File

@ -4,8 +4,28 @@
var fs = require("fs");
var _ = require("underscore");
var Engine = function(path) {
this._path = path;
var Engine = function(opts) {
this.applicationContext = opts.applicationContext;
this.path = opts.path;
this.name = opts.name;
this.collectionNames = opts.collectionNames;
this.authenticated = opts.authenticated;
this.author = opts.author;
this.description = opts.description;
this.license = opts.license;
this._path = this.applicationContext.foxxFilename("templates");
this.folder = fs.join(this.path, this.name);
};
Engine.prototype.write = function() {
fs.makeDirectory(this.folder);
fs.write(fs.join(this.folder, "manifest.json"), this.buildManifest({
name: this.name,
description: this.description,
author: this.author,
license: this.license
}));
};
Engine.prototype.buildManifest = function(info) {

View File

@ -1,3 +1,17 @@
{
"author": "<%=author %>"
"name": "<%= name %>",
"description": "<%= description %>",
"author": "<%= author %>",
"version": "0.0.1",
"license": "<%= license %>",
"isSystem": false,
"contributors": [
],
"controllers": {
},
"setup": "",
"teardown": ""
}