mirror of
https://github.com/reality/dbot.git
synced 2024-12-25 20:22:39 +01:00
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
var _ = require('underscore')._;
|
|
var pages = function(dbot) {
|
|
return {
|
|
// Lists quotes in a category
|
|
'/quotes/:key': function(req, res) {
|
|
this.api.getQuoteCategory(req.params.key, function(category) {
|
|
if(category) {
|
|
res.render('quotes', {
|
|
'name': dbot.config.name,
|
|
'quotes': category.quotes,
|
|
'locals': {
|
|
'url_regex': RegExp.prototype.url_regex()
|
|
}
|
|
});
|
|
} else {
|
|
res.render('error', {
|
|
'name': dbot.config.name,
|
|
'message': 'No quotes under that key.'
|
|
});
|
|
}
|
|
});
|
|
},
|
|
|
|
// Show quote list.
|
|
'/quotes': function(req, res) {
|
|
this.api.getCategoryKeys(function(keys) {
|
|
res.render('quotelist', {
|
|
'name': dbot.config.name,
|
|
'quotelist': keys
|
|
});
|
|
});
|
|
},
|
|
}
|
|
};
|
|
|
|
exports.fetch = function(dbot) {
|
|
return pages(dbot);
|
|
};
|