mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-03 04:25:55 +01:00
recent posts in /users/ page
This commit is contained in:
@@ -227,6 +227,15 @@ footer.footer {
|
|||||||
width:100px;
|
width:100px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-recent-posts {
|
||||||
|
div {
|
||||||
|
color: #333;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.category-icon {
|
.category-icon {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|||||||
@@ -25,7 +25,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="span10">
|
<div class="span5">
|
||||||
|
<h4>profile</h4>
|
||||||
<div class="inline-block">
|
<div class="inline-block">
|
||||||
<div class="account-bio-block">
|
<div class="account-bio-block">
|
||||||
<span class="account-bio-label">email</span>
|
<span class="account-bio-label">email</span>
|
||||||
@@ -76,6 +77,19 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="span5 user-recent-posts">
|
||||||
|
<h4>recent posts </h4>
|
||||||
|
<!-- BEGIN posts -->
|
||||||
|
<a href="/topic/{posts.tid}/{posts.pid}">
|
||||||
|
<div class="topic-row img-polaroid clearfix">
|
||||||
|
<span>{posts.content}</span>
|
||||||
|
<span class="pull-right">{posts.timestamp} ago</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- END posts -->
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
33
src/posts.js
33
src/posts.js
@@ -64,7 +64,7 @@ marked.setOptions({
|
|||||||
};
|
};
|
||||||
|
|
||||||
Posts.getPostsByPids = function(pids, current_user, callback) {
|
Posts.getPostsByPids = function(pids, current_user, callback) {
|
||||||
var content = [], uid = [], timestamp = [], post_rep = [], editor = [], editTime = [], deleted = [];
|
var content = [], uid = [], timestamp = [], post_rep = [], editor = [], editTime = [], deleted = [], tid = [];
|
||||||
|
|
||||||
for (var i=0, ii=pids.length; i<ii; i++) {
|
for (var i=0, ii=pids.length; i<ii; i++) {
|
||||||
content.push('pid:' + pids[i] + ':content');
|
content.push('pid:' + pids[i] + ':content');
|
||||||
@@ -74,6 +74,7 @@ marked.setOptions({
|
|||||||
editor.push('pid:' + pids[i] + ':editor');
|
editor.push('pid:' + pids[i] + ':editor');
|
||||||
editTime.push('pid:' + pids[i] + ':edited');
|
editTime.push('pid:' + pids[i] + ':edited');
|
||||||
deleted.push('pid:' + pids[i] + ':deleted');
|
deleted.push('pid:' + pids[i] + ':deleted');
|
||||||
|
tid.push('pid:' + pids[i] + ':tid');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -92,6 +93,7 @@ marked.setOptions({
|
|||||||
.mget(editor)
|
.mget(editor)
|
||||||
.mget(editTime)
|
.mget(editTime)
|
||||||
.mget(deleted)
|
.mget(deleted)
|
||||||
|
.mget(tid)
|
||||||
.exec(function(err, replies) {
|
.exec(function(err, replies) {
|
||||||
post_data = {
|
post_data = {
|
||||||
pid: pids,
|
pid: pids,
|
||||||
@@ -101,7 +103,8 @@ marked.setOptions({
|
|||||||
reputation: replies[3],
|
reputation: replies[3],
|
||||||
editor: replies[4],
|
editor: replies[4],
|
||||||
editTime: replies[5],
|
editTime: replies[5],
|
||||||
deleted: replies[6]
|
deleted: replies[6],
|
||||||
|
tid: replies[7]
|
||||||
};
|
};
|
||||||
|
|
||||||
// below, to be deprecated
|
// below, to be deprecated
|
||||||
@@ -302,5 +305,31 @@ marked.setOptions({
|
|||||||
callback(raw);
|
callback(raw);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Posts.getPostsByUid = function(uid, callback) {
|
||||||
|
|
||||||
|
RDB.lrange('uid:' + uid + ':posts', 0, 10, function(err, pids) {
|
||||||
|
if(err === null) {
|
||||||
|
|
||||||
|
Posts.getPostsByPids(pids, uid, function(posts) {
|
||||||
|
var returnData = [];
|
||||||
|
|
||||||
|
var len = posts.postData.pid.length;
|
||||||
|
|
||||||
|
for (var i=0; i < len; ++i) {
|
||||||
|
returnData.push({
|
||||||
|
pid: posts.postData.pid[i],
|
||||||
|
content: posts.postData.content[i],
|
||||||
|
timestamp: utils.relativeTime(posts.postData.timestamp[i]),
|
||||||
|
tid: posts.postData.tid[i]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
console.log(returnData);
|
||||||
|
callback(returnData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}(exports));
|
}(exports));
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
var user = require('./../user.js'),
|
var user = require('./../user.js'),
|
||||||
|
posts = require('./../posts.js'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
utils = require('./../../public/src/utils.js'),
|
utils = require('./../../public/src/utils.js'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
@@ -41,13 +42,13 @@ var user = require('./../user.js'),
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getUserData(uid, function(data) {
|
user.getUserData(uid, function(userdata) {
|
||||||
if(data) {
|
if(userdata) {
|
||||||
res.send(app.build_header(res) + app.create_route('users/'+data.userslug, 'account') + templates['footer']);
|
res.send(app.build_header(res) + app.create_route('users/'+userdata.userslug, 'account') + templates['footer']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
res.redirect('/404');
|
res.redirect('/404');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -274,11 +275,15 @@ var user = require('./../user.js'),
|
|||||||
getUserDataByUserSlug(req.params.userslug, callerUID, function(userData) {
|
getUserDataByUserSlug(req.params.userslug, callerUID, function(userData) {
|
||||||
|
|
||||||
user.isFollowing(callerUID, userData.theirid, function(isFollowing) {
|
user.isFollowing(callerUID, userData.theirid, function(isFollowing) {
|
||||||
userData.isFollowing = isFollowing;
|
|
||||||
|
|
||||||
userData.signature = marked(userData.signature || '');
|
posts.getPostsByUid(userData.theirid, function(posts) {
|
||||||
|
userData.posts = posts;
|
||||||
|
userData.isFollowing = isFollowing;
|
||||||
|
|
||||||
res.json(userData);
|
userData.signature = marked(userData.signature || '');
|
||||||
|
|
||||||
|
res.json(userData);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user