forked from GitHub/dbot
sort photos by primary
This commit is contained in:
parent
bb45ef5e3c
commit
f03dfd9111
@ -27,9 +27,23 @@ var pages = function(dbot) {
|
|||||||
var connection = req.params.connection;
|
var connection = req.params.connection;
|
||||||
var profiles = dbot.db.profiles[connection];
|
var profiles = dbot.db.profiles[connection];
|
||||||
|
|
||||||
|
var nicks = [];
|
||||||
|
for (var p in profiles) {
|
||||||
|
if (profiles.hasOwnProperty(p) && profiles[p].profile.avatar) {
|
||||||
|
nicks.push(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nicks.sort(function(a, b) {
|
||||||
|
var x = profiles[a].profile.primary.toLowerCase();
|
||||||
|
var y = profiles[b].profile.primary.toLowerCase();
|
||||||
|
if(x > y) return 1;
|
||||||
|
if(x < y) return -1;
|
||||||
|
return 0;
|
||||||
|
});
|
||||||
res.render('profile_grid', {
|
res.render('profile_grid', {
|
||||||
'name': dbot.config.name,
|
'name': dbot.config.name,
|
||||||
'connection': connection,
|
'connection': connection,
|
||||||
|
'nicks': nicks,
|
||||||
'profiles': profiles,
|
'profiles': profiles,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,9 @@ block content
|
|||||||
a(href='../connections') « Connections
|
a(href='../connections') « Connections
|
||||||
|
|
||||||
ul.thumbnails
|
ul.thumbnails
|
||||||
each profile, key in profiles
|
each nick in nicks
|
||||||
if profile.hasOwnProperty('profile') && profile.profile.avatar
|
li.span2
|
||||||
li.span2
|
a.thumbnail(href='/profile/'+connection+'/'+encodeURIComponent(nick))
|
||||||
a.thumbnail(href='/profile/'+connection+'/'+encodeURIComponent(key))
|
div.imgwrap
|
||||||
div.imgwrap
|
img(src="#{profiles[nick].profile.avatar}", alt="#{profiles[nick].profile.primary}'s photo")
|
||||||
img(src="#{profile.profile.avatar}", alt="#{key}'s photo")
|
span.nicks #{profiles[nick].profile.primary}
|
||||||
span.nicks #{profile.profile.primary}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user