-
Loading Categories
-
-
-
-
This topic will be moved to the category
+
+
+
+
+
+
+
Loading Categories
+
+
+
+
This topic will be moved to the category
+
+
+
-
diff --git a/public/templates/users.tpl b/public/templates/users.tpl
index 43d421a21b..ff6f2aaa72 100644
--- a/public/templates/users.tpl
+++ b/public/templates/users.tpl
@@ -1,7 +1,7 @@
- Latest Users
+ Latest Users
Top Posters
Most Reputation
Search
diff --git a/src/categories.js b/src/categories.js
index dab6475543..b5a0938e5b 100644
--- a/src/categories.js
+++ b/src/categories.js
@@ -15,6 +15,7 @@ var RDB = require('./redis.js'),
var category_name = categoryData.name,
category_slug = categoryData.slug,
+ disabled = categoryData.disabled || '0',
category_description = categoryData.description;
function getTopicIds(next) {
@@ -32,6 +33,7 @@ var RDB = require('./redis.js'),
var categoryData = {
'category_name' : category_name,
'category_description': category_description,
+ 'disabled': disabled,
'show_sidebar' : 'show',
'show_topic_button': 'inline-block',
'no_topics_message': 'hidden',
diff --git a/src/install.js b/src/install.js
index 6431b0a689..22275068bc 100644
--- a/src/install.js
+++ b/src/install.js
@@ -75,8 +75,7 @@ var async = require('async'),
server_conf = config,
client_conf = {
socket: {
- address: protocol + '//' + host,
- port: config.port
+ address: protocol + '//' + host + (config.use_port ? ':' + config.port : '')
},
api_url: protocol + '//' + host + (config.use_port ? ':' + config.port : '') + relative_path + '/api/',
relative_path: relative_path
diff --git a/src/plugins.js b/src/plugins.js
index 4a4772ff57..a7e66421d9 100644
--- a/src/plugins.js
+++ b/src/plugins.js
@@ -18,17 +18,19 @@ var fs = require('fs'),
RDB.smembers('plugins:active', next);
},
function(plugins, next) {
- async.each(plugins, function(plugin) {
- // TODO: Update this check to also check node_modules
- var pluginPath = path.join(__dirname, '../plugins/', plugin),
- modulePath = path.join(__dirname, '../node_modules/', plugin);
- if (fs.existsSync(pluginPath)) _self.loadPlugin(pluginPath, next);
- else if (fs.existsSync(modulePath)) _self.loadPlugin(modulePath, next);
- else {
- if (global.env === 'development') winston.info('[plugins] Plugin \'' + plugin + '\' not found');
- next(); // Ignore this plugin silently
- }
- }, next);
+ if (plugins && Array.isArray(plugins) && plugins.length > 0) {
+ async.each(plugins, function(plugin) {
+ // TODO: Update this check to also check node_modules
+ var pluginPath = path.join(__dirname, '../plugins/', plugin),
+ modulePath = path.join(__dirname, '../node_modules/', plugin);
+ if (fs.existsSync(pluginPath)) _self.loadPlugin(pluginPath, next);
+ else if (fs.existsSync(modulePath)) _self.loadPlugin(modulePath, next);
+ else {
+ if (global.env === 'development') winston.info('[plugins] Plugin \'' + plugin + '\' not found');
+ next(); // Ignore this plugin silently
+ }
+ }, next);
+ } else next();
}
], function(err) {
if (err) {
diff --git a/src/postTools.js b/src/postTools.js
index edef132e4c..d8e97cc66f 100644
--- a/src/postTools.js
+++ b/src/postTools.js
@@ -55,7 +55,7 @@ var RDB = require('./redis.js'),
});
}
- PostTools.edit = function(uid, pid, title, content) {
+ PostTools.edit = function(uid, pid, title, content, images) {
var success = function() {
posts.setPostField(pid, 'content', content);
posts.setPostField(pid, 'edited', Date.now());
@@ -66,6 +66,11 @@ var RDB = require('./redis.js'),
});
async.parallel([
+ function(next) {
+ posts.uploadPostImages(pid, images, function(err, uploadedImages) {
+ next(err, uploadedImages);
+ });
+ },
function(next) {
posts.getPostField(pid, 'tid', function(tid) {
PostTools.isMain(pid, tid, function(isMainPost) {
@@ -76,7 +81,7 @@ var RDB = require('./redis.js'),
});
}
- next(null, tid);
+ next(null, {tid:tid, isMainPost:isMainPost});
});
});
},
@@ -84,10 +89,12 @@ var RDB = require('./redis.js'),
PostTools.toHTML(content, next);
}
], function(err, results) {
- io.sockets.in('topic_' + results[0]).emit('event:post_edited', {
+ io.sockets.in('topic_' + results[1].tid).emit('event:post_edited', {
pid: pid,
title: title,
- content: results[1]
+ isMainPost: results[1].isMainPost,
+ content: results[2],
+ uploadedImages:results[0]
});
});
};
@@ -160,7 +167,7 @@ var RDB = require('./redis.js'),
});
});
- // Restore topic if it is the only post
+ // Restore topic if it is the only post
topics.getTopicField(postData.tid, 'postcount', function(err, count) {
if (count === '1') {
threadTools.restore(postData.tid, uid);
@@ -179,6 +186,7 @@ var RDB = require('./redis.js'),
}
PostTools.toHTML = function(raw, callback) {
+ raw = raw || '';
plugins.fireHook('filter:post.parse', raw, function(parsed) {
var cheerio = require('cheerio');
diff --git a/src/posts.js b/src/posts.js
index d292f86523..ac127bc57c 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -332,7 +332,7 @@ var RDB = require('./redis.js'),
async.parallel({
uploadedImages: function(next) {
- uploadPostImages(postData, images, function(err, uploadedImages) {
+ Posts.uploadPostImages(postData.pid, images, function(err, uploadedImages) {
if(err) {
winston.error('Uploading images failed!', err.stack);
next(null, []);
@@ -350,7 +350,6 @@ var RDB = require('./redis.js'),
}
}, function(err, results) {
postData.uploadedImages = results.uploadedImages;
- Posts.setPostField(pid, 'uploadedImages', JSON.stringify(postData.uploadedImages));
postData.content = results.content;
callback(postData);
});
@@ -366,41 +365,44 @@ var RDB = require('./redis.js'),
});
}
- function uploadPostImages(postData, images, callback) {
+ Posts.uploadPostImages = function(pid, images, callback) {
var imgur = require('./imgur');
imgur.setClientID(meta.config.imgurClientID);
- var uploadedImages = [];
+ if(!images)
+ return callback(null, []);
+
+ var uploadedImages = images.filter(function(image) { return !!image.url; });
+
+ function uploadImage(image, next) {
+ if(!image.data)
+ return next(null);
- function uploadImage(image, callback) {
imgur.upload(image.data, 'base64', function(err, data) {
if(err) {
- callback(err);
+ next(err);
} else {
if(data.success) {
var img= {url:data.data.link, name:image.name};
uploadedImages.push(img);
- callback(null);
+ next(null);
} else {
winston.error('Can\'t upload image, did you set imgurClientID?');
- callback(data);
+ next(data);
}
}
});
}
- if(!images) {
- callback(null, uploadedImages);
- } else {
- async.each(images, uploadImage, function(err) {
- if(!err) {
- callback(null, uploadedImages);
- } else {
- console.log(err);
- callback(err, null);
- }
- });
- }
+ async.each(images, uploadImage, function(err) {
+ if(!err) {
+ Posts.setPostField(pid, 'uploadedImages', JSON.stringify(uploadedImages));
+ callback(null, uploadedImages);
+ } else {
+ console.log(err);
+ callback(err, null);
+ }
+ });
}
Posts.getPostsByUid = function(uid, start, end, callback) {
diff --git a/src/user.js b/src/user.js
index 5f84b492fb..d087cd4102 100644
--- a/src/user.js
+++ b/src/user.js
@@ -7,7 +7,8 @@ var utils = require('./../public/src/utils.js'),
bcrypt = require('bcrypt'),
notifications = require('./notifications.js'),
topics = require('./topics.js'),
- async = require('async');
+ async = require('async'),
+ userSearch = require('reds').createSearch('nodebbusersearch');
(function(User) {
User.create = function(username, password, email, callback) {
@@ -90,6 +91,8 @@ var utils = require('./../public/src/utils.js'),
RDB.zadd('users:postcount', 0, uid);
RDB.zadd('users:reputation', 0, uid);
+ userSearch.index(username, uid);
+
io.sockets.emit('user.latest', {userslug: userslug, username: username});
if (password !== undefined) {
@@ -385,25 +388,42 @@ var utils = require('./../public/src/utils.js'),
});
}
+ User.reIndexAll = function(callback) {
+ User.getUsers('users:joindate', 0, -1, function(err, usersData) {
+ if(err) {
+ return callback(err, null);
+ }
+
+ function reIndexUser(uid, username) {
+ userSearch.remove(uid, function(){
+ userSearch.index(username, uid);
+ })
+ }
+
+ for(var i=0; i';
if(!isUserOnline(touid)) {
- notifications.create(notifText, 5, '#', 'notification_' + uid + '_' + touid, function(nid) {
+ notifications.create(notifText, 5, 'javascript:app.openChat(''+username+'', '+uid+');', 'notification_' + uid + '_' + touid, function(nid) {
notifications.push(nid, [touid], function(success) {
});
@@ -571,13 +548,8 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
numSockets = userSockets[touid].length;
for(var x=0; x 0) {
if (parseInt(data.tid) > 0) {
topics.getTopicData(data.tid, function(topicData) {
-
if (data.body)
topicData.body = data.body;
@@ -640,9 +606,17 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
}
});
} else if (parseInt(data.pid) > 0) {
+
async.parallel([
function(next) {
- posts.getPostField(data.pid, 'content', function(raw) {
+ posts.getPostFields(data.pid, ['content', 'uploadedImages'], function(raw) {
+ try {
+ raw.uploadedImages = JSON.parse(raw.uploadedImages);
+ } catch(e) {
+ winston.err(e);
+ raw.uploadedImages = [];
+ }
+
next(null, raw);
});
},
@@ -655,7 +629,8 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
socket.emit('api:composer.push', {
title: results[1],
pid: data.pid,
- body: results[0]
+ body: results[0].content,
+ uploadedImages: results[0].uploadedImages
});
});
}