2013-01-22 21:44:45 +01:00
|
|
|
var pages = function(dbot) {
|
|
|
|
var _ = require('underscore')._;
|
|
|
|
var connections = dbot.instance.connections;
|
|
|
|
|
|
|
|
return {
|
|
|
|
'/profile/:connection/:user': function(req, res) {
|
|
|
|
var connection = req.params.connection;
|
|
|
|
var user = dbot.cleanNick(req.params.user);
|
|
|
|
|
|
|
|
var primary = dbot.api.users.resolveUser(connection, user, true);
|
|
|
|
//var profile = dbot.api.profile.getProfile(primary);
|
|
|
|
var profile = dbot.db.profiles[connection][primary.toLowerCase()].profile;
|
|
|
|
var stats = dbot.api.stats.getUserChansStats(connection, primary.toLowerCase(), [
|
|
|
|
"lines", "words", "lincent", "wpl", "in_mentions"]
|
|
|
|
);
|
|
|
|
|
2013-01-25 01:40:42 +01:00
|
|
|
|
|
|
|
|
2013-01-22 21:44:45 +01:00
|
|
|
res.render('profile', {
|
|
|
|
'name': dbot.config.name,
|
|
|
|
'connection': connection,
|
|
|
|
'primary': primary,
|
|
|
|
'profile': profile,
|
|
|
|
'stats': stats.channels,
|
|
|
|
});
|
2013-01-24 02:02:50 +01:00
|
|
|
},
|
|
|
|
|
2013-01-24 20:39:28 +01:00
|
|
|
'/profile/:connection': function(req, res) {
|
2013-01-24 02:02:50 +01:00
|
|
|
var connection = req.params.connection;
|
|
|
|
var profiles = dbot.db.profiles[connection];
|
|
|
|
|
2013-01-25 01:40:42 +01:00
|
|
|
// TODO: Clean up
|
|
|
|
_.each(profiles, function(profile) {
|
|
|
|
if(_.has(dbot.db.quoteArrs, profile.profile.primary)) {
|
|
|
|
var category = dbot.db.quoteArrs[profile.profile.primary];
|
|
|
|
var avatar = _.find(category, function(quote) {
|
|
|
|
return quote.match(/(\.jpg|\.png|\.jpeg)$/i);
|
|
|
|
});
|
|
|
|
if(avatar) profile.profile.avatar = avatar;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-01-24 02:02:50 +01:00
|
|
|
res.render('profile_grid', {
|
|
|
|
'name': dbot.config.name,
|
|
|
|
'connection': connection,
|
|
|
|
'profiles': profiles,
|
|
|
|
});
|
2013-01-22 21:44:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.fetch = function(dbot) {
|
|
|
|
return pages(dbot);
|
|
|
|
};
|