Merge remote-tracking branch 'origin/master' into mongodb-3.0-driver-2.0

v1.18.x
Barış Soner Uşaklı 10 years ago
commit f6d0ad9b0f

@ -32,12 +32,9 @@ define('admin/appearance/skins', function() {
app.alert({
alert_id: 'admin:theme',
type: 'info',
title: 'Theme Changed',
message: 'Please restart your NodeBB to fully activate this theme',
timeout: 5000,
clickfn: function() {
socket.emit('admin.restart');
}
title: 'Skin Updated',
message: themeId + ' skin was successfully applied',
timeout: 5000
});
});
}

@ -60,7 +60,10 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func
fork.init();
components.get('topic').on('click', '[component="topic/follow"]', function() {
components.get('topic').on('click', '[component="topic/follow"]', follow);
components.get('topic/follow').off('click').on('click', follow);
function follow() {
socket.emit('topics.toggleFollow', tid, function(err, state) {
if(err) {
return app.alert({
@ -83,7 +86,7 @@ define('forum/topic/threadTools', ['forum/topic/fork', 'forum/topic/move'], func
});
return false;
});
}
};
function topicCommand(command, tid) {

@ -48,7 +48,7 @@ define('notifications', ['sounds'], function(sound) {
});
});
notifList.on('click', '.mark-all-read', function() {
notifContainer.on('click', '.mark-all-read', function() {
socket.emit('notifications.markAllRead', function(err) {
if (err) {
app.alertError(err.message);

@ -367,6 +367,20 @@
};
}
if (typeof String.prototype.endsWith != 'function') {
String.prototype.endsWith = function(suffix) {
if (this.length < suffix.length) {
return false;
}
var len = this.length;
var suffixLen = suffix.length;
for (var i=1; (i <= suffixLen && this[len - i] === suffix[suffixLen - i]); ++i) {
continue;
}
return i > suffixLen;
};
}
if ('undefined' !== typeof window) {
window.utils = module.exports;
}

@ -59,6 +59,17 @@
usernamePassword = nconf.get('mongo:username') + ':' + nconf.get('mongo:password') + '@';
}
// Sensible defaults for Mongo, if not set
if (!nconf.get('mongo:host')) {
nconf.set('mongo:host', '127.0.0.1');
}
if (!nconf.get('mongo:port')) {
nconf.set('mongo:port', 27017);
}
if (!nconf.get('mongo:database')) {
nconf.set('mongo:database', '0');
}
var connString = 'mongodb://' + usernamePassword + nconf.get('mongo:host') + ':' + nconf.get('mongo:port') + '/' + nconf.get('mongo:database');
var connOptions = {
server: {

@ -10,7 +10,8 @@ var winston = require('winston'),
plugins = require('../plugins'),
emitter = require('../emitter'),
db = require('../database');
db = require('../database'),
utils = require('../../public/src/utils');
module.exports = function(Meta) {
@ -21,30 +22,46 @@ module.exports = function(Meta) {
Meta.css.defaultBranding = {};
Meta.css.minify = function(callback) {
if (nconf.get('isPrimary') === 'true') {
winston.verbose('[meta/css] Minifying LESS/CSS');
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'),
baseThemePath = path.join(nconf.get('themes_path'), (themeData['theme:type'] && themeData['theme:type'] === 'local' ? themeId : 'nodebb-theme-vanilla')),
paths = [
baseThemePath,
path.join(__dirname, '../../node_modules'),
path.join(__dirname, '../../public/vendor/fontawesome/less'),
path.join(__dirname, '../../public/vendor/bootstrap/less')
],
source = '@import "font-awesome";',
acpSource,
x;
plugins.lessFiles = filterMissingFiles(plugins.lessFiles);
for(x=0; x<plugins.lessFiles.length; ++x) {
source += '\n@import ".' + path.sep + plugins.lessFiles[x] + '";';
}
callback = callback || function() {};
if (nconf.get('isPrimary') !== 'true') {
winston.verbose('[meta/css] Cluster worker ' + process.pid + ' skipping LESS/CSS compilation');
return callback();
}
winston.verbose('[meta/css] Minifying LESS/CSS');
db.getObjectFields('config', ['theme:type', 'theme:id'], function(err, themeData) {
if (err) {
return callback(err);
}
plugins.cssFiles = filterMissingFiles(plugins.cssFiles);
for(x=0; x<plugins.cssFiles.length; ++x) {
source += '\n@import (inline) ".' + path.sep + plugins.cssFiles[x] + '";';
var themeId = (themeData['theme:id'] || 'nodebb-theme-vanilla'),
baseThemePath = path.join(nconf.get('themes_path'), (themeData['theme:type'] && themeData['theme:type'] === 'local' ? themeId : 'nodebb-theme-vanilla')),
paths = [
baseThemePath,
path.join(__dirname, '../../node_modules'),
path.join(__dirname, '../../public/vendor/fontawesome/less'),
path.join(__dirname, '../../public/vendor/bootstrap/less')
],
source = '@import "font-awesome";';
plugins.lessFiles = filterMissingFiles(plugins.lessFiles);
plugins.cssFiles = filterMissingFiles(plugins.cssFiles);
async.waterfall([
function(next) {
getStyleSource(plugins.lessFiles, '\n@import ".', '.less', next);
},
function(src, next) {
source += src;
getStyleSource(plugins.cssFiles, '\n@import (inline) ".', '.css', next);
},
function(src, next) {
source += src;
next();
}
], function(err) {
if (err) {
return callback(err);
}
source += '\n@import (inline) "..' + path.sep + '..' + path.sep + 'public/vendor/jquery/css/smoothness/jquery-ui-1.10.4.custom.min.css";';
@ -52,7 +69,7 @@ module.exports = function(Meta) {
source += '\n@import (inline) "..' + path.sep + '..' + path.sep + 'public/vendor/jquery/textcomplete/jquery.textcomplete.css";';
source += '\n@import (inline) "..' + path.sep + '..' + path.sep + 'public/vendor/colorpicker/colorpicker.css";';
acpSource = '\n@import "..' + path.sep + 'public/less/admin/admin";\n' + source;
var acpSource = '\n@import "..' + path.sep + 'public/less/admin/admin";\n' + source;
acpSource += '\n@import (inline) "..' + path.sep + 'public/vendor/colorpicker/colorpicker.css";';
source = '@import "./theme";\n' + source;
@ -65,6 +82,10 @@ module.exports = function(Meta) {
minify(acpSource, paths, 'acpCache', next);
}
], function(err, minified) {
if (err) {
return callback(err);
}
// Propagate to other workers
if (process.send) {
process.send({
@ -77,19 +98,41 @@ module.exports = function(Meta) {
emitter.emit('meta:css.compiled');
if (typeof callback === 'function') {
callback();
}
callback();
});
});
} else {
winston.verbose('[meta/css] Cluster worker ' + process.pid + ' skipping LESS/CSS compilation');
if (typeof callback === 'function') {
callback();
}
}
});
};
function getStyleSource(files, prefix, extension, callback) {
var pluginDirectories = [],
source = '';
files.forEach(function(styleFile) {
if (styleFile.endsWith(extension)) {
source += prefix + path.sep + styleFile + '";';
} else {
pluginDirectories.push(styleFile);
}
});
async.each(pluginDirectories, function(directory, next) {
utils.walk(directory, function(err, styleFiles) {
if (err) {
return next(err);
}
styleFiles.forEach(function(styleFile) {
source += prefix + path.sep + styleFile + '";';
});
next();
});
}, function(err) {
callback(err, source);
});
}
Meta.css.commitToFile = function(filename) {
var file = (filename === 'acpCache' ? 'admin' : 'stylesheet') + '.css';

@ -94,7 +94,7 @@ module.exports = function(Meta) {
clientScripts = [];
pluginsScripts = plugins.clientScripts.filter(function(path) {
if (path.indexOf('.js') !== -1) {
if (path.endsWith('.js')) {
return true;
} else {
pluginDirectories.push(path);

@ -120,7 +120,7 @@ var cache = LRU({
},
postData: function(next) {
cache.del(postData.pid);
PostTools.parsePost(postData, data.uid, next);
PostTools.parsePost(postData, next);
}
}, function(err, results) {
if (err) {
@ -176,7 +176,7 @@ var cache = LRU({
if (err) {
return callback(err);
}
PostTools.parsePost(postData, uid, callback);
PostTools.parsePost(postData, callback);
});
}
});
@ -192,7 +192,7 @@ var cache = LRU({
});
};
PostTools.parsePost = function(postData, uid, callback) {
PostTools.parsePost = function(postData, callback) {
postData.content = postData.content || '';
var cachedContent = cache.get(postData.pid);
@ -201,7 +201,7 @@ var cache = LRU({
return callback(null, postData);
}
plugins.fireHook('filter:parse.post', {postData: postData, uid: uid}, function(err, data) {
plugins.fireHook('filter:parse.post', {postData: postData}, function(err, data) {
if (err) {
return callback(err);
}

@ -52,7 +52,7 @@ var async = require('async'),
postData.relativeTime = utils.toISOString(postData.timestamp);
postData.relativeEditTime = parseInt(postData.edited, 10) !== 0 ? utils.toISOString(postData.edited) : '';
postTools.parsePost(postData, uid, next);
postTools.parsePost(postData, next);
}, function(err, posts) {
if (err) {
return callback(err);

@ -86,7 +86,7 @@ module.exports = function(Posts) {
return next(null, post);
}
postTools.parsePost(post, uid, function(err, post) {
postTools.parsePost(post, function(err, post) {
if (err) {
return next(err);
}

@ -102,17 +102,11 @@ module.exports = function(privileges) {
}
cids = cids.filter(function(cid, index) {
return !results.categories[index].disabled;
return !results.categories[index].disabled ||
(results.allowedTo[index] || results.isAdmin || results.isModerators[index]);
});
if (results.isAdmin) {
return callback(null, cids);
}
cids = cids.filter(function(cid, index) {
return results.allowedTo[index] || results.isModerators[index];
});
callback(null, cids);
callback(null, cids.filter(Boolean));
});
};

@ -232,7 +232,7 @@ SocketPosts.sendNotificationToPostOwner = function(pid, fromuid, notification) {
async.parallel({
username: async.apply(user.getUserField, fromuid, 'username'),
topicTitle: async.apply(topics.getTopicField, postData.tid, 'title'),
postObj: async.apply(postTools.parsePost, postData, postData.uid)
postObj: async.apply(postTools.parsePost, postData)
}, function(err, results) {
if (err) {
return;
@ -479,7 +479,7 @@ SocketPosts.flag = function(socket, pid, callback) {
function(topic, next) {
post.topic = topic;
message = '[[notifications:user_flagged_post_in, ' + userName + ', ' + topic.title + ']]';
postTools.parsePost(post, socket.uid, next);
postTools.parsePost(post, next);
},
function(post, next) {
async.parallel({

@ -245,7 +245,7 @@ module.exports = function(Topics) {
posts.getPidIndex(postData.pid, uid, next);
},
content: function(next) {
postTools.parsePost(postData, uid, next);
postTools.parsePost(postData, next);
}
}, next);
},

@ -3,11 +3,13 @@
'use strict';
var async = require('async'),
S = require('string'),
db = require('../database'),
user = require('../user'),
posts = require('../posts'),
plugins = require('../plugins'),
postTools = require('../postTools'),
utils = require('../../public/src/utils');
@ -49,21 +51,30 @@ module.exports = function(Topics) {
users[user.uid] = user;
});
var tidToPost = {};
postData.forEach(function(post) {
async.each(postData, function(post, next) {
post.user = users[post.uid];
post.timestamp = utils.toISOString(post.timestamp);
tidToPost[post.tid] = post;
});
var teasers = topics.map(function(topic, index) {
if (tidToPost[topic.tid]) {
tidToPost[topic.tid].index = counts[index];
postTools.parsePost(post, next);
}, function(err) {
if (err) {
return callback(err);
}
return tidToPost[topic.tid];
});
plugins.fireHook('filter:teasers.get', {teasers: teasers}, function(err, data) {
callback(err, data ? data.teasers : null);
var teasers = topics.map(function(topic, index) {
if (tidToPost[topic.tid]) {
tidToPost[topic.tid].index = counts[index];
if (tidToPost[topic.tid].content) {
var s = S(tidToPost[topic.tid].content);
tidToPost[topic.tid].content = s.stripTags.apply(s, utils.stripTags).s;
}
}
return tidToPost[topic.tid];
});
plugins.fireHook('filter:teasers.get', {teasers: teasers}, function(err, data) {
callback(err, data ? data.teasers : null);
});
});
});
});

@ -10,7 +10,7 @@
<!-- BEGIN events -->
<div>
<span>#{events.eid} </span><span class="label label-info">{events.type}</span>
<a href="{config.relative_path}/user/{events.user.userslug}" target="_blank"><img class="user-img" src="{events.user.picture}"/></a> <a href="{config.relative_path}/user/{events.user.userslug}">{events.user.username}</a> (uid {events.user.uid}) (IP {events.ip})
<a href="{config.relative_path}/user/{events.user.userslug}" target="_blank"><img class="user-img" src="{events.user.picture}"/></a> <a href="{config.relative_path}/user/{events.user.userslug}" target="_blank">{events.user.username}</a> (uid {events.user.uid}) (IP {events.ip})
<span class="pull-right">{events.timestampISO}</span>
<br/><br/>
<pre>{events.jsonString}</pre>

Loading…
Cancel
Save