From 0ab31586e98b2c9081e083df7a6b22d8b2ad2f6b Mon Sep 17 00:00:00 2001 From: Luke Slater Date: Thu, 15 Sep 2011 12:30:52 +0100 Subject: [PATCH] quote list and error page --- modules/web.js | 8 ++++++++ views/error.jade | 1 + views/quotes.jade | 3 +++ 3 files changed, 12 insertions(+) create mode 100644 views/error.jade create mode 100644 views/quotes.jade diff --git a/modules/web.js b/modules/web.js index 27c0576..8dfbf36 100644 --- a/modules/web.js +++ b/modules/web.js @@ -13,6 +13,14 @@ var webInterface = function(dbot) { app.get('/', function(req, res) { res.render('index', { }); }); + + app.get('/quotes/:key', function(req, res) { + if(dbot.db.quoteArrs.hasOwnProperty(req.params.key)) { + res.render('quotes', { 'quotes': dbot.db.quoteArrs[req.params.key] }); + } else { + res.render('error', { 'message': 'No quotes under that key.' }); + } + }); app.listen(1337); diff --git a/views/error.jade b/views/error.jade new file mode 100644 index 0000000..f78f6ae --- /dev/null +++ b/views/error.jade @@ -0,0 +1 @@ +p #{message} diff --git a/views/quotes.jade b/views/quotes.jade new file mode 100644 index 0000000..6d1acc4 --- /dev/null +++ b/views/quotes.jade @@ -0,0 +1,3 @@ +ul#quotes + -each quote in quotes + #{quote}