Permalink
Browse files

migrated meryl to node version 0.4.x and refactored some parts with s…

…ome rewriting
  • Loading branch information...
1 parent afeb9d3 commit c86f5aeaa091a02e0226592993c5df2fc5486c3a @kadirpekel committed Mar 9, 2011
View
@@ -1,46 +1,47 @@
Meryl
=====
-Meryl is minimalist web framework for nodejs platform.
+Meryl is a minimalist web framework for nodejs platform.
It is really simple to use, fun to play and easy to modify.
Here is simple preview.
+ // take the pills
var meryl = require('meryl');
- meryl
- .plug('GET *', function (req, resp, next) {
- resp.headers.server = 'Meryl on NodeJS';
- next();
- }
- )
- .plug('GET /private/*', function (req, resp, next) {
- resp.status = 401;
- throw 'Forbidden';
- }
- )
- .handle('GET /', function (req, resp) {
- resp.send('<h3>Hello, World!</h3>');
- }
- )
- .handle('GET /greet/{name}', function (req, resp) {
- resp.send('<h3>Hello, ' + req.params.name + '</h3>');
- }
- )
- .run();
-
-Meryl has much more...
-
-Please visit Meryl homepage for all related stuff.
-
-<http://coffeemate.github.com/meryl>
-
-For updates please follow: <http://twitter.com/meryljs>
+ // first, take it easy
+ meryl.handle('GET /', function (req, resp) {
+ resp.end('<h3>Hello, World!</h3>');
+ });
+
+ // not impressed? let it interfere with blood some more
+ meryl.handle('GET /greet/{who}', function(req, resp) {
+ resp.render('greeter_template', {name: req.params.who});
+ });
+
+ // lay down and enjoy it
+ meryl.plug('GET *', function(req, resp, next) {
+ resp.setHeader('server', 'meryl');
+ next();
+ });
+
+ // now you are a 'meryl' junkie
+ meryl.run();
+
+
+Meryl has much more.
+
+Please visit wiki page for documentation:
+ <http://github.com/coffeemate/meryl/wiki>
+
+Also there are plenty of examples in 'examples' directory:
+ <http://github.com/coffeemate/meryl/tree/master/examples>
+
+For updates please follow:
+ <http://twitter.com/meryljs>
Contributors:
* Kadir Pekel (Author) <http://twitter.com/kadirpekel>
* George Stagas <http://twitter.com/stagas>
* Samuel Morello <http://twitter.com/ouvanous>
- * Tom R <http://twitter.com/rx>
-
@@ -11,37 +11,37 @@ require('http').createServer(
.plug(function (req, resp, next) {
resp.filteredSend = function (buffer) {
- resp.send("<h1>" + buffer.toString() + "</h1>");
+ resp.end("<h1>" + buffer.toString() + "</h1>");
};
next();
})
.plug(function (req, resp, next) {
- resp.headers.server = 'node';
+ resp.setHeader('server', 'node');
console.log(req.method + ' ' + req.params.pathname);
next();
})
.plug('POST *', function (req, resp, next) {
- resp.status = 405;
+ resp.statusCode = 405;
throw new Error('method not allowed');
})
.plug('{method} /private/*', function (req, resp, next) {
- resp.status = 401;
+ resp.statusCode = 401;
throw new Error('access denied');
})
.handle('GET /', function (req, resp) {
- resp.send("<h1>Demonstraing Meryl</h1>");
+ resp.end("<h1>Demonstraing Meryl</h1>");
})
.handle('GET /{pagename}.html', function (req, resp) {
resp.filteredSend("You're reading: " + req.params.pagename);
})
.handle('GET /exception', function (req, resp) {
- resp.send(1);
+ resp.end(1);
})
.cgi({debug: true})
@@ -12,7 +12,7 @@ var controllerDir = 'controllers',
datastore.load(function () {
// Register plugins
- meryl.plug(connect.staticProvider({root: staticDir}), connect.logger());
+ meryl.plug(connect.static(staticDir), connect.logger());
// Loads controllers automatically
var loadControllers = function (controllerDir, onLoad) {
@@ -5,7 +5,7 @@ with (meryl) {
});
get('/about', function(req, resp) {
- resp.send('<h3>Meryl is simple to use, fun to play, easy to modify!</h3>');
+ resp.end('<h3>Meryl is simple to use, fun to play, easy to modify!</h3>');
});
}
@@ -6,7 +6,7 @@ people = ['animal', 'beakers', 'piggy', 'kermit']
(require '../../index')
.plug connect.logger(),
- connect.staticProvider()
+ connect.static(".")
.get '/', (req, resp) ->
resp.redirect('/people')
@@ -4,17 +4,17 @@ var Connect = require('connect'),
meryl
.p(
function (req, resp, next) {
- resp.headers.server = 'nodejs/connect/meryl';
+ resp.setHeader('backend', 'nodejs/connect/meryl');
next();
},
Connect.logger()
)
.p('GET *',
Connect.favicon(),
- Connect.staticProvider()
+ Connect.static(".")
)
.h('GET /', function (req, resp) {
- resp.send("<h1>Welcome To NodeJS!</h1><img src='nodejs.png' />");
+ resp.end("<h1>Welcome To NodeJS!</h1><img src='nodejs.png' />");
})
.run();
@@ -63,7 +63,7 @@ meryl
if (err) {
throw err;
}
- resp.send(output);
+ resp.end(output);
});
};
next();
@@ -2,7 +2,7 @@ with (require('connect')) {
require('../../index') // meryl
.fabby
- (logger(), staticProvider())
+ (logger(), static("."))
('GET /', function (req, resp) {
resp.render('home');
}
@@ -2,7 +2,7 @@ var meryl = require('../../index');
meryl
.h('GET /', function (req, resp) {
- resp.send("<h1>Hello World!</h1>");
+ resp.end("<h1>Hello World!</h1>");
})
.run();
@@ -13,7 +13,7 @@ meryl
});
})
.h('GET /', function (req, resp) {
- resp.send("<h1>Welcome To NodeJS!</h1><img src='nodejs.png' />");
+ resp.end("<h1>Welcome To NodeJS!</h1><img src='nodejs.png' />");
})
.run();
@@ -7,5 +7,5 @@ module.exports = function (meryl) {
meryl.options.templateExt = '.mt', // Default is '.jshtml'
- meryl.plug(connect.staticProvider(), connect.logger());
+ meryl.plug(connect.static("."), connect.logger());
};
@@ -4,7 +4,7 @@ var meryl = require('../../index'),
var twinkles = ['This is my freaking first wink', 'Hey tweeting sucks, lets twinkle'];
-meryl.p(Connect.staticProvider({root: 'public'}));
+meryl.p(Connect.static('public'));
meryl.h('GET /', function (req, resp) {
resp.render('index', {twinkles: twinkles});
Oops, something went wrong.

0 comments on commit c86f5ae

Please sign in to comment.