template fixes closes #825

v1.18.x
Baris Soner Usakli 11 years ago
parent 12a5b6b4c6
commit 55d4a5fe3a

@ -68,10 +68,6 @@ define(['forum/accountheader'], function(header) {
app.openChat(username, theirid); 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.on('user.isOnline', Account.handleUserOnline);
socket.emit('user.isOnline', theirid, Account.handleUserOnline); socket.emit('user.isOnline', theirid, Account.handleUserOnline);

@ -155,8 +155,8 @@ define(['composer'], function(composer) {
replies += '<li data-pid="'+ posts[i].pid +'">' + 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 + '/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>' + '<strong><span>'+ posts[i].username + '</span></strong>' +
'<a href="' + RELATIVE_PATH + '/topic/' + posts[i].topicSlug + '#' + posts[i].pid + '">' +
'<p>' + posts[i].content + '</p>' + '<p>' + posts[i].content + '</p>' +
'</a>' + '</a>' +
'<span class="timeago pull-right" title="' + posts[i].relativeTime + '"></span>' + '<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) { $('#post-container').on('click', '.chat', function(e) {
var username = $(this).parents('li.row').attr('data-username'); var post = $(this).parents('li.post-row'),
var touid = $(this).parents('li.row').attr('data-uid'); username = post.attr('data-username'),
touid = post.attr('data-uid');
app.openChat(username, touid); app.openChat(username, touid);
$(this).parents('.btn-group').find('.dropdown-toggle').click(); $(this).parents('.btn-group').find('.dropdown-toggle').click();
return false; return false;

@ -108,15 +108,31 @@
</div> </div>
<div class="col-md-6 user-recent-posts"> <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 --> <!-- BEGIN posts -->
<div class="topic-row img-thumbnail clearfix" topic-url="topic/{posts.tid}/#{posts.pid}"> <div class="clearfix">
<span>{posts.content}</span> <p>{posts.content}</p>
<span class="pull-right timeago" title="{posts.relativeTime}"></span> <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> </div>
<hr/>
<!-- END posts --> <!-- END posts -->
</div> </div>
</div> </div>
</div>
</div>
<br/> <br/>
<div id="user-action-alert" class="alert alert-success hide"></div> <div id="user-action-alert" class="alert alert-success hide"></div>

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

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

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

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

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

@ -19,11 +19,20 @@
<ul id="topics-container" data-next-start="{nextStart}"> <ul id="topics-container" data-next-start="{nextStart}">
<!-- BEGIN topics --> <!-- BEGIN topics -->
<li class="category-item {topics.deleted-class}"> <li class="category-item {topics.deleted-class}">
<div class="row"> <div class="col-md-12 col-xs-12 panel panel-default topic-row">
<div class="col-md-12 topic-row">
<h3>
<a href="{relative_path}/topic/{topics.slug}"> <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> </a>
</h3>
<small> <small>
<span class="topic-stats"> <span class="topic-stats">
posts posts
@ -62,7 +71,6 @@
</span> </span>
</small> </small>
</div> </div>
</div>
</li> </li>
<!-- END topics --> <!-- END topics -->
</ul> </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) { Posts.addUserInfoToPost = function(post, callback) {
user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) { user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) {
if (err) { if (err) {
@ -310,39 +364,6 @@ var db = require('./database'),
db.setObject('post:' + pid, data, callback); 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.getCidByPid = function(pid, callback) {
Posts.getPostField(pid, 'tid', function(err, tid) { Posts.getPostField(pid, 'tid', function(err, tid) {
if(err) { 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) { Posts.reIndexPids = function(pids, callback) {
function reIndex(pid, callback) { function reIndex(pid, callback) {
@ -478,16 +465,11 @@ var db = require('./database'),
Posts.getFavourites = function(uid, callback) { Posts.getFavourites = function(uid, callback) {
db.getSortedSetRevRange('uid:' + uid + ':favourites', 0, -1, function(err, pids) { db.getSortedSetRevRange('uid:' + uid + ':favourites', 0, -1, function(err, pids) {
if (err) if (err) {
return callback(err, null);
Posts.getPostSummaryByPids(pids, false, function(err, posts) {
if (err)
return callback(err, null); return callback(err, null);
}
callback(null, posts); Posts.getPostSummaryByPids(pids, false, callback);
});
}); });
} }

@ -407,9 +407,15 @@ var fs = require('fs'),
var callerUID = req.user ? req.user.uid : '0'; var callerUID = req.user ? req.user.uid : '0';
getUserDataByUserSlug(req.params.userslug, callerUID, function (userData) { 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) { 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) { if(err) {
return next(err); return next(err);
@ -424,6 +430,7 @@ var fs = require('fs'),
if (!userData.profileviews) { if (!userData.profileviews) {
userData.profileviews = 1; userData.profileviews = 1;
} }
if (parseInt(callerUID, 10) !== parseInt(userData.uid, 10)) { if (parseInt(callerUID, 10) !== parseInt(userData.uid, 10)) {
user.incrementUserFieldBy(userData.uid, 'profileviews', 1); 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