1
0
Fork 0

Added an automatic dev app reloading.

This commit is contained in:
Michael Hackstein 2014-12-15 11:55:41 +01:00
parent 987dec185e
commit 85da13197d
4 changed files with 20 additions and 11 deletions

View File

@ -61,6 +61,7 @@ controller.post("/generate", function(req, res) {
if (isDevMode()) { if (isDevMode()) {
FoxxManager.devSetup(conf.get("name")); FoxxManager.devSetup(conf.get("name"));
internal.executeGlobalContextFunction("reloadRouting");
} else { } else {
// TODO Zip and ship it // TODO Zip and ship it
} }

View File

@ -634,10 +634,13 @@
author: $("#new-app-author").val(), author: $("#new-app-author").val(),
license: $("#new-app-license").val(), license: $("#new-app-license").val(),
description: $("#new-app-description").val() description: $("#new-app-description").val()
}; },
self = this;
console.log(info); console.log(info);
$.post("templates/generate", JSON.stringify(info), function(a) { $.post("templates/generate", JSON.stringify(info), function(a) {
alert("GENERATOOOO!", a); //TODO Error Handling
window.modalView.hide();
self.reload();
}); });
}, },

View File

@ -56,20 +56,24 @@
this.models = []; this.models = [];
_.each(collectionNames, function (collectionName) { _.each(collectionNames, function (collectionName) {
var modelName = i.singularize(collectionName), var modelBase = i.singularize(collectionName).substr(1),
collectionStart, collectionStart,
repositoryBase = collectionName.substr(1), repositoryBase = collectionName.substr(1),
repositoryName, repositoryName,
repositoryPath, repositoryPath,
repositoryInstance, repositoryInstance,
modelPath; modelPath,
modelName,
modelInstance;
collectionStart = collectionName.charAt(0); collectionStart = collectionName.charAt(0);
if (collectionStart.match("[a-zA-Z]") === null) { if (collectionStart.match("[a-zA-Z]") === null) {
throw "Collection Name has to start with a letter"; throw "Collection Name has to start with a letter";
} }
if (modelName === collectionName) { if (modelBase === repositoryBase) {
repositoryBase += "_repo"; repositoryBase += "_repo";
} }
modelName = collectionStart.toUpperCase() + modelBase;
modelInstance = collectionStart.toLowerCase() + modelBase;
repositoryName = collectionStart.toUpperCase() + repositoryBase; repositoryName = collectionStart.toUpperCase() + repositoryBase;
repositoryInstance = collectionStart.toLowerCase() + repositoryBase; repositoryInstance = collectionStart.toLowerCase() + repositoryBase;
repositoryPath = 'repositories/' + collectionName; repositoryPath = 'repositories/' + collectionName;
@ -82,7 +86,8 @@
repositoryInstance: repositoryName, repositoryInstance: repositoryName,
repository: repositoryInstance, repository: repositoryInstance,
repositoryPath: repositoryPath, repositoryPath: repositoryPath,
model: i.titleize(modelName), modelInstance: modelInstance,
model: modelName,
modelPath: modelPath, modelPath: modelPath,
basePath: collectionName, basePath: collectionName,
collectionName: collectionName collectionName: collectionName

View File

@ -30,9 +30,9 @@
* requestBody. * requestBody.
*/ */
controller.post('/<%= basePath %>', function (req, res) { controller.post('/<%= basePath %>', function (req, res) {
var todo = req.params('todo'); var <%= modelInstance %> = req.params('<%= modelInstance %>');
res.json(<%= repositoryInstance %>.save(todo).forClient()); res.json(<%= repositoryInstance %>.save(todo).forClient());
}).bodyParam('todo', 'The <%= model %> you want to create', <%= model %>); }).bodyParam('<%= modelInstance %>', 'The <%= model %> you want to create', <%= model %>);
/** Updates a <%= model %> /** Updates a <%= model %>
* *
@ -41,12 +41,12 @@
*/ */
controller.put('/<%= basePath %>/:id', function (req, res) { controller.put('/<%= basePath %>/:id', function (req, res) {
var id = req.params('id'), var id = req.params('id'),
todo = req.params('todo'); <%= modelInstance %> = req.params('<%= modelInstance %>');
res.json(<%= repositoryInstance %>.replaceById(id, todo)); res.json(<%= repositoryInstance %>.replaceById(id, <%= modelInstance %>));
}).pathParam('id', { }).pathParam('id', {
description: 'The id of the <%= model %>-Item', description: 'The id of the <%= model %>-Item',
type: 'string' type: 'string'
}).bodyParam('todo', 'The <%= model %> you want your old one to be replaced with', <%= model %>); }).bodyParam('<%= modelInstance %>', 'The <%= model %> you want your old one to be replaced with', <%= model %>);
/** Removes a <%= model %> /** Removes a <%= model %>
* *