basic web thing for the warnings module [#506]

This commit is contained in:
reality 2013-06-19 20:00:35 +00:00
parent 9a531dab2f
commit ce2f3c99d9
3 changed files with 13 additions and 9 deletions

View File

@ -1,20 +1,23 @@
var _ = require('underscore')._; var _ = require('underscore')._;
var pages = function(dbot) { var pages = function(dbot) {
this.warnings = dbot.db.warnings;
return { return {
'/warnings': function(req, res) { '/warning': function(req, res) {
res.render('warnings_servers', { res.render('servers', {
'name': dbot.config.name, 'name': dbot.config.name,
'servers': _.keys(this.warnings) 'servers': _.keys(this.warnings)
}); });
}, },
'/warnings/:server': function(req, res) { '/warning/:server': function(req, res) {
var server = req.params.server; var server = req.params.server;
if(_.has(this.warnings, server)) { if(_.has(this.warnings, server)) {
res.render('warnings_users', { res.render('users', {
'name': dbot.config.name, 'name': dbot.config.name,
'server': server,
'users': _.keys(this.warnings[server]) 'users': _.keys(this.warnings[server])
}); });
} else { } else {
@ -22,13 +25,14 @@ var pages = function(dbot) {
} }
}, },
'/warnings/:server/:user': function(req, res) { '/warning/:server/:user': function(req, res) {
var server = req.params.server, var server = req.params.server,
user = req.params.user; user = req.params.user;
if(_.has(this.warnings, server) && _.has(this.warnings.server, user)) { if(_.has(this.warnings, server) && _.has(this.warnings[server], user)) {
res.render('warnings', { res.render('warnings', {
'name': dbot.config.name, 'name': dbot.config.name,
'server': server,
'warnings': this.warnings[server][user] 'warnings': this.warnings[server][user]
}); });
} else { } else {

View File

@ -26,7 +26,7 @@ var warning = function(dbot) {
'warner': warner, 'warner': warner,
'warnee': warnee, 'warnee': warnee,
'reason': reason, 'reason': reason,
'url': dbot.api.web.getUrl('warnings/' + server + '/' + warnee) 'url': dbot.api.web.getUrl('warning/' + server + '/' + warnee)
}); });
if(!_.isUndefined(adminChannel)) { if(!_.isUndefined(adminChannel)) {
adminChannel = event.channel.name; adminChannel = event.channel.name;
@ -44,7 +44,7 @@ var warning = function(dbot) {
event.reply(dbot.t('warning_info', { event.reply(dbot.t('warning_info', {
'user': warnee, 'user': warnee,
'num': this.warnings[server][warnee].length, 'num': this.warnings[server][warnee].length,
'url': dbot.api.web.getUrl('warnings/' + server + '/' + warnee) 'url': dbot.api.web.getUrl('warning/' + server + '/' + warnee)
})); }));
} else { } else {
event.reply(dbot.t('no_warnings', { 'user': warnee })); event.reply(dbot.t('no_warnings', { 'user': warnee }));

View File

@ -3,7 +3,7 @@ extends ../layout
block content block content
h3 Channels on #{connection} h3 Channels on #{connection}
div#backlink div#backlink
a(href='/connections') « Connection List a(href='/users') « Connection List
ul#quotelist ul#quotelist
-each channel in channels -each channel in channels
a(href='/users/'+connection+'/'+encodeURIComponent(channel)) a(href='/users/'+connection+'/'+encodeURIComponent(channel))