Skip to content

Commit 6bd67d9

Browse files
committed
Renamed project to grasshopper.
1 parent 77fc38f commit 6bd67d9

File tree

11 files changed

+57
-57
lines changed

11 files changed

+57
-57
lines changed

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
MVC.js
2-
======
1+
Grasshopper
2+
==========
33

4-
A simple MVC framework for web applications built on [node.JS](http://nodejs.org/). Follow the [instructions to install node.JS](http://nodejs.org/#download). Join the [mailing list](http://groups.google.com/group/mvcjs) for further help and feedback.
4+
A simple MVC framework for web applications built on [node.JS](http://nodejs.org/). Follow the [instructions to install node.JS](http://nodejs.org/#download). Join the [mailing list](http://groups.google.com/group/grasshopperjs) for further help and feedback.
55

66
This framework is licensed under the terms of [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
77

88
Hello World
99
-----------
1010

11-
1. Clone the repository using `git clone git://github.com/tuxychandru/mvc.js.git`.
12-
2. Create a directory for your application and copy the `lib` directory from the cloned repository to it.
11+
1. Clone the repository using `git clone git://github.com/tuxychandru/grasshopper.git`.
12+
2. Create a directory for your application and copy or symlink the `lib` directory from the cloned repository to it.
1313
3. Create a file named `hello.js` in your application's directory with the following content.
1414

1515
require.paths.unshift('./lib');
1616

17-
var mvc = require('mvc');
17+
var gh = require('grasshopper');
1818

19-
mvc.get('/', function() {
19+
gh.get('/', function() {
2020
this.renderText('Hello World!');
2121
});
2222

23-
mvc.serve(8080);
23+
gh.serve(8080);
2424

2525
4. From your applications directory invoke the command `node hello.js`.
2626
5. Point your browser at http://localhost:8080.
@@ -52,26 +52,26 @@ Arguments passed as part of the URL can be obtained with an additional parameter
5252

5353
require.paths.unshift('./lib');
5454

55-
var mvc = require('mvc');
55+
var gh = require('grasshopper');
5656

57-
mvc.get('/greetings/{name}', function(args) {
57+
gh.get('/greetings/{name}', function(args) {
5858
this.model['name'] = args.name;
5959
this.render('greeting');
6060
});
6161

62-
mvc.serve(8080);
62+
gh.serve(8080);
6363

6464
4. From your applications directory invoke the command `node template.js`.
6565
5. Point your browser at http://localhost:8080/greetings/ABC.
6666

6767
Dependency Injection
6868
--------------------
6969

70-
Hashes containing the necessary dependencies can be added to the `this` context of your controller functions, using the `mvc.addToContext()` function. You can either specify all the hashes to be included in a single invocation or in multiple invocations. For example,
70+
Hashes containing the necessary dependencies can be added to the `this` context of your controller functions, using the `gh.addToContext()` function. You can either specify all the hashes to be included in a single invocation or in multiple invocations. For example,
7171

7272
require.paths.unshift('./lib');
7373

74-
var mvc = require('mvc');
74+
var gh = require('grasshopper');
7575

7676
var dependencies = {
7777
dataService: {
@@ -80,13 +80,13 @@ Hashes containing the necessary dependencies can be added to the `this` context
8080
}
8181
}
8282
};
83-
mvc.addToContext(dependencies);
83+
gh.addToContext(dependencies);
8484

85-
mvc.get('/', function() {
85+
gh.get('/', function() {
8686
this.renderText('There are ' + this.dataService.getStock() + ' units in stock!');
8787
});
8888

89-
mvc.serve(8080);
89+
gh.serve(8080);
9090

9191
To Do
9292
-----

examples/REST/cities.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require.paths.unshift('./lib');
22

3-
var mvc = require('mvc');
3+
var gh = require('grasshopper');
44
var renderer = require('renderer');
55

66
function InMemoryCityProvider() {
@@ -34,15 +34,15 @@ function InMemoryCityProvider() {
3434
}
3535
}
3636

37-
mvc.get('/', function() {
37+
gh.get('/', function() {
3838
this.redirect('/cities');
3939
});
4040

41-
mvc.get('/cities', function() {
41+
gh.get('/cities', function() {
4242
this.renderText(JSON.stringify({cities: this.cityProvider.findAll()}));
4343
});
4444

45-
mvc.get('/cities/{id}', function(args) {
45+
gh.get('/cities/{id}', function(args) {
4646
var city = this.cityProvider.findById(args.id);
4747

4848
if(city) {
@@ -52,7 +52,7 @@ mvc.get('/cities/{id}', function(args) {
5252
}
5353
});
5454

55-
mvc.post('/cities', function() {
55+
gh.post('/cities', function() {
5656
var city = {
5757
name: this.params.name,
5858
population: this.params.population
@@ -63,7 +63,7 @@ mvc.post('/cities', function() {
6363
this.renderText(JSON.stringify(city));
6464
});
6565

66-
mvc.put('/cities/{id}', function(args) {
66+
gh.put('/cities/{id}', function(args) {
6767
var city = this.cityProvider.findById(args.id);
6868
if(city) {
6969
city.name = this.params.name;
@@ -77,7 +77,7 @@ mvc.put('/cities/{id}', function(args) {
7777
}
7878
});
7979

80-
mvc.del('/cities/{id}', function(args) {
80+
gh.del('/cities/{id}', function(args) {
8181
var city = this.cityProvider.findById(args.id);
8282
if(city) {
8383
this.cityProvider.remove(city);
@@ -93,5 +93,5 @@ renderer.configure({
9393
defaultViewExtn: 'json'
9494
});
9595

96-
mvc.addToContext({cityProvider: new InMemoryCityProvider()});
97-
mvc.serve(8080);
96+
gh.addToContext({cityProvider: new InMemoryCityProvider()});
97+
gh.serve(8080);

examples/cookies/cookies.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
require.paths.unshift('./lib');
22

3-
var mvc = require('mvc');
3+
var gh = require('grasshopper');
44

5-
mvc.get('/', function() {
5+
gh.get('/', function() {
66
this.model['cookies'] = this.requestCookies;
77
this.render('index');
88
});
99

10-
mvc.post('/set_cookie', function() {
11-
this.addCookie(new mvc.Cookie(this.params['name'], this.params['value']));
10+
gh.post('/set_cookie', function() {
11+
this.addCookie(new gh.Cookie(this.params['name'], this.params['value']));
1212
this.redirect('/');
1313
});
1414

15-
mvc.serve(8080);
15+
gh.serve(8080);

examples/di/di.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require.paths.unshift('./lib');
22

3-
var mvc = require('mvc');
3+
var gh = require('grasshopper');
44

55
var dependencies = {
66
dataService: {
@@ -9,11 +9,11 @@ var dependencies = {
99
}
1010
}
1111
};
12-
mvc.addToContext(dependencies);
12+
gh.addToContext(dependencies);
1313

14-
mvc.get('/', function() {
14+
gh.get('/', function() {
1515
this.renderText('There are ' + this.dataService.getStock() + ' units in stock!');
1616
});
1717

18-
mvc.serve(8080);
18+
gh.serve(8080);
1919

examples/filter/filter.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require.paths.unshift('./lib');
22

3-
var mvc = require('mvc');
3+
var gh = require('grasshopper');
44

5-
mvc.addFilters(/\/secure/, function(nextFilter) {
5+
gh.addFilters(/\/secure/, function(nextFilter) {
66
var self = this;
77
this.getSessionValue('user', function(err, user) {
88
if(!err && user) {
@@ -13,7 +13,7 @@ mvc.addFilters(/\/secure/, function(nextFilter) {
1313
});
1414
});
1515

16-
mvc.get('/secure_welcome', function() {
16+
gh.get('/secure_welcome', function() {
1717
this.disableCache();
1818
var self = this;
1919
this.getSessionValue('user', function(err, user) {
@@ -22,7 +22,7 @@ mvc.get('/secure_welcome', function() {
2222
});
2323
});
2424

25-
mvc.get('/', function() {
25+
gh.get('/', function() {
2626
this.disableCache();
2727
var self = this;
2828
this.getSessionValue('user', function(err, user) {
@@ -34,18 +34,18 @@ mvc.get('/', function() {
3434
});
3535
});
3636

37-
mvc.post('/login', function() {
37+
gh.post('/login', function() {
3838
var self = this;
3939
this.setSessionValue('user', this.params['name'], function() {
4040
self.redirect('/');
4141
});
4242
});
4343

44-
mvc.get('/logout', function() {
44+
gh.get('/logout', function() {
4545
var self = this;
4646
this.endSession(function() {
4747
self.redirect('/');
4848
});
4949
});
5050

51-
mvc.serve(8080);
51+
gh.serve(8080);

examples/hello_world/hello.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
require.paths.unshift('./lib');
22

3-
var mvc = require('mvc');
3+
var gh = require('grasshopper');
44

5-
mvc.get('/', function() {
5+
gh.get('/', function() {
66
this.renderText('Hello World!');
77
});
88

9-
mvc.serve(8080);
9+
gh.serve(8080);

examples/session/login.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
require.paths.unshift('./lib');
22

3-
var mvc = require('mvc');
3+
var gh = require('grasshopper');
44

5-
mvc.get('/', function() {
5+
gh.get('/', function() {
66
var self = this;
77
this.getSessionValue('user', function(err, user) {
88
self.disableCache();
@@ -15,18 +15,18 @@ mvc.get('/', function() {
1515
});
1616
});
1717

18-
mvc.post('/login', function() {
18+
gh.post('/login', function() {
1919
var self = this;
2020
this.setSessionValue('user', this.params['name'], function() {
2121
self.redirect('/');
2222
});
2323
});
2424

25-
mvc.get('/logout', function() {
25+
gh.get('/logout', function() {
2626
var self = this;
2727
this.endSession(function() {
2828
self.redirect('/');
2929
});
3030
});
3131

32-
mvc.serve(8080);
32+
gh.serve(8080);

examples/url_arg_template/template.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
require.paths.unshift('./lib');
22

3-
var mvc = require('mvc');
3+
var gh = require('grasshopper');
44

5-
mvc.get('/greetings/{name}', function(args) {
5+
gh.get('/greetings/{name}', function(args) {
66
this.model['name'] = args.name;
77
this.render('greeting');
88
});
99

10-
mvc.serve(8080);
10+
gh.serve(8080);
File renamed without changes.

lib/mvc.js renamed to lib/grasshopper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ exports.serve = function(port) {
6565
});
6666

6767
server.listen(port);
68-
console.log('Server running at http://127.0.0.1:' + port + '/');
68+
console.log('Hopping at http://127.0.0.1:' + port + '/. Use Ctrl+C to stop.');
6969
}
7070

7171
// Class: Cookie

lib/renderer.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
var template = require('./mvcTemplate'),
16+
var template = require('./ghTemplate'),
1717
mime = require('./mime'),
1818
uuid = require('./uuid'),
1919
session = require('./session'),
20-
mvc = require('./mvc'),
20+
gh = require('./grasshopper'),
2121
fs = require('fs'),
2222
url = require('url'),
2323
crypto = require('crypto');
@@ -68,7 +68,7 @@ function RequestContext(request, response, params) {
6868
var cookies = cookieLine.split('; ');
6969
for(var i = 0; i < cookies.length; i++) {
7070
var cookieParts = cookies[i].split('=');
71-
if(cookieParts[0] == 'MVCSESSION') {
71+
if(cookieParts[0] == 'GHSESSION') {
7272
this.sessionId = decodeURIComponent(cookieParts[1]);
7373
} else {
7474
this.requestCookies[cookieParts[0]] = decodeURIComponent(cookieParts[1]);
@@ -221,7 +221,7 @@ RequestContext.prototype.beginSession = function(callback) {
221221
session.getSessionStore().beginSession(sessionId, function(err) {
222222
if(!err) {
223223
this.sessionId = sessionId;
224-
self.addCookie(new mvc.Cookie('MVCSESSION', sessionId));
224+
self.addCookie(new gh.Cookie('GHSESSION', sessionId));
225225
}
226226
callback(err);
227227
});

0 commit comments

Comments
 (0)