From ce2f3c99d9412460c9eeb15a86df091355ce9635 Mon Sep 17 00:00:00 2001 From: reality Date: Wed, 19 Jun 2013 20:00:35 +0000 Subject: [PATCH] basic web thing for the warnings module [#506] --- modules/warning/pages.js | 16 ++++++++++------ modules/warning/warning.js | 4 ++-- views/users/channels.jade | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/modules/warning/pages.js b/modules/warning/pages.js index d3bea78..e60a634 100644 --- a/modules/warning/pages.js +++ b/modules/warning/pages.js @@ -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 { diff --git a/modules/warning/warning.js b/modules/warning/warning.js index 51c48db..cbea752 100644 --- a/modules/warning/warning.js +++ b/modules/warning/warning.js @@ -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 })); diff --git a/views/users/channels.jade b/views/users/channels.jade index bb3cac4..62911f9 100644 --- a/views/users/channels.jade +++ b/views/users/channels.jade @@ -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))