3
0
mirror of https://github.com/reality/dbot.git synced 2024-11-23 12:29:26 +01:00

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 pages = function(dbot) {
this.warnings = dbot.db.warnings;
return {
'/warnings': function(req, res) {
res.render('warnings_servers', {
'/warning': function(req, res) {
res.render('servers', {
'name': dbot.config.name,
'servers': _.keys(this.warnings)
});
},
'/warnings/:server': function(req, res) {
'/warning/:server': function(req, res) {
var server = req.params.server;
if(_.has(this.warnings, server)) {
res.render('warnings_users', {
res.render('users', {
'name': dbot.config.name,
'server': server,
'users': _.keys(this.warnings[server])
});
} 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,
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', {
'name': dbot.config.name,
'server': server,
'warnings': this.warnings[server][user]
});
} else {

View File

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

View File

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