diff --git a/js/apps/system/aardvark/foxxTemplates.js b/js/apps/system/aardvark/foxxTemplates.js index 7fb9b39228..9e1d0ea312 100644 --- a/js/apps/system/aardvark/foxxTemplates.js +++ b/js/apps/system/aardvark/foxxTemplates.js @@ -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(); }); diff --git a/js/apps/system/aardvark/lib/foxxTemplateEngine.js b/js/apps/system/aardvark/lib/foxxTemplateEngine.js index f1b8030a9b..689a9cab2f 100644 --- a/js/apps/system/aardvark/lib/foxxTemplateEngine.js +++ b/js/apps/system/aardvark/lib/foxxTemplateEngine.js @@ -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) { diff --git a/js/apps/system/aardvark/templates/manifest.json.tmpl b/js/apps/system/aardvark/templates/manifest.json.tmpl index 42640230cc..4b436bd9d7 100644 --- a/js/apps/system/aardvark/templates/manifest.json.tmpl +++ b/js/apps/system/aardvark/templates/manifest.json.tmpl @@ -1,3 +1,17 @@ { - "author": "<%=author %>" + "name": "<%= name %>", + "description": "<%= description %>", + "author": "<%= author %>", + "version": "0.0.1", + "license": "<%= license %>", + "isSystem": false, + + "contributors": [ + ], + + "controllers": { + }, + + "setup": "", + "teardown": "" }