Skip to content

Instantly share code, notes, and snippets.

@olleolleolle
Created February 7, 2010 09:26
Show Gist options
  • Save olleolleolle/297342 to your computer and use it in GitHub Desktop.
Save olleolleolle/297342 to your computer and use it in GitHub Desktop.
Making the example a little more understandable to the casual user.
diff --git a/exampleProject/views/simple.js b/exampleProject/views/simple.js
index 22e2b7e..6307b2c 100644
--- a/exampleProject/views/simple.js
+++ b/exampleProject/views/simple.js
@@ -4,15 +4,30 @@ var path = require('path');
var HTTP301MovedPermanently = require('bomberjs/lib/http_responses').HTTP301MovedPermanently;
+function htmlHead () {
+ return '<html><head><title>Bomber.js example app</title></head><body>';
+}
+function htmlFoot () {
+ return '</body></html>';
+}
+
exports.index = function(request, response) {
- return "index action";
+ var html = htmlHead();
+ html += "<h1>index action</h1><p>See <tt>routes.js</tt> for more.</p>";
+ html += "<p>Other actions include:</p>";
+ html += "<ul><li><a href='/section/1000'>section/1000</a></li>";
+ html += "<li><a href='/section/2'>section/2 (special case)</a></li>";
+ html += "<li><a href='/simple/lorem'>lorem</a></li>";
+ html += "</ul>";
+ html += htmlFoot();
+ return html;
};
exports.show = function(request, response) {
if( request.params.id == 2 ) {
return new HTTP301MovedPermanently('http://google.com');
}
else {
- return "show action";
+ return htmlHead() + "show action" + htmlFoot();
}
};
@@ -23,6 +38,6 @@ exports.lorem = function(request, response) {
// so this example is pretty simple. But once we can chain, I'll show
// how to manipulate the result as you move through the chain.
- var filename = path.join(path.dirname(__filename),'../resources/lorem-ipsum.txt');
+ var filename = path.join(path.dirname(__filename),'../resources/text.txt');
return posix.cat(filename);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment