Permalink
Browse files

Merge branch 'master' into feature/socket.io-mvc

  • Loading branch information...
2 parents e2739b5 + 3037cfc commit 9762d1520469e8ba6ab463d570312189ab0c30e8 Techwraith committed Aug 11, 2012
Showing with 3,365 additions and 8,450 deletions.
  1. +2 −0 .gitignore
  2. +8 −9 Jakefile
  3. +6 −0 README.md
  4. +22 −34 bin/cli.js
  5. +1 −1 deps/color.js
  6. +12 −0 deps/templato/lib/engines/handlebars.js
  7. +18 −6 deps/templato/lib/engines/mustache.js
  8. +7 −0 deps/templato/lib/templato.js
  9. +2 −1 examples/todo_app_coffee/config/environment.coffee
  10. +0 −25 examples/todo_app_jade/app/controllers/application.js
  11. +0 −30 examples/todo_app_jade/app/controllers/main.js
  12. +0 −83 examples/todo_app_jade/app/controllers/todos.js
  13. +0 −22 examples/todo_app_jade/app/models/todo.js
  14. +0 −45 examples/todo_app_jade/app/views/layouts/application.html.jade
  15. +0 −6 examples/todo_app_jade/app/views/main/index.html.ejs
  16. +0 −31 examples/todo_app_jade/app/views/todos/_form.html.jade
  17. +0 −2 examples/todo_app_jade/app/views/todos/add.html.jade
  18. +0 −2 examples/todo_app_jade/app/views/todos/edit.html.jade
  19. +0 −14 examples/todo_app_jade/app/views/todos/index.html.jade
  20. +0 −5 examples/todo_app_jade/app/views/todos/show.html.jade
  21. +0 −31 examples/todo_app_jade/config/development.js
  22. +0 −14 examples/todo_app_jade/config/environment.js
  23. +0 −6 examples/todo_app_jade/config/init.js
  24. +0 −32 examples/todo_app_jade/config/production.js
  25. +0 −37 examples/todo_app_jade/config/router.js
  26. +0 −3,363 examples/todo_app_jade/public/css/bootstrap.css
  27. +0 −610 examples/todo_app_jade/public/css/bootstrap.min.css
  28. +0 −567 examples/todo_app_jade/public/css/bootstrap.responsive.css
  29. +0 −3 examples/todo_app_jade/public/css/bootstrap.responsive.min.css
  30. +0 −50 examples/todo_app_jade/public/css/style.css
  31. BIN examples/todo_app_jade/public/favicon.ico
  32. BIN examples/todo_app_jade/public/img/glyphicons-halflings-white.png
  33. BIN examples/todo_app_jade/public/img/glyphicons-halflings.png
  34. BIN examples/todo_app_jade/public/img/whitey.png
  35. +0 −1,722 examples/todo_app_jade/public/js/bootstrap.js
  36. +0 −1 examples/todo_app_jade/public/js/bootstrap.min.js
  37. +0 −4 examples/todo_app_jade/public/js/jquery.min.js
  38. +76 −69 lib/app.js
  39. +112 −68 lib/base_controller.js
  40. +0 −1 lib/cluster/hack_message_parser.js
  41. +13 −26 lib/cluster/master.js
  42. +3 −4 lib/cluster/master_dispatch.js
  43. +1 −0 lib/cluster/server.js
  44. +1 −1 lib/cluster/worker.js
  45. +2 −3 lib/geddy.js
  46. +0 −2 lib/i18n/index.js
  47. +3 −6 lib/init/i18n.js
  48. +21 −27 lib/model/adapters/mongo.js
  49. +2 −2 lib/model/adapters/riak/index.js
  50. +24 −14 lib/model/index.js
  51. +1 −10 lib/response/errors.js
  52. +4 −3 lib/routers/regexp_router.js
  53. +7 −10 lib/server.js
  54. +2 −8 lib/sessions/stores/memcache.js
  55. +8 −14 lib/sessions/stores/mongodb.js
  56. +8 −13 lib/sessions/stores/redis.js
  57. +0 −14 lib/template/adapters/ejs.js
  58. +7 −27 lib/template/adapters/handlebars.js
  59. +2 −9 lib/template/adapters/jade.js
  60. +10 −26 lib/template/adapters/mustache.js
  61. +7 −4 lib/template/engines/ejs.js
  62. +12 −14 lib/template/helpers/action.js
  63. +108 −227 lib/template/helpers/index.js
  64. +125 −76 lib/template/helpers/utils.js
  65. +4 −3 lib/template/index.js
  66. +1 −0 lib/template/templates/empty.html.ejs
  67. +42 −11 lib/utils/array.js
  68. +57 −0 lib/utils/compat.js
  69. +36 −25 lib/utils/date.js
  70. +78 −2 lib/utils/file.js
  71. +2 −0 lib/utils/index.js
  72. +27 −1 lib/utils/object.js
  73. +231 −28 lib/utils/sorted_collection.js
  74. +475 −137 lib/utils/string.js
  75. +81 −35 lib/utils/uri.js
  76. +215 −165 lib/utils/xml.js
  77. +0 −50 lib/watch_files.js
  78. +1 −1 package.json
  79. +79 −40 site/features.html
  80. +278 −274 site/tutorial.html
  81. +96 −39 templates/Jakefile
  82. +6 −4 templates/resource/model.ejs
  83. +5 −5 templates/scaffold/controller.ejs
  84. +6 −4 templates/scaffold/model.ejs
  85. +15 −15 templates/scaffold/views/ejs/add.html.ejs.ejs
  86. +20 −15 templates/scaffold/views/ejs/edit.html.ejs.ejs
  87. +1 −1 templates/scaffold/views/ejs/index.html.ejs.ejs
  88. +3 −1 templates/scaffold/views/ejs/show.html.ejs.ejs
  89. 0 templates/scaffold/views/handlebars/{add.html.hbs → add.html.hbs.ejs}
  90. 0 templates/scaffold/views/handlebars/{edit.html.hbs → edit.html.hbs.ejs}
  91. 0 templates/scaffold/views/handlebars/{index.html.hbs → index.html.hbs.ejs}
  92. 0 templates/scaffold/views/handlebars/{layout.html.hbs → layout.html.hbs.ejs}
  93. 0 templates/scaffold/views/handlebars/{show.html.hbs → show.html.hbs.ejs}
  94. +15 −15 templates/scaffold/views/jade/add.html.jade.ejs
  95. +21 −17 templates/scaffold/views/jade/edit.html.jade.ejs
  96. +1 −1 templates/scaffold/views/jade/index.html.jade.ejs
  97. +10 −9 templates/scaffold/views/jade/show.html.jade.ejs
  98. 0 templates/scaffold/views/mustache/{add.html.ms → add.html.ms.ejs}
  99. 0 templates/scaffold/views/mustache/{edit.html.ms → edit.html.ms.ejs}
  100. 0 templates/scaffold/views/mustache/{index.html.ms → index.html.ms.ejs}
  101. 0 templates/scaffold/views/mustache/{layout.html.ms → layout.html.ms.ejs}
  102. +0 −6 templates/scaffold/views/mustache/show.html.ms
  103. 0 templates/scaffold/views/mustache/{show.html.hbs → show.html.ms.ejs}
  104. +0 −30 test/event_buffer.js
  105. +2 −2 test/model/create_user.js
  106. +2 −2 test/model/datatypes.js
  107. +2 −2 test/{ → routers}/regexp_router.js
  108. +20 −5 test/{ → templates}/ejs.js
  109. +19 −4 test/{ → templates}/handlebars_mustache.js
  110. +75 −5 test/{ → templates}/helpers.js
  111. +19 −4 test/{ → templates}/jade.js
  112. +64 −0 test/utils/array.js
  113. +69 −0 test/utils/date.js
  114. +45 −0 test/utils/event_buffer.js
  115. +86 −0 test/utils/object.js
  116. +19 −5 test/{ → utils}/sorted_collection.js
  117. +287 −0 test/utils/string.js
  118. +137 −0 test/utils/uri.js
  119. +76 −0 test/utils/xml.js
  120. +0 −53 test/xml.js
View
@@ -1,3 +1,4 @@
+v8.log
*.swp
*.swo
auth_info.js
@@ -12,3 +13,4 @@ tmtags
examples/*/log/*
.log
npm-debug.log
+doc/
View
@@ -42,13 +42,10 @@ var p = new jake.NpmPublishTask('geddy', [
, 'test/**'
]);
-// TODO: This is hacky -- need a better way to poke Jake to
-// set up the package part included in the publish-task
-jake.Task['npm:definePackage'].invoke();
-
testTask = new jake.TestTask('Geddy', function () {
this.testName = 'testBase';
this.testFiles.include('test/*.js');
+ this.testFiles.include('test/**/*.js');
this.showDescription = false;
});
@@ -58,25 +55,27 @@ task('test', function () {
t.addListener('error', function (err) {
var module
, cmd
- , errMsg = err.message;
+ , errMsg = err.message
+ , match = errMsg.match('Cannot find module')
+ , absModuleName = errMsg.match(/'[a-zA-Z]*'/);
- if (errMsg.match('Cannot find module')) {
- module = errMsg.match(/'[a-zA-Z]*'/)[0].replace(/'/g, '')
+ if (match && absModuleName) {
+ module = absModuleName[0].replace(/'/g, '');
cmd = 'npm install ' + module;
jake.logger.log(module + ' is not installed; Jake will attempt to install it for you.');
jake.exec(cmd, function () {
jake.logger.log('installed!');
t.addListener('complete', function () {
complete();
});
- t.invoke();
+ t.invoke.apply(t, arguments);
});
}
else {
throw err;
}
});
- t.invoke();
+ t.invoke.apply(t, arguments);
}, {async: true});
testTask = new jake.TestTask('Geddy model-adapters', function () {
View
@@ -158,6 +158,12 @@ Each of these items include a name and an optional type, if there's no type give
to string. The list of supported types are listed in the [model](https://github.com/mde/geddy/wiki/Models) documentation.
If no id property is given then a default id property will be created with the type of string.
+You can also use custom default properties:
+```
+geddy resource user name:default admin:boolean
+```
+The above example will use the property `name`(string) to display the items in the views instead of the default ID property, this way when generating scaffolds, it will look better out of the box.
+
### Routes
Routes are created in a similar fashion to Merb or Rails.
View
@@ -3,7 +3,6 @@
// Dependencies
var geddy = require('../lib/geddy')
, exec = require('child_process').exec
- , fs = require('fs')
, path = require('path')
, parseopts = require('../lib/parseopts')
, utils = require('../lib/utils/index');
@@ -36,26 +35,26 @@ usage = [
, ' --workers, -w Number of worker processes to start(Default: 2)'
, ' --debug, -d Sets the log level to output debug messages to'
, ' the console'
- , ' --help, -h Output this usage dialog'
- , ' --version, -v Output the version of Geddy that\'s installed'
, ' --jade, -j When generating views this will create Jade'
, ' templates(Default: EJS)'
, ' --handle, -H When generating views this will create Handlebars'
, ' templates(Default: EJS)'
- , ' --Mustache, -m When generating views this will create Mustache'
+ , ' --mustache, -m When generating views this will create Mustache'
, ' templates(Default: EJS)'
+ , ' --help, -h Output this usage dialog'
+ , ' --version, -v Output the version of Geddy that\'s installed'
, ''
, 'Commands:'
- , ' app [name] Create a new Geddy application'
- , ' resource [name] Create a new resource. A resource includes'
- , ' a model, controller and route'
- , ' scaffold [name] Create a new scaffolding. Scaffolding includes'
- , ' the views, a model, controller and route'
- , ' secret Generate a new application secret in'
- , ' `congig/environment`'
- , ' controller [name] Generate a new controller including views'
- , ' and and a route'
- , ' model [name] Generate a new model'
+ , ' app <name> Create a new Geddy application'
+ , ' resource <name> [attrs] Create a new resource. A resource includes'
+ , ' a model, controller and route'
+ , ' scaffold <name> [attrs] Create a new scaffolding. Scaffolding includes'
+ , ' the views, a model, controller and route'
+ , ' secret Generate a new application secret in'
+ , ' `congig/environment`'
+ , ' controller <name> Generate a new controller including an index view'
+ , ' and and a route'
+ , ' model <name> [attrs] Generate a new model'
, ''
, 'Examples:'
, ' geddy Start Geddy on localhost:4000 in development mode'
@@ -67,6 +66,9 @@ usage = [
, ' geddy resource user name admin:boolean'
, ' Generate a users resource with the model properties'
, ' name as a string and admin as a boolean'
+ , ' geddy scaffold user name:string:default'
+ , ' Generate a users scaffolding user name as the default'
+ , ' value to display data with'
, ''
].join('\n');
@@ -179,26 +181,12 @@ if(cmds.length) {
}
// Just `geddy` -- start the server
else {
- var relPath = '';
-
- // Search for the `config` directory needed to run Geddy
- // - up to 5 parent directories then show the usage
- for(var i = 0, len = utils.file.maxParentDir; i <= len; i++) {
- var configPath = path.join(cwd, relPath, 'config')
- , existsSync = typeof fs.existsSync == 'function' ?
- fs.existsSync : path.existsSync
- , geddyApp = existsSync(configPath);
-
- if(geddyApp) {
- break;
+ // Search for 'config' directory in parent directories
+ utils.fileUtils.searchParentPath('config', function(err, filePath) {
+ if(err) {
+ die(usage);
} else {
- // If 5 directories up show usage
- if(i === len) die(usage);
-
- // Add a relative parent directory
- relPath += '../';
- process.chdir(path.join(cwd, relPath));
+ start();
}
- }
- start(); // Start the server up
+ });
}
View
@@ -151,4 +151,4 @@ function zalgo(text, options) {
return result;
};
return heComes(text);
-}
+}
@@ -16,6 +16,18 @@ var TemplatoHandlebars = (function() {
return fn(data);
};
+ // Iterate over a object of helpers and assign them by name
+ TemplatoHandlebars.prototype.registerHelper = function(data) {
+ var helper;
+
+ for(helper in data) {
+ // Only functions are allowed to be assigned
+ if(typeof data[helper] === 'function') {
+ this.engine.registerHelper(helper, data[helper]);
+ }
+ }
+ };
+
return TemplatoHandlebars;
})();
@@ -1,8 +1,8 @@
require('../../color');
-var TemplatoHandlebars = (function() {
+var TemplatoMustache = (function() {
- function TemplatoHandlebars() {
+ function TemplatoMustache() {
try {
this.engine = this.engine || require('handlebars');
} catch(err) {
@@ -14,16 +14,28 @@ var TemplatoHandlebars = (function() {
}
};
- TemplatoHandlebars.prototype.compile = function(template, options) {
+ TemplatoMustache.prototype.compile = function(template, options) {
return this.engine.compile(template, options);
};
- TemplatoHandlebars.prototype.render = function(data, fn) {
+ TemplatoMustache.prototype.render = function(data, fn) {
return fn(data);
};
- return TemplatoHandlebars;
+ // Iterate over a object of helpers and assign them by name
+ TemplatoMustache.prototype.registerHelper = function(data) {
+ var helper;
+
+ for(helper in data) {
+ // Only functions are allowed to be assigned
+ if(typeof data[helper] === 'function') {
+ this.engine.registerHelper(helper, data[helper]);
+ }
+ }
+ };
+
+ return TemplatoMustache;
})();
-module.exports = TemplatoHandlebars;
+module.exports = TemplatoMustache;
@@ -34,6 +34,7 @@ Templato = (function() {
Templato.prototype.set = function(opts) {
opts = opts || {};
this.options = opts.options || {};
+ this.engineName = opts.engine;
this.engine = (function() {
switch(opts.engine) {
@@ -86,6 +87,12 @@ Templato = (function() {
data[helper] = Templato.helpers[helper];
}
+ // If engine is handlebars or mustache register function helpers
+ if(this.engineName === 'handlebars' || this.engineName === 'mustache') {
+ // Register all helpers with handlebars native registerHelpers method
+ this.engine.registerHelper(data);
+ }
+
return this.engine.render(data, this.compile());
};
@@ -1,6 +1,7 @@
config =
- metrics:
+ ###metrics:
port: 4001
+ ###
module.exports = config
@@ -1,25 +0,0 @@
-/*
- * Geddy JavaScript Web development framework
- * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-
-var Application = function () {
-};
-
-exports.Application = Application;
-
-
-
@@ -1,30 +0,0 @@
-/*
- * Geddy JavaScript Web development framework
- * Copyright 2112 Matthew Eernisse (mde@fleegix.org)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
-*/
-
-var Main = function () {
- this.index = function (req, resp, params) {
- this.respond(params, {
- format: 'html'
- , template: 'app/views/main/index'
- });
- };
-};
-
-exports.Main = Main;
-
-
Oops, something went wrong.

0 comments on commit 9762d15

Please sign in to comment.