mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 03:26:04 +01:00
updated category: tracking active participants + removed placeholder; recent author picture now pulled dynamically; graph/users/picture implemented
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
<div class="span12 topic-row img-polaroid">
|
<div class="span12 topic-row img-polaroid">
|
||||||
<div class="latest-post visible-desktop">
|
<div class="latest-post visible-desktop">
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<img src="{topics.recent_picture}?s=50" />
|
<img style="width: 48px; height: 48px; /*temporary*/" src="/graph/users/{topics.recent_author}/picture" />
|
||||||
<p><strong>{topics.recent_author}</strong>: {topics.recent_post}</p>
|
<p><strong>{topics.recent_author}</strong>: {topics.recent_post}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -37,31 +37,17 @@
|
|||||||
Recent Replies
|
Recent Replies
|
||||||
</div>
|
</div>
|
||||||
<div class="block-content">
|
<div class="block-content">
|
||||||
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="sidebar-block img-polaroid">
|
<div class="sidebar-block img-polaroid">
|
||||||
<div class="block-header">
|
<div class="block-header">
|
||||||
Top posters
|
Active Participants
|
||||||
</div>
|
</div>
|
||||||
<div class="block-content">
|
<div class="block-content">
|
||||||
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
|
<!-- BEGIN active_users -->
|
||||||
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
|
<a href="/users/{active_users.username}"><img style="width: 48px; height: 48px; /*temporary*/" src="/graph/users/{active_users.username}/picture" class="img-polaroid" /></a>
|
||||||
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
|
<!-- END active_users -->
|
||||||
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/fd37ce111f863c6665045c2d72d199bf?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/07c9c7170c3ac676c2561e3eeaee063c?s=48" class="img-polaroid" />
|
|
||||||
<img src="http://www.gravatar.com/avatar/91050ce0072697b53380c6a03a1bc12a?s=48" class="img-polaroid" />
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -75,13 +75,7 @@ var RDB = require('./redis.js'),
|
|||||||
'slug' : slug[i],
|
'slug' : slug[i],
|
||||||
'description' : description[i],
|
'description' : description[i],
|
||||||
'blockclass' : blockclass[i],
|
'blockclass' : blockclass[i],
|
||||||
'icon' : icon[i],
|
'icon' : icon[i]
|
||||||
/*'topics' : [0,1], later
|
|
||||||
'latest_post' : {
|
|
||||||
'uid' : 1,
|
|
||||||
'pid' : 1,
|
|
||||||
timestamp and shit
|
|
||||||
}*/
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
17
src/posts.js
17
src/posts.js
@@ -224,10 +224,23 @@ marked.setOptions({
|
|||||||
RDB.incr('tid:' + tid + ':postcount');
|
RDB.incr('tid:' + tid + ':postcount');
|
||||||
|
|
||||||
|
|
||||||
user.getUserFields(uid, ['username','picture'], function(data){
|
user.getUserFields(uid, ['username'], function(data){
|
||||||
RDB.set('tid:' + tid + ':recent:post', content);
|
RDB.set('tid:' + tid + ':recent:post', content);
|
||||||
RDB.set('tid:' + tid + ':recent:author', data.username);
|
RDB.set('tid:' + tid + ':recent:author', data.username);
|
||||||
RDB.set('tid:' + tid + ':recent:picture', data.picture);
|
|
||||||
|
//add active users to this category
|
||||||
|
RDB.get('tid:' + tid + ':cid', function(err, cid) {
|
||||||
|
RDB.handle(err);
|
||||||
|
|
||||||
|
// this is a bit of a naive implementation, defn something to look at post-MVP
|
||||||
|
RDB.scard('cid:' + cid + ':active_users', function(amount) {
|
||||||
|
if (amount > 10) {
|
||||||
|
RDB.spop('cid:' + cid + ':active_users');
|
||||||
|
}
|
||||||
|
|
||||||
|
RDB.sadd('cid:' + cid + ':active_users', data.username);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ var RDB = require('./redis.js'),
|
|||||||
deleted = [],
|
deleted = [],
|
||||||
pinned = [],
|
pinned = [],
|
||||||
recent_post = [],
|
recent_post = [],
|
||||||
recent_author = [],
|
recent_author = [];
|
||||||
recent_picture = [];
|
|
||||||
|
|
||||||
for (var i=0, ii=tids.length; i<ii; i++) {
|
for (var i=0, ii=tids.length; i<ii; i++) {
|
||||||
title.push('tid:' + tids[i] + ':title');
|
title.push('tid:' + tids[i] + ':title');
|
||||||
@@ -43,11 +42,11 @@ var RDB = require('./redis.js'),
|
|||||||
pinned.push('tid:' + tids[i] + ':pinned');
|
pinned.push('tid:' + tids[i] + ':pinned');
|
||||||
recent_post.push('tid:' + tids[i] + ':recent:post');
|
recent_post.push('tid:' + tids[i] + ':recent:post');
|
||||||
recent_author.push('tid:' + tids[i] + ':recent:author');
|
recent_author.push('tid:' + tids[i] + ':recent:author');
|
||||||
recent_picture.push('tid:' + tids[i] + ':recent:picture');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var multi = RDB.multi()
|
var multi = RDB.multi()
|
||||||
.get('cid:' + category_id + ':name');
|
.get('cid:' + category_id + ':name')
|
||||||
|
.smembers('cid:' + category_id + ':active_users');
|
||||||
|
|
||||||
if (tids.length > 0) {
|
if (tids.length > 0) {
|
||||||
multi
|
multi
|
||||||
@@ -61,26 +60,25 @@ var RDB = require('./redis.js'),
|
|||||||
.mget(pinned)
|
.mget(pinned)
|
||||||
.mget(recent_post)
|
.mget(recent_post)
|
||||||
.mget(recent_author)
|
.mget(recent_author)
|
||||||
.mget(recent_picture)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
multi.exec(function(err, replies) {
|
multi.exec(function(err, replies) {
|
||||||
category_name = replies[0];
|
category_name = replies[0];
|
||||||
|
active_usernames = replies[1];
|
||||||
var topics = [];
|
var topics = [];
|
||||||
|
|
||||||
if (tids.length > 0) {
|
if (tids.length > 0) {
|
||||||
title = replies[1];
|
title = replies[2];
|
||||||
uid = replies[2];
|
uid = replies[3];
|
||||||
timestamp = replies[3];
|
timestamp = replies[4];
|
||||||
slug = replies[4];
|
slug = replies[5];
|
||||||
postcount = replies[5];
|
postcount = replies[6];
|
||||||
locked = replies[6];
|
locked = replies[7];
|
||||||
deleted = replies[7];
|
deleted = replies[8];
|
||||||
pinned = replies[8];
|
pinned = replies[9];
|
||||||
recent_post = replies[9];
|
recent_post = replies[10];
|
||||||
recent_author = replies[10];
|
recent_author = replies[11];
|
||||||
recent_picture = replies[11];
|
|
||||||
|
|
||||||
var usernames,
|
var usernames,
|
||||||
has_read;
|
has_read;
|
||||||
@@ -104,8 +102,7 @@ var RDB = require('./redis.js'),
|
|||||||
'pin-icon': pinned[i] === '1' ? 'icon-pushpin' : 'none',
|
'pin-icon': pinned[i] === '1' ? 'icon-pushpin' : 'none',
|
||||||
'badgeclass' : (has_read[i] && current_user !=0) ? '' : 'badge-important',
|
'badgeclass' : (has_read[i] && current_user !=0) ? '' : 'badge-important',
|
||||||
'recent_post' : recent_post[i],
|
'recent_post' : recent_post[i],
|
||||||
'recent_author' : recent_author[i],
|
'recent_author' : recent_author[i]
|
||||||
'recent_picture' : recent_picture[i]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +115,17 @@ var RDB = require('./redis.js'),
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var active_users = {};
|
||||||
|
for (var username in active_usernames) {
|
||||||
|
active_users['username'] = active_usernames[username];
|
||||||
|
}
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
'category_name' : category_id ? category_name : 'Recent',
|
'category_name' : category_id ? category_name : 'Recent',
|
||||||
'show_topic_button' : category_id ? 'show' : 'hidden',
|
'show_topic_button' : category_id ? 'show' : 'hidden',
|
||||||
'category_id': category_id || 0,
|
'category_id': category_id || 0,
|
||||||
'topics': topics
|
'topics': topics,
|
||||||
|
'active_users': active_users
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -211,6 +211,21 @@ var express = require('express'),
|
|||||||
res.send(JSON.stringify(post));
|
res.send(JSON.stringify(post));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//START TODO: MOVE TO GRAPH.JS
|
||||||
|
|
||||||
|
app.get('/graph/users/:username/picture', function(req, res) {
|
||||||
|
user.get_uid_by_username(req.params.username, function(uid) {
|
||||||
|
user.getUserField(uid, 'picture', function(picture) {
|
||||||
|
res.redirect(picture);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
//END TODO: MOVE TO GRAPH.JS
|
||||||
}(WebServer));
|
}(WebServer));
|
||||||
|
|
||||||
server.listen(config.port);
|
server.listen(config.port);
|
||||||
|
|||||||
Reference in New Issue
Block a user