Merge branch 'master' of github.com:designcreateplay/NodeBB

v1.18.x
Julian Lam 11 years ago
commit cc236c1f72

@ -68,10 +68,6 @@ define(['forum/accountheader'], function(header) {
app.openChat(username, theirid);
});
$('.user-recent-posts .topic-row').on('click', function() {
ajaxify.go($(this).attr('topic-url'));
});
socket.on('user.isOnline', Account.handleUserOnline);
socket.emit('user.isOnline', theirid, Account.handleUserOnline);

@ -155,8 +155,8 @@ define(['composer'], function(composer) {
replies += '<li data-pid="'+ posts[i].pid +'">' +
'<a href="' + RELATIVE_PATH + '/user/' + posts[i].userslug + '"><img title="' + posts[i].username + '" class="img-rounded user-img" src="' + posts[i].picture + '"/></a>' +
'<a href="' + RELATIVE_PATH + '/topic/' + posts[i].topicSlug + '#' + posts[i].pid + '">' +
'<strong><span>'+ posts[i].username + '</span></strong>' +
'<a href="' + RELATIVE_PATH + '/topic/' + posts[i].topicSlug + '#' + posts[i].pid + '">' +
'<p>' + posts[i].content + '</p>' +
'</a>' +
'<span class="timeago pull-right" title="' + posts[i].relativeTime + '"></span>' +

@ -522,8 +522,10 @@ define(['composer'], function(composer) {
$('#post-container').on('click', '.chat', function(e) {
var username = $(this).parents('li.row').attr('data-username');
var touid = $(this).parents('li.row').attr('data-uid');
var post = $(this).parents('li.post-row'),
username = post.attr('data-username'),
touid = post.attr('data-uid');
app.openChat(username, touid);
$(this).parents('.btn-group').find('.dropdown-toggle').click();
return false;

@ -108,15 +108,31 @@
</div>
<div class="col-md-6 user-recent-posts">
<div class="topic-row panel panel-default clearfix">
<div class="panel-heading">
<h3 class="panel-title">Recent Posts</h3>
</div>
<div class="panel-body">
<!-- BEGIN posts -->
<div class="topic-row img-thumbnail clearfix" topic-url="topic/{posts.tid}/#{posts.pid}">
<span>{posts.content}</span>
<span class="pull-right timeago" title="{posts.relativeTime}"></span>
<div class="clearfix">
<p>{posts.content}</p>
<span class="pull-right">
<a href="../../topic/{posts.tid}/#{posts.pid}">posted</a>
in
<a href="../../category/{posts.categorySlug}">
<i class="fa {posts.categoryIcon}"></i> {posts.categoryName}
</a>
<span class="timeago" title="{posts.relativeTime}"></span>
</span>
</div>
<hr/>
<!-- END posts -->
</div>
</div>
</div>
</div>
<br/>
<div id="user-action-alert" class="alert alert-success hide"></div>

@ -30,19 +30,21 @@
<meta itemprop="itemListOrder" content="descending">
<!-- BEGIN topics -->
<li class="category-item {topics.deleted-class}" itemprop="itemListElement">
<div class="row">
<div class="col-md-12 topic-row">
<div>
<a href="../../topic/{topics.slug}" itemprop="url">
<div class="col-md-12 panel panel-default topic-row">
<h3>
<a href="../../topic/{topics.slug}" itemprop="url">
<meta itemprop="name" content="{topics.title}">
<span class="topic-title">
<strong><i class="fa {topics.pin-icon}"></i> <i class="fa {topics.lock-icon}"></i></strong>
{topics.title}
</span>
</h3>
</a>
</h3>
<small>
<span class="topic-stats">
[[category:posts]]
@ -75,9 +77,9 @@
<!-- ENDIF topics.unreplied -->
</span>
</small>
</div>
</div>
</div>
</li>
<!-- END topics -->
</ul>

@ -13,7 +13,8 @@
<div class="row">
<div class="col-md-12 user-favourite-posts">
<!-- BEGIN posts -->
<div class="topic-row img-thumbnail clearfix">
<div class="topic-row panel panel-default clearfix">
<div class="panel-body">
<a href="../../user/{posts.userslug}">
<img title="{posts.username}" class="img-rounded user-img" src="{posts.picture}">
</a>
@ -34,7 +35,7 @@
</span>
</div>
</div>
<br/>
</div>
<!-- END posts -->
</div>
</div>

@ -1,22 +1,31 @@
<div class="motd{motd_class}">
<div class="panel motd{motd_class}">
{motd}
</div>
<div class="row home" itemscope itemtype="http://www.schema.org/ItemList">
<!-- BEGIN categories -->
<div class="{categories.class}">
<!-- IF categories.link -->
<a href="{categories.link}" itemprop="url" target="_blank">
<!-- ELSE -->
<a href="{relative_path}/category/{categories.slug}" itemprop="url">
<!-- ENDIF categories.link -->
<meta itemprop="name" content="{categories.name}">
<h4>
<!-- IF !categories.link -->
<span class="badge {categories.badgeclass}">{categories.topic_count} </span>
<!-- ENDIF !categories.link -->
<!-- IF categories.link -->
<a href="{categories.link}" itemprop="url" target="_blank">
<!-- ELSE -->
<a href="{relative_path}/category/{categories.slug}" itemprop="url">
<!-- ENDIF categories.link -->
{categories.name}
</a>
</h4>
<!-- IF categories.link -->
<a href="{categories.link}" itemprop="url" target="_blank">
<!-- ELSE -->
<a href="{relative_path}/category/{categories.slug}" itemprop="url">
<!-- ENDIF categories.link -->
<div class="icon" style="background: {categories.background}; color: {categories.color};">
<div id="category-{categories.cid}" class="category-slider-{categories.post_count}">
<div class="category-box"><i class="fa {categories.icon} fa-4x"></i></div>

@ -24,12 +24,20 @@
<ul id="topics-container">
<!-- BEGIN topics -->
<li class="category-item {topics.deleted-class}">
<div class="row">
<div class="col-md-12 col-xs-12 topic-row img-thumbnail">
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
<h3>
<a href="{relative_path}/topic/{topics.slug}">
<h3><span class="topic-title"><strong><i class="fa {topics.pin-icon}"></i> <i class="fa {topics.lock-icon}"></i></strong> {topics.title}</span></h3>
<span class="topic-title">
<strong>
<i class="fa {topics.pin-icon}"></i>
<i class="fa {topics.lock-icon}"></i>
</strong>
{topics.title}
</span>
</a>
</h3>
<small>
<span class="topic-stats">
posts
@ -68,7 +76,6 @@
</span>
</small>
</div>
</div>
</li>
<!-- END topics -->
</ul>

@ -23,7 +23,7 @@
<ul id="post-container" class="posts" data-tid="{topic_id}">
<!-- BEGIN posts -->
<li class="row post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-userslug="{posts.userslug}" data-index="{posts.index}" data-deleted="{posts.deleted}" itemscope itemtype="http://schema.org/Comment">
<li class="post-row infiniteloaded" data-pid="{posts.pid}" data-uid="{posts.uid}" data-username="{posts.username}" data-userslug="{posts.userslug}" data-index="{posts.index}" data-deleted="{posts.deleted}" itemscope itemtype="http://schema.org/Comment">
<a id="post_anchor_{posts.pid}" name="{posts.pid}"></a>
<meta itemprop="datePublished" content="{posts.relativeTime}">
@ -36,11 +36,10 @@
<span class="label label-danger">[[topic:banned]]</span>
<!-- ENDIF posts.user_banned -->
</a>
</div>
<div class="col-md-11">
<div class="post-block">
<div class="col-md-11 panel panel-default post-block">
<a class="main-post avatar" href="{relative_path}/user/{posts.userslug}">
<img itemprop="image" src="{posts.picture}" align="left" class="img-thumbnail" width=150 height=150 />
</a>
@ -136,7 +135,7 @@
<div style="clear:both;"></div>
</div>
</div>
</div>
<div style="clear:both;"></div>
</li>
<!-- IF @first -->

@ -19,11 +19,20 @@
<ul id="topics-container" data-next-start="{nextStart}">
<!-- BEGIN topics -->
<li class="category-item {topics.deleted-class}">
<div class="row">
<div class="col-md-12 topic-row">
<div class="col-md-12 col-xs-12 panel panel-default topic-row">
<h3>
<a href="{relative_path}/topic/{topics.slug}">
<h3><span class="topic-title"><strong><i class="fa {topics.pin-icon}"></i> <i class="fa {topics.lock-icon}"></i></strong> {topics.title}</span></h3>
<span class="topic-title">
<strong>
<i class="fa {topics.pin-icon}"></i>
<i class="fa {topics.lock-icon}"></i>
</strong>
{topics.title}
</span>
</a>
</h3>
<small>
<span class="topic-stats">
posts
@ -62,7 +71,6 @@
</span>
</small>
</div>
</div>
</li>
<!-- END topics -->
</ul>

@ -126,6 +126,60 @@ var db = require('./database'),
});
};
Posts.getPostsByPids = function(pids, callback) {
var keys = [];
for(var x=0, numPids=pids.length; x<numPids; ++x) {
keys.push('post:' + pids[x]);
}
db.getObjects(keys, function(err, data) {
if(err) {
return callback(err);
}
async.map(data, function(postData, next) {
if(!postData) {
return next(null);
}
postData.relativeTime = utils.toISOString(postData.timestamp);
postData.relativeEditTime = parseInt(postData.edited, 10) !== 0 ? utils.toISOString(postData.edited) : '';
postTools.parse(postData.content, function(err, content) {
if(err) {
return next(err);
}
postData.content = content;
next(null, postData);
});
}, callback);
});
};
Posts.getPostsByUid = function(callerUid, uid, start, end, callback) {
user.getPostIds(uid, start, end, function(err, pids) {
if(err) {
return callback(err);
}
async.filter(pids, function(pid, next) {
postTools.privileges(pid, callerUid, function(err, privileges) {
next(privileges.read);
});
}, function(pids) {
if (!(pids && pids.length)) {
return callback(null, []);
}
Posts.getPostSummaryByPids(pids, false, callback);
});
});
}
Posts.addUserInfoToPost = function(post, callback) {
user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) {
if (err) {
@ -310,39 +364,6 @@ var db = require('./database'),
db.setObject('post:' + pid, data, callback);
};
Posts.getPostsByPids = function(pids, callback) {
var keys = [];
for(var x=0, numPids=pids.length; x<numPids; x++) {
keys.push('post:' + pids[x]);
}
db.getObjects(keys, function(err, data) {
if(err) {
return callback(err);
}
async.map(data, function(postData, next) {
if(!postData) {
return next(null);
}
postData.relativeTime = utils.toISOString(postData.timestamp);
postData.relativeEditTime = parseInt(postData.edited, 10) !== 0 ? utils.toISOString(postData.edited) : '';
postTools.parse(postData.content, function(err, content) {
if(err) {
return next(err);
}
postData.content = content;
next(null, postData);
});
}, callback);
});
}
Posts.getCidByPid = function(pid, callback) {
Posts.getPostField(pid, 'tid', function(err, tid) {
if(err) {
@ -418,40 +439,6 @@ var db = require('./database'),
});
}
Posts.getPostsByUid = function(uid, start, end, callback) {
user.getPostIds(uid, start, end, function(err, pids) {
if(err) {
return callback(err);
}
async.filter(pids, function(pid, next) {
postTools.privileges(pid, 0, function(err, privileges) {
next(privileges.read);
});
}, function(pids) {
if (pids && pids.length) {
plugins.fireHook('filter:post.getTopic', pids, function(err, posts) {
if(err) {
return callback(err);
}
if (posts && posts.length) {
Posts.getPostsByPids(pids, function(err, posts) {
plugins.fireHook('action:post.gotTopic', posts);
callback(null, posts);
});
} else {
callback(null, []);
}
});
} else {
callback(null, []);
}
});
});
}
Posts.reIndexPids = function(pids, callback) {
function reIndex(pid, callback) {
@ -478,16 +465,11 @@ var db = require('./database'),
Posts.getFavourites = function(uid, callback) {
db.getSortedSetRevRange('uid:' + uid + ':favourites', 0, -1, function(err, pids) {
if (err)
return callback(err, null);
Posts.getPostSummaryByPids(pids, false, function(err, posts) {
if (err)
if (err) {
return callback(err, null);
}
callback(null, posts);
});
Posts.getPostSummaryByPids(pids, false, callback);
});
}

@ -68,39 +68,44 @@ var path = require('path'),
async.each(data.categories, iterator, function (err) {
// Assemble the MOTD
var motdString;
var motdString,
assemble = function() {
data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none';
data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default');
data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : '';
data.motd = require('marked')(motdString);
res.json(data);
};
if (!meta.config.motd) {
// Construct default MOTD
translator.mget(['global:motd.welcome', 'global:motd.get', 'global:motd.fork', 'global:motd.like', 'global:motd.follow'], function(err, strings) {
motdString = '\n\n# NodeBB \n<small><span>v' + pkg.version + '</span></small>\n\n' + strings[0] +
'<div class="btn-group">\
translator.translate('\n\n# NodeBB \n<small><span>v' + pkg.version + '</span></small>\n\n[[global:motd.welcome]]\
<div class="btn-group">\
<a target="_blank" href="https://www.nodebb.org" class="btn btn-default btn-lg">\
<i class="fa fa-comment"></i>\
<span class="hidden-mobile">&nbsp;' + strings[1] + '</span>\
<span class="hidden-mobile">&nbsp;[[global:motd.get]]</span>\
</a>\
<a target="_blank" href="https://github.com/designcreateplay/NodeBB" class="btn btn-default btn-lg hidden-mobile">\
<i class="fa fa-github"></i>\
<span class="hidden-mobile">&nbsp;' + strings[2] + '</span>\
<span class="hidden-mobile">&nbsp;[[global:motd.fork]]</span>\
</a>\
<a target="_blank" href="https://facebook.com/NodeBB" class="btn btn-default btn-lg">\
<i class="fa fa-facebook"></i>\
<span class="hidden-mobile">&nbsp;' + strings[3] + '</span>\
<span class="hidden-mobile">&nbsp;[[global:motd.like]]</span>\
</a>\
<a target="_blank" href="https://twitter.com/NodeBB" class="btn btn-default btn-lg">\
<i class="fa fa-twitter"></i>\
<span class="hidden-mobile">&nbsp;' + strings[4] + '</span>\
<span class="hidden-mobile">&nbsp;[[global:motd.follow]]</span>\
</a>\
</div>';
</div>\
', function(motd) {
motdString = motd;
assemble();
});
} else {
motdString = meta.config.motd;
assemble();
}
data.motd_class = (parseInt(meta.config.show_motd, 10) === 1 || meta.config.show_motd === undefined) ? '' : ' none';
data.motd_class += (meta.config.motd && meta.config.motd.length > 0 ? '' : ' default');
data.motd_class += meta.config.motd_class ? ' ' + meta.config.motd_class : '';
data.motd = require('marked')(motdString);
res.json(data);
});
});
});

@ -407,9 +407,15 @@ var fs = require('fs'),
var callerUID = req.user ? req.user.uid : '0';
getUserDataByUserSlug(req.params.userslug, callerUID, function (userData) {
if (userData) {
if(!userData) {
return res.json(404, {
error: 'User not found!'
});
}
user.isFollowing(callerUID, userData.theirid, function (isFollowing) {
posts.getPostsByUid(userData.theirid, 0, 9, function (err, posts) {
posts.getPostsByUid(callerUID, userData.theirid, 0, 9, function (err, posts) {
if(err) {
return next(err);
@ -424,6 +430,7 @@ var fs = require('fs'),
if (!userData.profileviews) {
userData.profileviews = 1;
}
if (parseInt(callerUID, 10) !== parseInt(userData.uid, 10)) {
user.incrementUserFieldBy(userData.uid, 'profileviews', 1);
}
@ -434,11 +441,7 @@ var fs = require('fs'),
});
});
});
} else {
res.json(404, {
error: 'User not found!'
});
}
});
});

Loading…
Cancel
Save