|
|
|
@ -13,12 +13,16 @@ marked.setOptions({
|
|
|
|
|
(function(Posts) {
|
|
|
|
|
|
|
|
|
|
Posts.get = function(callback, tid, current_user, start, end) {
|
|
|
|
|
|
|
|
|
|
if (start == null) start = 0;
|
|
|
|
|
if (end == null) end = start + 10;
|
|
|
|
|
|
|
|
|
|
var post_data, user_data, thread_data, vote_data, viewer_data;
|
|
|
|
|
|
|
|
|
|
topics.markAsRead(tid, current_user);
|
|
|
|
|
getTopicPosts();
|
|
|
|
|
|
|
|
|
|
getUserReputation();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//compile thread after all data is asynchronously called
|
|
|
|
|
function generateThread() {
|
|
|
|
@ -71,11 +75,18 @@ marked.setOptions({
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getTopicPosts() {
|
|
|
|
|
// get all data for thread in asynchronous fashion
|
|
|
|
|
RDB.lrange('tid:' + tid + ':posts', start, end, function(err, pids) {
|
|
|
|
|
RDB.handle(err);
|
|
|
|
|
|
|
|
|
|
if(pids.length === 0 ){
|
|
|
|
|
callback(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
topics.markAsRead(tid, current_user);
|
|
|
|
|
|
|
|
|
|
var content = [], uid = [], timestamp = [], pid = [], post_rep = [], editor = [], editTime = [], deleted = [];
|
|
|
|
|
|
|
|
|
|
for (var i=0, ii=pids.length; i<ii; i++) {
|
|
|
|
@ -142,7 +153,9 @@ marked.setOptions({
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getUserReputation() {
|
|
|
|
|
user.getUserField(current_user, 'reputation', function(reputation){
|
|
|
|
|
viewer_data = {
|
|
|
|
|
reputation: reputation
|
|
|
|
@ -150,6 +163,7 @@ marked.setOptions({
|
|
|
|
|
generateThread();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Posts.reply = function(socket, tid, uid, content) {
|
|
|
|
|