2013-06-19 02:06:52 +02:00
|
|
|
var _ = require('underscore')._;
|
|
|
|
|
|
|
|
var pages = function(dbot) {
|
2013-06-19 22:00:35 +02:00
|
|
|
this.warnings = dbot.db.warnings;
|
|
|
|
|
2013-06-19 02:06:52 +02:00
|
|
|
return {
|
2013-06-19 22:00:35 +02:00
|
|
|
'/warning': function(req, res) {
|
|
|
|
res.render('servers', {
|
2013-06-19 02:06:52 +02:00
|
|
|
'name': dbot.config.name,
|
|
|
|
'servers': _.keys(this.warnings)
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2013-06-19 22:00:35 +02:00
|
|
|
'/warning/:server': function(req, res) {
|
2013-06-19 02:06:52 +02:00
|
|
|
var server = req.params.server;
|
|
|
|
|
|
|
|
if(_.has(this.warnings, server)) {
|
2013-06-19 22:00:35 +02:00
|
|
|
res.render('users', {
|
2013-06-19 02:06:52 +02:00
|
|
|
'name': dbot.config.name,
|
2013-06-19 22:00:35 +02:00
|
|
|
'server': server,
|
2013-06-19 02:06:52 +02:00
|
|
|
'users': _.keys(this.warnings[server])
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
res.render('error');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-19 22:00:35 +02:00
|
|
|
'/warning/:server/:user': function(req, res) {
|
2013-06-19 02:06:52 +02:00
|
|
|
var server = req.params.server,
|
|
|
|
user = req.params.user;
|
|
|
|
|
2013-06-19 22:00:35 +02:00
|
|
|
if(_.has(this.warnings, server) && _.has(this.warnings[server], user)) {
|
2013-06-19 02:06:52 +02:00
|
|
|
res.render('warnings', {
|
|
|
|
'name': dbot.config.name,
|
2013-06-19 22:00:35 +02:00
|
|
|
'server': server,
|
2013-06-19 02:06:52 +02:00
|
|
|
'warnings': this.warnings[server][user]
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
res.render('error');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return pages(dbot);
|
|
|
|
};
|