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

v1.18.x
Julian Lam
commit 521586f08f

@ -275,7 +275,7 @@ var socket,
if (active) {
jQuery('#main-nav li a').each(function() {
var href = this.getAttribute('href');
if (active == "sort-posts" || active == "sort-reputation" || active == "search" || active== "latest")
if (active == "sort-posts" || active == "sort-reputation" || active == "search" || active == "latest" || active == "online")
active = 'users';
if (href && href.match(active)) {
jQuery(this.parentNode).addClass('active');
@ -286,6 +286,8 @@ var socket,
$('span.timeago').timeago();
setTimeout(function() {
window.scrollTo(0, 1); // rehide address bar on mobile after page load completes.
}, 100);
@ -432,12 +434,14 @@ var socket,
ajaxify.go("search/" + input.val(), null, "search");
input.val('');
return false;
})
});
});
showWelcomeMessage = location.href.indexOf('loggedin') !== -1;
loadConfig();
}());

@ -94,6 +94,11 @@
right_menu.appendChild(registerEl);
right_menu.appendChild(loginEl);
}
$('#main-nav a,#right-menu a').off('click').on('click', function() {
if($('.navbar .navbar-collapse').hasClass('in'))
$('.navbar-header button').click();
});
});
// Notifications dropdown

@ -12,6 +12,13 @@
$('#search-form input').val(searchQuery);
$('#mobile-search-form').off('submit').on('submit', function() {
var input = $(this).find('input');
ajaxify.go("search/" + input.val(), null, "search");
input.val('');
return false;
});
});
})();

@ -74,7 +74,12 @@
});
socket.on('api:user.isOnline', function(data) {
if(active == 'online' && !loadingMoreUsers) {
$('#users-container').empty();
startLoading('users:online', 0);
}
});
function onUsersLoaded(users) {
var html = templates.prepare(templates['users'].blocks['users']).parse({
@ -91,24 +96,32 @@
set = 'users:postcount';
} else if (active === 'sort-reputation') {
set = 'users:reputation';
} else if (active === 'online') {
set = 'users:online';
}
if (set) {
loadingMoreUsers = true;
socket.emit('api:users.loadMore', {
set: set,
after: $('#users-container').children().length
}, function(data) {
if (data.users.length) {
onUsersLoaded(data.users);
} else {
$('#load-more-users-btn').addClass('disabled');
}
loadingMoreUsers = false;
});
startLoading(set, $('#users-container').children().length);
}
}
function startLoading(set, after) {
loadingMoreUsers = true;
socket.emit('api:users.loadMore', {
set: set,
after: after
}, function(data) {
if (data.users.length) {
onUsersLoaded(data.users);
$('#load-more-users-btn').removeClass('disabled');
} else {
$('#load-more-users-btn').addClass('disabled');
}
loadingMoreUsers = false;
});
}
$('#load-more-users-btn').on('click', loadMoreUsers);
$(window).off('scroll').on('scroll', function() {

@ -43,9 +43,9 @@
<li>
<a href="/users">Users</a>
</li>
<!--Enable when /search form is completed <li class="visible-xs">
<li class="visible-xs">
<a href="/search">Search</a>
</li>-->
</li>
<li>
<a href="/"></a>
</li>

@ -3,8 +3,18 @@
<li class="active">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="Search" name="query" value="">
</div>
<button type="submit" class="btn btn-default hide">Search</button>
</div>
</form>
<div class="category search">
<div class="">
<div class="{show_results}">
<ul id="topics-container" data-search-query="{search_query}">
<h3>Topics</h3>
<div class="alert alert-info {show_no_topics}">No topics found!</div>

@ -3,6 +3,7 @@
<li class=''><a href='/users/latest'>Latest Users</a></li>
<li class=''><a href='/users/sort-posts'>Top Posters</a></li>
<li class=''><a href='/users/sort-reputation'>Most Reputation</a></li>
<li class=''><a href='/users/online'>Online</a></li>
<li class=''><a href='/users/search'>Search</a></li>
</ul>

@ -137,7 +137,7 @@ var fs = require('fs'),
hookList = this.loadedHooks[hook];
if (hookList && Array.isArray(hookList)) {
if (global.env === 'development') winston.info('[plugins] Firing hook: \'' + hook + '\'');
//if (global.env === 'development') winston.info('[plugins] Firing hook: \'' + hook + '\'');
var hookType = hook.split(':')[0];
switch (hookType) {
case 'filter':

@ -70,7 +70,7 @@ var RDB = require('./redis.js'),
Posts.getPostFields(pid, ['pid', 'tid', 'content', 'uid', 'timestamp', 'deleted'], function(postData) {
if (postData.deleted === '1') return callback(null);
else {
postData.relativeTime = new Date(parseInt(postData.timestamp, 10)).toISOString();
postData.relativeTime = new Date(parseInt(postData.timestamp || 0, 10)).toISOString();
next(null, postData);
}
});

@ -186,6 +186,7 @@ var user = require('./../user.js'),
return res.json({
show_no_topics: 'hide',
show_no_posts: 'hide',
show_results: 'hide',
search_query: '',
posts: [],
topics: []
@ -235,6 +236,7 @@ var user = require('./../user.js'),
return res.json({
show_no_topics: results[1].length ? 'hide' : '',
show_no_posts: results[0].length ? 'hide' : '',
show_results: '',
search_query: req.params.term,
posts: results[0],
topics: results[1]

@ -25,7 +25,6 @@ var user = require('./../user.js'),
});
}
});
});
app.get('/users', function(req, res) {
@ -64,6 +63,15 @@ var user = require('./../user.js'),
});
});
app.get('/users/online', function(req, res) {
app.build_header({
req: req,
res: res
}, function(err, header) {
res.send(header + app.create_route("users/online", "users") + templates['footer']);
});
});
app.get('/users/search', function(req, res) {
app.build_header({
req: req,
@ -136,7 +144,7 @@ var user = require('./../user.js'),
app.post('/user/uploadpicture', function(req, res) {
if (!req.user)
return res.redirect('/403');
var uploadSize = meta.config.maximumProfileImageSize || 256;
if (req.files.userPhoto.size > uploadSize * 1024) {
@ -342,7 +350,7 @@ var user = require('./../user.js'),
return;
}
user.getUserFields(uid, ['username', 'userslug', 'showemail'], function(err, userData) {
if (err)
return next(err);
@ -436,6 +444,7 @@ var user = require('./../user.js'),
app.get('/api/users/sort-posts', getUsersSortedByPosts);
app.get('/api/users/sort-reputation', getUsersSortedByReputation);
app.get('/api/users/latest', getUsersSortedByJoinDate);
app.get('/api/users/online', getOnlineUsers);
app.get('/api/users/search', getUsersForSearch);
@ -469,6 +478,16 @@ var user = require('./../user.js'),
});
}
function getOnlineUsers(req, res) {
user.getUsers('users:online', 0, 49, function(err, data) {
res.json({
search_display: 'none',
loadmore_display: 'block',
users: data
});
});
}
function getUsersForSearch(req, res) {
res.json({
search_display: 'block',

@ -476,6 +476,8 @@ var express = require('express'),
});
app.get('/search', function (req, res) {
if (!req.user)
return res.redirect('/403');
app.build_header({
req: req,
res: res
@ -485,6 +487,8 @@ var express = require('express'),
});
app.get('/search/:term', function (req, res) {
if (!req.user)
return res.redirect('/403');
app.build_header({
req: req,
res: res

@ -23,6 +23,7 @@ var SocketIO = require('socket.io').listen(global.server, {
client: RDB,
ttl: 60 * 60 * 24 * 14
}),
nconf = require('nconf'),
socketCookieParser = express.cookieParser(nconf.get('secret')),
admin = {
'categories': require('./admin/categories.js'),
@ -53,14 +54,17 @@ var SocketIO = require('socket.io').listen(global.server, {
userSockets[uid].push(socket);
if (uid) {
socket.join('uid_' + uid);
io.sockets. in ('global').emit('api:user.isOnline', isUserOnline(uid));
user.getUserField(uid, 'username', function(err, username) {
socket.emit('event:connect', {
status: 1,
username: username,
uid: uid
RDB.zadd('users:online', Date.now(), uid, function(err, data) {
socket.join('uid_' + uid);
io.sockets. in ('global').emit('api:user.isOnline', isUserOnline(uid));
user.getUserField(uid, 'username', function(err, username) {
socket.emit('event:connect', {
status: 1,
username: username,
uid: uid
});
});
});
}
@ -80,7 +84,9 @@ var SocketIO = require('socket.io').listen(global.server, {
delete users[sessionID];
delete userSockets[uid];
if (uid) {
io.sockets. in ('global').emit('api:user.isOnline', isUserOnline(uid));
RDB.zrem('users:online', uid, function(err, data) {
io.sockets. in ('global').emit('api:user.isOnline', isUserOnline(uid));
});
}
}
@ -100,7 +106,7 @@ var SocketIO = require('socket.io').listen(global.server, {
socket.on('api:get_all_rooms', function(data) {
socket.emit('api:get_all_rooms', io.sockets.manager.rooms);
})
});
function updateRoomBrowsingText(roomName) {

Loading…
Cancel
Save