forked from GitHub/dbot
tags
This commit is contained in:
parent
2864c0fa7f
commit
4acf17f636
@ -8,7 +8,8 @@ var pages = function(dbot) {
|
|||||||
var server = req.user.server,
|
var server = req.user.server,
|
||||||
userCount = {},
|
userCount = {},
|
||||||
users = [],
|
users = [],
|
||||||
channelCount = {};
|
channelCount = {},
|
||||||
|
tags = {};
|
||||||
|
|
||||||
this.db.scan('notifies', function(notify) {
|
this.db.scan('notifies', function(notify) {
|
||||||
if(!_.has(userCount, notify.user)) {
|
if(!_.has(userCount, notify.user)) {
|
||||||
@ -19,6 +20,10 @@ var pages = function(dbot) {
|
|||||||
}
|
}
|
||||||
userCount[notify.user]++;
|
userCount[notify.user]++;
|
||||||
channelCount[notify.channel]++;
|
channelCount[notify.channel]++;
|
||||||
|
_.each(notify.tags, function(tag) {
|
||||||
|
if(!_.has(tags, tag)) tags[tag] = 0;
|
||||||
|
tags[tag]++;
|
||||||
|
});
|
||||||
}, function() {
|
}, function() {
|
||||||
userCount = _.map(userCount, function(value, key) {
|
userCount = _.map(userCount, function(value, key) {
|
||||||
return {
|
return {
|
||||||
@ -39,7 +44,8 @@ var pages = function(dbot) {
|
|||||||
res.render('channels', {
|
res.render('channels', {
|
||||||
'server': server,
|
'server': server,
|
||||||
'users': users,
|
'users': users,
|
||||||
'channels': channelCount
|
'channels': channelCount,
|
||||||
|
'tags': tags
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -110,16 +116,24 @@ var pages = function(dbot) {
|
|||||||
|
|
||||||
'/notify/:item': function(req, res) {
|
'/notify/:item': function(req, res) {
|
||||||
var server = req.user.server,
|
var server = req.user.server,
|
||||||
|
type = req.query.t,
|
||||||
notifies = [];
|
notifies = [];
|
||||||
|
|
||||||
if(req.params.item.charAt(0) == '#') {
|
console.log(type);
|
||||||
var channel = req.params.item;
|
|
||||||
|
|
||||||
this.db.search('notifies', {
|
if(req.params.item.charAt(0) == '#') {
|
||||||
|
var item = req.params.item,
|
||||||
|
search = {
|
||||||
'server': server,
|
'server': server,
|
||||||
'channel': channel
|
};
|
||||||
}, function(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);
|
notifies.push(notify);
|
||||||
|
}
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
var pNickCache = {};
|
var pNickCache = {};
|
||||||
async.eachSeries(notifies, function(notify, next) {
|
async.eachSeries(notifies, function(notify, next) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
!!! 5
|
doctype html
|
||||||
html(lang='en')
|
html(lang='en')
|
||||||
head
|
head
|
||||||
meta(charset='utf-8')
|
meta(charset='utf-8')
|
||||||
|
@ -18,3 +18,9 @@ block content
|
|||||||
-each nUser in users
|
-each nUser in users
|
||||||
a(href='/notify/'+encodeURIComponent(nUser.name))
|
a(href='/notify/'+encodeURIComponent(nUser.name))
|
||||||
li.quotes #{nUser.name} (#{nUser.count})
|
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})
|
||||||
|
Loading…
Reference in New Issue
Block a user