mirror of
https://github.com/reality/dbot.git
synced 2025-01-12 04:52:36 +01:00
Random quote page on the web interface.
This commit is contained in:
parent
846514e09f
commit
0c4b86dc28
@ -15,21 +15,27 @@ var webInterface = function(dbot) {
|
|||||||
//res.render('index', { });
|
//res.render('index', { });
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get('/quotes', function(req, res) {
|
|
||||||
// Lists the quote categories
|
// Lists the quote categories
|
||||||
|
app.get('/quotes', function(req, res) {
|
||||||
res.render('quotelist', { 'quotelist': Object.keys(dbot.db.quoteArrs) });
|
res.render('quotelist', { 'quotelist': Object.keys(dbot.db.quoteArrs) });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Lists quotes in a category
|
||||||
app.get('/quotes/:key', function(req, res) {
|
app.get('/quotes/:key', function(req, res) {
|
||||||
// Lists the quotes in a category
|
|
||||||
var key = req.params.key.toLowerCase();
|
var key = req.params.key.toLowerCase();
|
||||||
if(dbot.db.quoteArrs.hasOwnProperty(key)) {
|
if(dbot.db.quoteArrs.hasOwnProperty(key)) {
|
||||||
res.render('quotes', { 'quotes': dbot.db.quoteArrs[key], locals: {url_regex: RegExp.prototype.url_regex()}});
|
res.render('quotes', { 'quotes': dbot.db.quoteArrs[key], locals: { 'url_regex': RegExp.prototype.url_regex() } });
|
||||||
} else {
|
} else {
|
||||||
res.render('error', { 'message': 'No quotes under that key.' });
|
res.render('error', { 'message': 'No quotes under that key.' });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Load random quote category page
|
||||||
|
app.get('/rq', function() {
|
||||||
|
var rCategory = Object.keys(dbot.db.quoteArrs).random();
|
||||||
|
res.render('quotes', { 'quotes': dbot.db.quoteArrs[rCategory], locals: { 'url_regex': RegExp.prototype.url_regex() } });
|
||||||
|
});
|
||||||
|
|
||||||
app.listen(443);
|
app.listen(443);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
Loading…
Reference in New Issue
Block a user