mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-06-16 22:41:36 +02:00
Merge branch 'master' of github.com:designcreateplay/NodeBB
This commit is contained in:
@@ -496,8 +496,10 @@ var socket,
|
||||
} else {
|
||||
if (allowGuestSearching) {
|
||||
$('#search-button').removeClass("hide").show();
|
||||
$('#mobile-search-button').removeClass("hide").show();
|
||||
} else {
|
||||
$('#search-button').addClass("hide").hide();
|
||||
$('#mobile-search-button').addClass("hide").hide();
|
||||
}
|
||||
|
||||
$('.nodebb-loggedin').hide();
|
||||
|
||||
@@ -7,6 +7,7 @@ define(['taskbar', 'string'], function(taskbar, S) {
|
||||
var chatsToggleEl = $('#chat_dropdown'),
|
||||
chatsListEl = $('#chat-list'),
|
||||
chatDropdownEl = chatsToggleEl.parent();
|
||||
|
||||
chatsToggleEl.on('click', function() {
|
||||
if (chatDropdownEl.hasClass('open')) {
|
||||
return;
|
||||
@@ -43,27 +44,29 @@ define(['taskbar', 'string'], function(taskbar, S) {
|
||||
});
|
||||
|
||||
socket.on('event:chats.receive', function(data) {
|
||||
require(['chat'], function(chat) {
|
||||
if (chat.modalExists(data.fromuid)) {
|
||||
var modal = chat.getModal(data.fromuid);
|
||||
chat.appendChatMessage(modal, data.message, data.timestamp);
|
||||
|
||||
if (modal.is(":visible")) {
|
||||
chat.load(modal.attr('UUID'));
|
||||
} else {
|
||||
chat.toggleNew(modal.attr('UUID'), true);
|
||||
}
|
||||
if (module.modalExists(data.fromuid)) {
|
||||
var modal = module.getModal(data.fromuid);
|
||||
module.appendChatMessage(modal, data.message, data.timestamp);
|
||||
|
||||
if (!modal.is(":visible") || !app.isFocused) {
|
||||
app.alternatingTitle(data.username + ' has messaged you');
|
||||
}
|
||||
if (modal.is(":visible")) {
|
||||
module.bringModalToTop(modal);
|
||||
checkOnlineStatus(modal);
|
||||
taskbar.updateActive(modal.attr('UUID'));
|
||||
scrollToBottom(modal.find('#chat-content'));
|
||||
} else {
|
||||
chat.createModal(data.username, data.fromuid, function(modal) {
|
||||
chat.toggleNew(modal.attr('UUID'), true);
|
||||
app.alternatingTitle(data.username + ' has messaged you');
|
||||
});
|
||||
module.toggleNew(modal.attr('UUID'), true);
|
||||
}
|
||||
});
|
||||
|
||||
if (!modal.is(":visible") || !app.isFocused) {
|
||||
app.alternatingTitle(data.username + ' has messaged you');
|
||||
}
|
||||
} else {
|
||||
module.createModal(data.username, data.fromuid, function(modal) {
|
||||
module.toggleNew(modal.attr('UUID'), true);
|
||||
app.alternatingTitle(data.username + ' has messaged you');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -54,23 +54,24 @@
|
||||
|
||||
<div class="navbar-collapse collapse navbar-ex1-collapse">
|
||||
<ul id="main-nav" class="nav navbar-nav">
|
||||
|
||||
<li>
|
||||
<a href="{relative_path}/recent"><i class="fa fa-fw fa-clock-o" title="[[global:header.recent]]"></i><span class="visible-xs-inline"> Recent Topics</span></a>
|
||||
<a href="{relative_path}/recent"><i class="fa fa-fw fa-clock-o" title="[[global:header.recent]]"></i><span class="visible-xs-inline"> [[global:header.recent]]</span></a>
|
||||
</li>
|
||||
<li class="nodebb-loggedin">
|
||||
<a href="{relative_path}/unread"><i id="unread-count" class="fa fa-fw fa-inbox" data-content="0" title="[[global:header.unread]]"></i><span class="visible-xs-inline"> Unread Topics</span></a>
|
||||
<a href="{relative_path}/unread"><i id="unread-count" class="fa fa-fw fa-inbox" data-content="0" title="[[global:header.unread]]"></i><span class="visible-xs-inline"> [[global:header.unread]]</span></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{relative_path}/users"><i class="fa fa-fw fa-users" title="[[global:header.users]]"></i><span class="visible-xs-inline"> Users</span></a>
|
||||
<a href="{relative_path}/users"><i class="fa fa-fw fa-users" title="[[global:header.users]]"></i><span class="visible-xs-inline"> [[global:header.users]]</span></a>
|
||||
</li>
|
||||
<li class="{adminDisplay}">
|
||||
<a href="{relative_path}/admin"><i class="fa fa-fw fa-cogs" title="[[global:header.admin]]"></i><span class="visible-xs-inline"> Admin Panel</span></a>
|
||||
<a href="{relative_path}/admin"><i class="fa fa-fw fa-cogs" title="[[global:header.admin]]"></i><span class="visible-xs-inline"> [[global:header.admin]]</span></a>
|
||||
</li>
|
||||
<!-- IF allowGuestSearching -->
|
||||
|
||||
<li class="visible-xs">
|
||||
<a href="{relative_path}/search">[[global:header.search]] Search</a>
|
||||
<a id="mobile-search-button" href="{relative_path}/search"><i class="fa fa-search" title="[[global:header.search]]"></i><span class="visible-xs-inline"> [[global:header.search]]</span></a>
|
||||
</li>
|
||||
<!-- ENDIF allowGuestSearching -->
|
||||
|
||||
<!-- BEGIN navigation -->
|
||||
<li class="{navigation.class}">
|
||||
<a href="{relative_path}{navigation.route}" title="{navigation.title}">
|
||||
@@ -147,6 +148,7 @@
|
||||
</div>
|
||||
</form>
|
||||
</li>
|
||||
|
||||
<li class="hidden-xs">
|
||||
<a id="search-button" class="hide"><i class="fa fa-search"></i></a>
|
||||
</li>
|
||||
|
||||
@@ -741,17 +741,44 @@
|
||||
|
||||
module.getListRange = function(key, start, stop, callback) {
|
||||
|
||||
if(stop === -1) {
|
||||
// mongo doesnt allow -1 as the count argument in slice
|
||||
// pass in a large value to retrieve the whole array
|
||||
stop = Math.pow(2, 31) - 2;
|
||||
var skip = start,
|
||||
limit = stop - start + 1,
|
||||
splice = false;
|
||||
|
||||
if((start < 0 && stop >= 0) || (start >= 0 && stop < 0)) {
|
||||
skip = 0;
|
||||
limit = Math.pow(2, 31) - 2;
|
||||
splice = true;
|
||||
} else if (start > stop) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
db.collection('objects').findOne({_key:key}, { array: { $slice: [start, stop - start + 1] }}, function(err, data) {
|
||||
db.collection('objects').findOne({_key:key}, { array: { $slice: [skip, limit] }}, function(err, data) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if(data && data.array) {
|
||||
if(splice) {
|
||||
|
||||
if(start < 0) {
|
||||
start = data.array.length - Math.abs(start);
|
||||
}
|
||||
|
||||
if(stop < 0) {
|
||||
stop = data.array.length - Math.abs(stop);
|
||||
}
|
||||
|
||||
if(start > stop) {
|
||||
return callback(null, []);
|
||||
}
|
||||
|
||||
var howMany = stop - start + 1;
|
||||
if(start !== 0 || howMany !== data.array.length) {
|
||||
data.array = data.array.splice(start, howMany);
|
||||
}
|
||||
}
|
||||
|
||||
callback(null, data.array);
|
||||
} else {
|
||||
callback(null, []);
|
||||
|
||||
@@ -160,26 +160,15 @@
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
data = data.split("\r\n");
|
||||
var lines = data.toString().split("\r\n").sort();
|
||||
var redisData = {};
|
||||
|
||||
for (var i in data) {
|
||||
|
||||
if (data[i].indexOf(':') == -1 || !data[i])
|
||||
continue;
|
||||
|
||||
try {
|
||||
data[i] = data[i].replace(/:/, "\":\"");
|
||||
var json = "{\"" + data[i] + "\"}";
|
||||
|
||||
var jsonObject = JSON.parse(json);
|
||||
for (var key in jsonObject) {
|
||||
redisData[key] = jsonObject[key];
|
||||
}
|
||||
} catch (err) {
|
||||
winston.warn('can\'t parse redis status variable, ignoring', i, data[i], err);
|
||||
lines.forEach(function (line) {
|
||||
var parts = line.split(':');
|
||||
if (parts[1]) {
|
||||
redisData[parts[0]] = parts[1];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
redisData.raw = JSON.stringify(redisData, null, 4);
|
||||
redisData.redis = true;
|
||||
|
||||
|
||||
@@ -21,6 +21,10 @@ var fs = require('fs'),
|
||||
log(uid,'changed email from "' + oldEmail + '" to "' + newEmail +'"');
|
||||
}
|
||||
|
||||
events.logUsernameChange = function(uid, oldUsername, newUsername) {
|
||||
log(uid,'changed username from "' + oldUsername + '" to "' + newUsername +'"');
|
||||
}
|
||||
|
||||
events.logAdminLogin = function(uid) {
|
||||
log(uid, 'logged into admin panel');
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ var async = require('async'),
|
||||
path = require('path'),
|
||||
prompt = require('prompt'),
|
||||
winston = require('winston'),
|
||||
reds = require('reds'),
|
||||
nconf = require('nconf'),
|
||||
|
||||
install = {
|
||||
@@ -474,11 +473,6 @@ var async = require('async'),
|
||||
file: path.join(__dirname, '..', 'config.json')
|
||||
});
|
||||
|
||||
/*var RDB = require('./redis');
|
||||
reds.createClient = function () {
|
||||
return reds.client || (reds.client = RDB);
|
||||
};*/
|
||||
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,6 +62,10 @@ var fs = require('fs'),
|
||||
},
|
||||
setOnEmpty: function (field, value, callback) {
|
||||
Meta.configs.get(field, function (err, curValue) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
if (!curValue) {
|
||||
Meta.configs.set(field, value, callback);
|
||||
} else {
|
||||
|
||||
@@ -258,6 +258,10 @@ var path = require('path'),
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
if(pids.length > 50) {
|
||||
pids = pids.splice(0, 50);
|
||||
}
|
||||
|
||||
posts.getPostSummaryByPids(pids, false, function (err, posts) {
|
||||
if (err){
|
||||
return callback(err, null);
|
||||
@@ -273,6 +277,10 @@ var path = require('path'),
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
if(tids.length > 50) {
|
||||
tids = tids.splice(0, 50);
|
||||
}
|
||||
|
||||
topics.getTopicsByTids(tids, 0, function (topics) {
|
||||
callback(null, topics);
|
||||
}, 0);
|
||||
|
||||
@@ -82,6 +82,7 @@ var DebugRoute = function(app) {
|
||||
app.get('/test', function(req, res) {
|
||||
res.send();
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -424,7 +424,7 @@ var fs = require('fs'),
|
||||
if (!userData.profileviews) {
|
||||
userData.profileviews = 1;
|
||||
}
|
||||
if (callerUID !== userData.uid) {
|
||||
if (parseInt(callerUID, 10) !== parseInt(userData.uid, 10)) {
|
||||
user.incrementUserFieldBy(userData.uid, 'profileviews', 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@ var topics = require('../topics'),
|
||||
SocketTopics = {};
|
||||
|
||||
SocketTopics.post = function(data, callback, sessionData) {
|
||||
var socket = sessionData.socket;
|
||||
|
||||
if (sessionData.uid < 1 && parseInt(meta.config.allowGuestPosting, 10) === 0) {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Post Unsuccessful',
|
||||
@@ -51,7 +53,7 @@ SocketTopics.post = function(data, callback, sessionData) {
|
||||
|
||||
module.parent.exports.emitTopicPostStats();
|
||||
|
||||
sessionData.socket.emit('event:alert', {
|
||||
socket.emit('event:alert', {
|
||||
title: 'Thank you for posting',
|
||||
message: 'You have successfully posted. Click here to view your post.',
|
||||
type: 'success',
|
||||
|
||||
@@ -285,7 +285,7 @@ var winston = require('winston'),
|
||||
}
|
||||
|
||||
ThreadTools.getLatestUndeletedPid = function(tid, callback) {
|
||||
db.getSortedSetRange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
|
||||
db.getSortedSetRevRange('tid:' + tid + ':posts', 0, -1, function(err, pids) {
|
||||
if(err) {
|
||||
return callback(err);
|
||||
}
|
||||
@@ -293,14 +293,9 @@ var winston = require('winston'),
|
||||
return callback(new Error('no-undeleted-pids-found'));
|
||||
}
|
||||
|
||||
pids.reverse();
|
||||
async.detectSeries(pids, function(pid, next) {
|
||||
posts.getPostField(pid, 'deleted', function(err, deleted) {
|
||||
if (parseInt(deleted, 10) === 0) {
|
||||
next(true);
|
||||
} else {
|
||||
next(false);
|
||||
}
|
||||
next(parseInt(deleted, 10) === 0);
|
||||
});
|
||||
}, function(pid) {
|
||||
if (pid) {
|
||||
|
||||
@@ -982,7 +982,7 @@ var async = require('async'),
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
posts.getPostFields(pid, ['pid', 'content', 'uid', 'timestamp'], function(err, postData) {
|
||||
posts.getPostFields(pid, ['pid', 'uid', 'timestamp'], function(err, postData) {
|
||||
if (err) {
|
||||
return callback(err, null);
|
||||
} else if(!postData) {
|
||||
@@ -994,26 +994,13 @@ var async = require('async'),
|
||||
return callback(err, null);
|
||||
}
|
||||
|
||||
var stripped = postData.content,
|
||||
timestamp = postData.timestamp,
|
||||
returnObj = {
|
||||
"pid": postData.pid,
|
||||
"username": userData.username || 'anonymous',
|
||||
"userslug": userData.userslug,
|
||||
"picture": userData.picture || gravatar.url('', {}, https = nconf.get('https')),
|
||||
"timestamp": timestamp
|
||||
};
|
||||
|
||||
if (postData.content) {
|
||||
stripped = postData.content.replace(/>.+\n\n/, '');
|
||||
postTools.parse(stripped, function(err, stripped) {
|
||||
returnObj.text = S(stripped).stripTags().s;
|
||||
callback(null, returnObj);
|
||||
});
|
||||
} else {
|
||||
returnObj.text = '';
|
||||
callback(null, returnObj);
|
||||
}
|
||||
callback(null, {
|
||||
pid: postData.pid,
|
||||
username: userData.username || 'anonymous',
|
||||
userslug: userData.userslug,
|
||||
picture: userData.picture || gravatar.url('', {}, https = nconf.get('https')),
|
||||
timestamp: postData.timestamp
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -312,6 +312,7 @@ var bcrypt = require('bcrypt'),
|
||||
db.searchRemove('user', uid, function() {
|
||||
db.searchIndex('user', data.username, uid);
|
||||
});
|
||||
events.logUsernameChange(uid, userData.username, data.username);
|
||||
}
|
||||
|
||||
if(userslug !== userData.userslug) {
|
||||
|
||||
Reference in New Issue
Block a user