3
0
mirror of https://github.com/reality/dbot.git synced 2024-12-24 03:33:07 +01:00
This commit is contained in:
reality 2014-05-25 17:54:46 +00:00
parent 2864c0fa7f
commit 4acf17f636
3 changed files with 29 additions and 9 deletions

View File

@ -8,7 +8,8 @@ var pages = function(dbot) {
var server = req.user.server,
userCount = {},
users = [],
channelCount = {};
channelCount = {},
tags = {};
this.db.scan('notifies', function(notify) {
if(!_.has(userCount, notify.user)) {
@ -19,6 +20,10 @@ var pages = function(dbot) {
}
userCount[notify.user]++;
channelCount[notify.channel]++;
_.each(notify.tags, function(tag) {
if(!_.has(tags, tag)) tags[tag] = 0;
tags[tag]++;
});
}, function() {
userCount = _.map(userCount, function(value, key) {
return {
@ -39,7 +44,8 @@ var pages = function(dbot) {
res.render('channels', {
'server': server,
'users': users,
'channels': channelCount
'channels': channelCount,
'tags': tags
});
});
});
@ -110,16 +116,24 @@ var pages = function(dbot) {
'/notify/:item': function(req, res) {
var server = req.user.server,
type = req.query.t,
notifies = [];
if(req.params.item.charAt(0) == '#') {
var channel = req.params.item;
console.log(type);
this.db.search('notifies', {
if(req.params.item.charAt(0) == '#') {
var item = req.params.item,
search = {
'server': server,
'channel': channel
}, function(notify) {
notifies.push(notify);
};
if(type != 'tag') search.channel = item;
this.db.search('notifies', search, function(notify) {
if(type == 'tag') {
if(_.include(notify.tags, item)) notifies.push(notify);
} else {
notifies.push(notify);
}
}, function(err) {
var pNickCache = {};
async.eachSeries(notifies, function(notify, next) {

View File

@ -1,4 +1,4 @@
!!! 5
doctype html
html(lang='en')
head
meta(charset='utf-8')

View File

@ -18,3 +18,9 @@ block content
-each nUser in users
a(href='/notify/'+encodeURIComponent(nUser.name))
li.quotes #{nUser.name} (#{nUser.count})
h3 Browse by Tag on #{server}
ul#quotelist
-each count, tag in tags
a(href='/notify/'+encodeURIComponent(tag)+'?t=tag')
li.quotes #{tag} (#{count})