mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-01-04 06:40:44 +01:00
Merge remote-tracking branch 'origin/master' into webserver.js-refactor
Conflicts: public/templates/account.tpl public/templates/accountposts.tpl public/templates/favourites.tpl public/templates/search.tpl
This commit is contained in:
@@ -9,7 +9,7 @@ define(['uploader'], function(uploader) {
|
||||
// Come back in 125ms if the config isn't ready yet
|
||||
if (!app.config) {
|
||||
setTimeout(function() {
|
||||
Settings.prepare();
|
||||
Settings.prepare(callback);
|
||||
}, 125);
|
||||
return;
|
||||
}
|
||||
|
||||
165
public/templates/account.tpl
Normal file
165
public/templates/account.tpl
Normal file
@@ -0,0 +1,165 @@
|
||||
|
||||
<div class="account-username-box" data-userslug="{userslug}">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="account">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5 account-block">
|
||||
|
||||
<div class="text-center account-picture-block panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div>
|
||||
<a href="{relative_path}/user/{userslug}"><img src="{picture}" class="user-profile-picture img-thumbnail"/></a>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div>
|
||||
<span>
|
||||
<i class="account-online-status fa fa-circle status offline" title="[[global:{status}]]"></i>
|
||||
<span class="account-username"> {username}</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- IF banned -->
|
||||
<div>
|
||||
<span class="label label-danger">[[user:banned]]</span>
|
||||
</div>
|
||||
<!-- ENDIF banned -->
|
||||
<div>
|
||||
<a id="chat-btn" href="#" class="btn btn-primary hide">[[user:chat]]</a>
|
||||
<a id="follow-btn" href="#" class="btn btn-success hide">[[user:follow]]</a>
|
||||
<a id="unfollow-btn" href="#" class="btn btn-warning hide">[[user:unfollow]]</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-center account-stats panel panel-default">
|
||||
<div class="panel-body">
|
||||
<div class="inline-block text-center">
|
||||
<div class="human-readable-number" title="{reputation}">{reputation}</div>
|
||||
<div class="account-bio-label">[[user:reputation]]</div>
|
||||
</div>
|
||||
|
||||
<div class="inline-block text-center">
|
||||
<div class="human-readable-number" title="{postcount}">{postcount}</div>
|
||||
<div class="account-bio-label">[[user:posts]]</div>
|
||||
</div>
|
||||
|
||||
<div class="inline-block text-center">
|
||||
<div class="human-readable-number" title="{profileviews}">{profileviews}</div>
|
||||
<div class="account-bio-label">[[user:profile_views]]</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
|
||||
<!-- IF email -->
|
||||
<span class="account-bio-label">[[user:email]]</span>
|
||||
<span class="account-bio-value"><i class="fa fa-eye-slash {emailClass}" title="[[user:email_hidden]]"></i> {email}</span>
|
||||
<!-- ENDIF email -->
|
||||
|
||||
<!-- IF fullname -->
|
||||
<span class="account-bio-label">[[user:fullname]]</span>
|
||||
<span class="account-bio-value">{fullname}</span>
|
||||
<!-- ENDIF fullname -->
|
||||
|
||||
<!-- IF websiteName -->
|
||||
<span class="account-bio-label">[[user:website]]</span>
|
||||
<span class="account-bio-value"><a href="{website}">{websiteName}</a></span>
|
||||
<!-- ENDIF websiteName -->
|
||||
|
||||
<!-- IF location -->
|
||||
<span class="account-bio-label">[[user:location]]</span>
|
||||
<span class="account-bio-value">{location}</span>
|
||||
<!-- ENDIF location -->
|
||||
|
||||
<!-- IF age -->
|
||||
<span class="account-bio-label">[[user:age]]</span>
|
||||
<span class="account-bio-value">{age}</span>
|
||||
<!-- ENDIF age -->
|
||||
|
||||
|
||||
<span class="account-bio-label">[[user:followers]]</span>
|
||||
<span class="human-readable-number account-bio-value" title="{followerCount}">{followerCount}</span>
|
||||
|
||||
<span class="account-bio-label">[[user:following]]</span>
|
||||
<span class="human-readable-number account-bio-value" title="{followingCount}">{followingCount}</span>
|
||||
|
||||
<span class="account-bio-label">[[user:joined]]</span>
|
||||
<span class="timeago account-bio-value" title="{joindate}"></span>
|
||||
|
||||
<span class="account-bio-label">[[user:lastonline]]</span>
|
||||
<span class="timeago account-bio-value" title="{lastonline}"></span>
|
||||
|
||||
<!-- IF !disableSignatures -->
|
||||
<!-- IF signature -->
|
||||
<hr/>
|
||||
<span class="account-bio-label">[[user:signature]]</span>
|
||||
<div class="post-signature">
|
||||
<span id='signature'>{signature}</span>
|
||||
</div>
|
||||
<!-- ENDIF signature -->
|
||||
<!-- ENDIF !disableSignatures -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IF ips.length -->
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">[[global:recentips]]</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<!-- BEGIN ips -->
|
||||
<div>{ips.ip}</div>
|
||||
<!-- END ips -->
|
||||
</div>
|
||||
</div>
|
||||
<!-- ENDIF ips.length -->
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-7 user-recent-posts">
|
||||
<div class="topic-row panel panel-default clearfix">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title">[[global:recentposts]]</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<!-- IF !posts.length -->
|
||||
<span>[[user:has_no_posts]]</span>
|
||||
<!-- ENDIF !posts.length -->
|
||||
<!-- BEGIN posts -->
|
||||
<div class="clearfix">
|
||||
<p>{posts.content}</p>
|
||||
<small>
|
||||
<span class="pull-right">
|
||||
<a href="../../topic/{posts.tid}/#{posts.pid}">[[global:posted]]</a>
|
||||
[[global:in]]
|
||||
<a href="../../category/{posts.category.slug}">
|
||||
<i class="fa {posts.category.icon}"></i> {posts.category.name}
|
||||
</a>
|
||||
<span class="timeago" title="{posts.relativeTime}"></span>
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
<hr/>
|
||||
<!-- END posts -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
<div id="user-action-alert" class="alert alert-success hide"></div>
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" template-variable="yourid" value="{yourid}" />
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
<input type="hidden" template-type="boolean" template-variable="isFollowing" value="{isFollowing}" />
|
||||
45
public/templates/accountposts.tpl
Normal file
45
public/templates/accountposts.tpl
Normal file
@@ -0,0 +1,45 @@
|
||||
<div class="account-username-box clearfix" data-userslug="{userslug}" data-uid="{uid}">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="favourites">
|
||||
|
||||
<!-- IF !posts.length -->
|
||||
<div class="alert alert-warning">[[user:has_no_posts]]</div>
|
||||
<!-- ENDIF !posts.length -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 user-favourite-posts" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN posts -->
|
||||
<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>
|
||||
|
||||
<a href="../../user/{posts.userslug}">
|
||||
<strong><span>{posts.username}</span></strong>
|
||||
</a>
|
||||
<p>{posts.content}</p>
|
||||
|
||||
<div>
|
||||
<small>
|
||||
<span class="pull-right">
|
||||
<a href="../../topic/{posts.topic.slug}#{posts.pid}">[[global:posted]]</a>
|
||||
[[global:in]]
|
||||
<a href="../../category/{posts.category.slug}">
|
||||
<i class="fa {posts.category.icon}"></i> {posts.category.name}
|
||||
</a>
|
||||
<span class="timeago" title="{posts.relativeTime}"></span>
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END posts -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" template-variable="yourid" value="{yourid}" />
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
45
public/templates/favourites.tpl
Normal file
45
public/templates/favourites.tpl
Normal file
@@ -0,0 +1,45 @@
|
||||
<div class="account-username-box clearfix" data-userslug="{userslug}">
|
||||
|
||||
</div>
|
||||
|
||||
<div class="favourites">
|
||||
|
||||
<!-- IF !posts.length -->
|
||||
<div class="alert alert-warning">[[topic:favourites.has_no_favourites]]</div>
|
||||
<!-- ENDIF !posts.length -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12 user-favourite-posts" data-nextstart="{nextStart}">
|
||||
<!-- BEGIN posts -->
|
||||
<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>
|
||||
|
||||
<a href="../../user/{posts.userslug}">
|
||||
<strong><span>{posts.username}</span></strong>
|
||||
</a>
|
||||
<div class="content">{posts.content}</div>
|
||||
|
||||
<div>
|
||||
<small>
|
||||
<span class="pull-right">
|
||||
<a href="../../topic/{posts.topic.slug}#{posts.pid}">[[global:posted]]</a>
|
||||
[[global:in]]
|
||||
<a href="../../category/{posts.category.slug}">
|
||||
<i class="fa {posts.category.icon}"></i> {posts.category.name}
|
||||
</a>
|
||||
<span class="timeago" title="{posts.relativeTime}"></span>
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END posts -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" template-variable="yourid" value="{yourid}" />
|
||||
<input type="hidden" template-variable="theirid" value="{theirid}" />
|
||||
88
public/templates/search.tpl
Normal file
88
public/templates/search.tpl
Normal file
@@ -0,0 +1,88 @@
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{relative_path}/">[[global:home]]</a></li>
|
||||
<li class="active">[[global:search]]</li>
|
||||
</ol>
|
||||
|
||||
|
||||
<form id="mobile-search-form" class="navbar-form navbar-right visible-xs" role="search" method="GET" action="">
|
||||
<div class="" id="search-fields">
|
||||
<div class="form-group">
|
||||
<input type="text" class="form-control" placeholder="[[global:search]]" name="query" value="">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default hide">[[global:search]]</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div class="search">
|
||||
<div class="{show_results} row">
|
||||
|
||||
<div id="topic-results" class="col-md-12" data-search-query="{search_query}">
|
||||
|
||||
<h3>[[topic:topics]]</h3>
|
||||
|
||||
<!-- IF topic_matches -->
|
||||
<small>{topic_matches} result(s) matching "{search_query}"</small>
|
||||
<!-- ENDIF topic_matches -->
|
||||
<div class="alert alert-info {show_no_topics}">[[topic:no_topics_found]]</div>
|
||||
|
||||
<!-- BEGIN topics -->
|
||||
<div class="topic-row panel panel-default clearfix">
|
||||
<div class="panel-body">
|
||||
|
||||
|
||||
<a href="../../topic/{topics.slug}" class="search-result-text">
|
||||
{topics.title}
|
||||
</a>
|
||||
|
||||
<div>
|
||||
<small>
|
||||
<span class="pull-right">
|
||||
<a href="../../user/{topics.userslug}"><img title="{topics.username}" class="img-rounded user-img" src="{topics.picture}"></a>
|
||||
<a href="../../topic/{topics.slug}"> [[global:posted]]</a>
|
||||
[[global:in]]
|
||||
<a href="../../category/{topics.category.slug}"><i class="fa {topics.category.icon}"></i> {topics.category.name}</a>
|
||||
<span class="timeago" title="{topics.relativeTime}"></span>
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END topics -->
|
||||
</div>
|
||||
|
||||
<div id="post-results" class="col-md-12" data-search-query="{search_query}">
|
||||
<h3>[[topic:posts]]</h3>
|
||||
|
||||
<!-- IF post_matches -->
|
||||
<small>{post_matches} result(s) matching "{search_query}"</small>
|
||||
<!-- ENDIF post_matches -->
|
||||
<div class="alert alert-info {show_no_posts}">[[tropic:no_posts_found]]</div>
|
||||
|
||||
<!-- BEGIN posts -->
|
||||
<div class="topic-row panel panel-default clearfix">
|
||||
<div class="panel-body">
|
||||
<a href="../../topic/{posts.topic.slug}#{posts.pid}" class="search-result-text">
|
||||
{posts.content}
|
||||
</a>
|
||||
|
||||
<div>
|
||||
<small>
|
||||
<span class="pull-right">
|
||||
<a href="../../user/{posts.userslug}">
|
||||
<img title="{posts.username}" class="img-rounded user-img" src="{posts.picture}">
|
||||
</a>
|
||||
<a href="../../topic/{posts.topic.slug}#{posts.pid}"> [[global:posted]]</a>
|
||||
[[global:in]]
|
||||
<a href="../../category/{posts.category.slug}">
|
||||
<i class="fa {posts.category.icon}"></i> {posts.category.name}
|
||||
</a>
|
||||
<span class="timeago" title="{posts.relativeTime}"></span>
|
||||
</span>
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- END posts -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
43
src/posts.js
43
src/posts.js
@@ -197,6 +197,35 @@ var db = require('./database'),
|
||||
});
|
||||
};
|
||||
|
||||
Posts.getRecentPosts = function(uid, start, stop, term, callback) {
|
||||
var terms = {
|
||||
day: 86400000,
|
||||
week: 604800000,
|
||||
month: 2592000000
|
||||
};
|
||||
|
||||
var since = terms.day;
|
||||
if (terms[term]) {
|
||||
since = terms[term];
|
||||
}
|
||||
|
||||
var count = parseInt(stop, 10) === -1 ? stop : stop - start + 1;
|
||||
|
||||
db.getSortedSetRevRangeByScore(['posts:pid', '+inf', Date.now() - since, 'LIMIT', start, count], function(err, pids) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
async.filter(pids, function(pid, next) {
|
||||
postTools.privileges(pid, uid, function(err, privileges) {
|
||||
next(!err && privileges.read);
|
||||
});
|
||||
}, function(pids) {
|
||||
Posts.getPostSummaryByPids(pids, true, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Posts.addUserInfoToPost = function(post, callback) {
|
||||
user.getUserFields(post.uid, ['username', 'userslug', 'reputation', 'postcount', 'picture', 'signature', 'banned'], function(err, userData) {
|
||||
if (err) {
|
||||
@@ -262,10 +291,10 @@ var db = require('./database'),
|
||||
|
||||
if (parseInt(postData.deleted, 10) === 1) {
|
||||
return callback(null);
|
||||
} else {
|
||||
postData.relativeTime = utils.toISOString(postData.timestamp);
|
||||
next(null, postData);
|
||||
}
|
||||
|
||||
postData.relativeTime = utils.toISOString(postData.timestamp);
|
||||
next(null, postData);
|
||||
});
|
||||
},
|
||||
function(postData, next) {
|
||||
@@ -281,11 +310,9 @@ var db = require('./database'),
|
||||
return callback(null);
|
||||
}
|
||||
categories.getCategoryFields(topicData.cid, ['name', 'icon', 'slug'], function(err, categoryData) {
|
||||
postData.categoryName = categoryData.name;
|
||||
postData.categoryIcon = categoryData.icon;
|
||||
postData.categorySlug = categoryData.slug;
|
||||
postData.title = validator.escape(topicData.title);
|
||||
postData.topicSlug = topicData.slug;
|
||||
postData.category = categoryData;
|
||||
topicData.title = validator.escape(topicData.title);
|
||||
postData.topic = topicData;
|
||||
next(null, postData);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user