Skip to content

Commit

Permalink
Fix code snippets to have section labels.
Browse files Browse the repository at this point in the history
  • Loading branch information
creationix committed Sep 7, 2010
1 parent 2911f27 commit 0c9af63
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions articles/node-redis-fun/snip.js
Expand Up @@ -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>'
Expand All @@ -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){
Expand All @@ -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();
Expand All @@ -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() {
Expand Down Expand Up @@ -243,6 +245,7 @@ var showSnippet = function( req, res, id ) {
});
}

//create
nerve.create( [
[ /^\/([0-9]+)/, showSnippet ],
[ nerve.post("/add"), addSnippet ],
Expand Down

0 comments on commit 0c9af63

Please sign in to comment.