Skip to content

Commit

Permalink
Merge branch 'master' into serverportfailure
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelMadero committed Oct 9, 2012
2 parents e2f0753 + 8b543db commit 7f93697
Show file tree
Hide file tree
Showing 185 changed files with 24,752 additions and 212 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
tmtags
*.DS_Store
examples/*/log/*
site/log/*
.log
npm-debug.log
doc/
45 changes: 33 additions & 12 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ var cwd = process.cwd()
, filepath
, die
, jake
, jakeArgs
, jakeProgram
, jakeLoader
, start;

// Usage dialog
Expand Down Expand Up @@ -126,9 +129,11 @@ if (cmds.length) {
cmd = '';

// Some commands take only one arg
if (!(cmds[0] == 'secret' ||
if (!(cmds[0] == 'jake' ||
cmds[0] == 'secret' ||
cmds[0] == 'db:init' ||
cmds[0] == 'console') && !cmds[1]) {
cmds[0] == 'console')
&& !cmds[1]) {
throw new Error(cmds[0] + ' command requires another argument.');
}

Expand All @@ -148,6 +153,10 @@ if (cmds.length) {

// Add Jake argument based on commands
switch (cmds[0]) {
case 'jake':
cmd = 'jake';
jakeArgs = cmds.slice(1);
break;
case 'console':
// Create DBs
cmd += 'console:start[' + (cmds[1] || 'development') + ']';
Expand Down Expand Up @@ -189,13 +198,26 @@ if (cmds.length) {
}

jake = require('jake');
jake.program.init({
quiet: !opts.debug
, trace: true
});
jake.loader.loadFile(filepath);
jake.program.setTaskNames([cmd]);
jake.program.run();
jakeProgram = jake.program;
jakeLoader = jake.loader;
// Load Geddy's bundled Jakefile
jakeLoader.loadFile(filepath);
if (cmd == 'jake') {
jakeProgram.parseArgs(jakeArgs);
// Load Jakefile and jakelibdir files for app
jakeLoader.loadFile(jakeProgram.opts.jakefile);
jakeLoader.loadDirectory(jakeProgram.opts.jakelibdir);
// Prepend env:init to load Geddy env
jakeProgram.taskNames.unshift('env:init');
}
else {
jakeProgram.init({
quiet: !opts.debug
, trace: true
});
jakeProgram.setTaskNames([cmd]);
}
jakeProgram.run();
}
// Just `geddy` -- start the server
else {
Expand All @@ -204,8 +226,7 @@ else {
if (err) {
die(usage);
}
else {
start();
}

start();
});
}
12 changes: 12 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### 0.5.0
+ removed models from geddy core
+ removed utilities from geddy core
+ removed router from geddy core
+ added [model](https://github.com/mde/model) as a dependency
+ added [utilities](https://github.com/mde/utilities) as a dependency
+ added [barista](https://github.com/kieran/barista) as a dependency
+ added the `geddy console` command
+ added the `geddy exec` command
+ added a ton of tests
+ a ton of minor bug fixes
+ created a new website
7 changes: 5 additions & 2 deletions deps/templato/lib/engines/ejs.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
var TemplatoEJS = (function() {
var path = require('path')
, TemplatoEJS;

TemplatoEJS = (function() {

function TemplatoEJS() {
try {
this.engine = this.engine || require('ejs');
this.engine = this.engine || require(path.join(process.cwd(), 'node_modules', 'ejs'));
} catch(err) {
throw "To use EJS you will need to install it: [sudo] npm install [-g] ejs";
}
Expand Down
7 changes: 5 additions & 2 deletions deps/templato/lib/engines/handlebars.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
var TemplatoHandlebars = (function() {
var path = require('path')
, TemplatoHandlebars;

TemplatoHandlebars = (function() {

function TemplatoHandlebars() {
try {
this.engine = this.engine || require('handlebars');
this.engine = this.engine || require(path.join(process.cwd(), 'node_modules', 'handlebars'));
} catch(err) {
throw "To use Handlebars you will need to install it: [sudo] npm install [-g] handlebars";
}
Expand Down
7 changes: 5 additions & 2 deletions deps/templato/lib/engines/jade.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
var TemplatoJade = (function() {
var path = require('path')
, TemplatoJade;

TemplatoJade = (function() {

function TemplatoJade() {
try {
this.engine = this.engine || require('jade');
this.engine = this.engine || require(path.join(process.cwd(), 'node_modules', 'jade'));
} catch(err) {
throw "To use Jade you will need to install it: [sudo] npm install [-g] jade";
}
Expand Down
6 changes: 4 additions & 2 deletions deps/templato/lib/engines/mustache.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require('../../color');
var path = require('path')
, TemplatoMustache;

var TemplatoMustache = (function() {
TemplatoMustache = (function() {

function TemplatoMustache() {
try {
this.engine = this.engine || require('handlebars');
this.engine = this.engine || require(path.join(process.cwd(), 'node_modules', 'mustache'));
} catch(err) {
throw [
"To use Handlebars you will need to install it: [sudo] npm install [-g] handlebars"
Expand Down
72 changes: 72 additions & 0 deletions docs/1-architecture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
Geddy is built on the same MVC principles that many popular frameworks are based on. Every Geddy app has it's models, controllers, and views as well as config files and routes.

* * *

#### structure

```
├── app
│   ├── controllers
│   │   ├── application.js
│   │   └── main.js
│   ├── helpers
│   ├── models
│   └── views
│   ├── layouts
│   │   └── application.html.jade
│   └── main
│   └── index.html.jade
├── config
├── development.js
├── environment.js
├── init.js
├── production.js
└── router.js
├── lib
├── log
├── node_modules
└── public
```

* * *

#### config
`geddy.config`

Geddy has built in configuration management. Global config options should go in your ‘config/environments.js` file. Likewise, your production and development config options should go in their respective files

If you want to start up your app in a specific environment, use the `-e` option:

```
$ geddy -e production
```

* * *

#### logger
`geddy.log[level]`

Geddy automatically logs requests to an access log, and you can log anything you'd like to stdout or a file. It supports 9 different log levels from debug to emergency.

##### levels
- `access`: outputs to the access log and stdout
- `debug`: debug level logging
- `info`: info level logging
- `notice`: notice level logging
- `warning`: warning level logging
- `error`: error level logging, prints to stdout and stderr
- `critical`: critical level logging
- `alert`: alert level logging
- `emergency`: emergency level logging

##### examples
```
geddy.log.debug(‘someting to debug`)
// prints `something to debug` to the console
geddy.log.error(‘something went wrong’)
// prints ‘something went wrong’ to stderr and the console
```

* * *
110 changes: 110 additions & 0 deletions docs/2-router.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
Geddy uses [Barista](http://github.com/kieran/barista) as it's router. Its API is very similar to rails routes. Both general purpose resource based routes and individually defined routes are possible.

* * *

#### .match
`router.match( path [, method] )`

defines the url to match to a controller action.

##### path
- `path [string]`: the url to match to an action

##### method
- `method [string]`: the http method to match

##### examples
```
router.match(‘/‘).to(‘Main.index’);
// will route any request to ‘/‘ to the Main controller’s index action
router.match( '/products/:id', 'GET' ).to( 'products.show' )
// will route ‘/products/5’ to Products.show()
// and set the id paramer to be 5
router.match( '/profiles/:username', 'GET' ).to( 'users.show' )
// will route ‘/products/dan’ to Users.show()
// and set the username paramer to be dan
router.match( '/products/:id(.:format)', 'GET' ).to( 'products.show' )
// things enclosed in parentheses are optional
```

* * *

#### .to
`router.match( path ).to( action )`

defines the action to map the path to.

##### action
- `action [string]`: a controller name plus an action name as a string
- `action [object]`: an object that defines a controller and action property

##### examples
```
router.match(‘/‘).to(‘Main.index’);
// will route any request to ‘/‘ to the Main controller’s index action
router.match(‘/‘).to({controller: ‘Main’, action: ‘index’});
// will route any request to ‘/‘ to the Main controller’s index action
```

* * *

#### .get
`router.get( path )`

Equivalent to `router.match( path, 'GET' )`

* * *

#### .post
`router.post( path )`

Equivalent to `router.match( path, ‘POST’ )`

* * *

#### .put
`router.put( path )`

Equivalent to `router.match( path, ‘PUT’ )`

* * *

#### .del
`router.del( path )`

Equivalent to `router.match( path, ‘DELETE’ )`

* * *

#### .resource
`router.resource( controller )`

generates standard resource routes for a controller name

##### controller
- `controller [string]`: the camelCased controller name that needs resourceful routes

##### examples
```
router.resource( 'products' )
// is equivalent to:
router.get( '/products(.:format)' ).to( 'products.index' )
router.get( '/products/add(.:format)' ).to( 'products.add' )
router.get( '/products/:id(.:format)' ).to('products.show' )
router.get('/products/:id/edit(.:format)' ).to( 'products.edit' )
router.post('/products(.:format)' ).to( 'products.create' )
router.put('/products/:id(.:format)' ).to( 'products.update' )
router.del('/products/:id(.:format)' ).to( 'products.destroy' )
```

* * *
Loading

0 comments on commit 7f93697

Please sign in to comment.