Permalink
Browse files

Fix code snippets to have section labels.

  • Loading branch information...
1 parent 2911f27 commit 0c9af633acb1b4f5d2d4bb99ee6a121858495b57 @creationix committed Sep 7, 2010
Showing with 5 additions and 2 deletions.
  1. +5 −2 articles/node-redis-fun/snip.js
View
7 articles/node-redis-fun/snip.js
@@ -168,6 +168,7 @@ var genLanguageList = function() {
} );
}
+//formHtml
var formHtml = '<form action="/add" method="post">'
+ '<label for="code">Paste code</label><br>'
+ '<textarea name="code" rows="25" cols="80"></textarea><br>'
@@ -177,6 +178,7 @@ var formHtml = '<form action="/add" method="post">'
+ '</select>'
+ '<input type="submit" value="Paste!" /></form>';
+//getPostParams
var getPostParams = function(req, callback){
var body = '';
req.on('data', function(chunk){
@@ -187,7 +189,7 @@ var getPostParams = function(req, callback){
callback( obj );
});
}
-
+//addSnippet
var addSnippet = function( req, res ) {
getPostParams( req, function( obj ) {
var r = redis.createClient();
@@ -202,7 +204,7 @@ var addSnippet = function( req, res ) {
} );
});
};
-
+//showSnippet
var showSnippet = function( req, res, id ) {
var r = redis.createClient();
r.stream.on( 'connect', function() {
@@ -243,6 +245,7 @@ var showSnippet = function( req, res, id ) {
});
}
+//create
nerve.create( [
[ /^\/([0-9]+)/, showSnippet ],
[ nerve.post("/add"), addSnippet ],

0 comments on commit 0c9af63

Please sign in to comment.