mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-08-26 21:56:35 +02:00
Merge remote-tracking branch 'origin/master' into socket.io1.x
This commit is contained in:
@@ -187,14 +187,9 @@ adminController.events.get = function(req, res, next) {
|
||||
};
|
||||
|
||||
adminController.logs.get = function(req, res, next) {
|
||||
var logPath = path.join('logs', path.sep, 'output.log');
|
||||
fs.readFile(logPath, function(err, data) {
|
||||
if (err || !data) {
|
||||
data = '';
|
||||
}
|
||||
|
||||
meta.logs.get(function(err, logs) {
|
||||
res.render('admin/advanced/logs', {
|
||||
data: validator.escape(data.toString())
|
||||
data: validator.escape(logs)
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
@@ -53,6 +53,7 @@ apiController.getConfig = function(req, res, next) {
|
||||
config.requireEmailConfirmation = parseInt(meta.config.requireEmailConfirmation, 10) === 1;
|
||||
config.topicPostSort = meta.config.topicPostSort || 'oldest_to_newest';
|
||||
config.csrf_token = req.csrfToken();
|
||||
config.searchEnabled = plugins.hasListeners('filter:search.query');
|
||||
|
||||
if (!req.user) {
|
||||
if (res.locals.isAPI) {
|
||||
@@ -75,6 +76,7 @@ apiController.getConfig = function(req, res, next) {
|
||||
config.userLang = settings.language || config.defaultLang;
|
||||
config.openOutgoingLinksInNewTab = settings.openOutgoingLinksInNewTab;
|
||||
config.topicPostSort = settings.topicPostSort || config.topicPostSort;
|
||||
config.topicSearchEnabled = settings.topicSearchEnabled || false;
|
||||
|
||||
if (res.locals.isAPI) {
|
||||
res.status(200).json(config);
|
||||
|
||||
@@ -20,6 +20,7 @@ var async = require('async'),
|
||||
require('./meta/css')(Meta);
|
||||
require('./meta/sounds')(Meta);
|
||||
require('./meta/settings')(Meta);
|
||||
require('./meta/logs')(Meta);
|
||||
Meta.templates = require('./meta/templates');
|
||||
|
||||
/* Assorted */
|
||||
|
||||
@@ -59,16 +59,43 @@ module.exports = function(Meta) {
|
||||
};
|
||||
|
||||
Meta.configs.setMultiple = function(data, callback) {
|
||||
db.setObject('config', data, function(err) {
|
||||
processConfig(data, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
db.setObject('config', data, function(err) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
updateConfig(data);
|
||||
callback();
|
||||
updateConfig(data);
|
||||
callback();
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function processConfig(data, callback) {
|
||||
if (data.customCSS) {
|
||||
saveRenderedCss(data, callback);
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
}
|
||||
|
||||
function saveRenderedCss(data, callback) {
|
||||
var less = require('less');
|
||||
less.render(data.customCSS, {
|
||||
compress: true
|
||||
}, function(err, lessObject) {
|
||||
if (err) {
|
||||
winston.error('[less] Could not convert custom LESS to CSS! Please check your syntax.');
|
||||
return callback(null, '');
|
||||
}
|
||||
data.renderedCustomCSS = lessObject.css;
|
||||
callback(null, lessObject.css);
|
||||
});
|
||||
}
|
||||
|
||||
function updateConfig(data) {
|
||||
var msg = {action: 'config:update', data: data};
|
||||
if (process.send) {
|
||||
|
||||
@@ -126,7 +126,8 @@ module.exports = function(Meta) {
|
||||
|
||||
function minify(source, paths, destination, callback) {
|
||||
less.render(source, {
|
||||
paths: paths
|
||||
paths: paths,
|
||||
compress: true
|
||||
}, function(err, lessOutput) {
|
||||
if (err) {
|
||||
winston.error('[meta/css] Could not minify LESS/CSS: ' + err.message);
|
||||
|
||||
28
src/meta/logs.js
Normal file
28
src/meta/logs.js
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var path = require('path'),
|
||||
fs = require('fs'),
|
||||
winston = require('winston');
|
||||
|
||||
module.exports = function(Meta) {
|
||||
|
||||
Meta.logs = {
|
||||
path: path.join('logs', path.sep, 'output.log')
|
||||
};
|
||||
|
||||
Meta.logs.get = function(callback) {
|
||||
fs.readFile(this.path, {
|
||||
encoding: 'utf-8'
|
||||
}, function(err, logs) {
|
||||
if (err) {
|
||||
winston.error('[meta/logs] Could not retrieve logs: ' + err.message);
|
||||
}
|
||||
|
||||
callback(undefined, logs || '');
|
||||
});
|
||||
}
|
||||
|
||||
Meta.logs.clear = function(callback) {
|
||||
fs.truncate(this.path, 0, callback);
|
||||
}
|
||||
};
|
||||
@@ -198,7 +198,7 @@ middleware.checkAccountPermissions = function(req, res, next) {
|
||||
|
||||
middleware.buildHeader = function(req, res, next) {
|
||||
res.locals.renderHeader = true;
|
||||
|
||||
|
||||
middleware.applyCSRF(req, res, function() {
|
||||
async.parallel({
|
||||
config: function(next) {
|
||||
@@ -305,24 +305,10 @@ middleware.renderHeader = function(req, res, callback) {
|
||||
async.parallel({
|
||||
customCSS: function(next) {
|
||||
templateValues.useCustomCSS = parseInt(meta.config.useCustomCSS, 10) === 1;
|
||||
if (!templateValues.useCustomCSS) {
|
||||
if (!templateValues.useCustomCSS || !meta.config.customCSS || !meta.config.renderedCustomCSS) {
|
||||
return next(null, '');
|
||||
}
|
||||
|
||||
if (!meta.config.customCSS) {
|
||||
return next(null, '');
|
||||
}
|
||||
|
||||
var less = require('less');
|
||||
|
||||
less.render(meta.config.customCSS, function(err, lessObject) {
|
||||
if (err) {
|
||||
winston.error('[less] Could not convert custom LESS to CSS! Please check your syntax.');
|
||||
return next(null, '');
|
||||
}
|
||||
|
||||
next(null, lessObject.css);
|
||||
});
|
||||
next(null, meta.config.renderedCustomCSS);
|
||||
},
|
||||
customJS: function(next) {
|
||||
templateValues.useCustomJS = parseInt(meta.config.useCustomJS, 10) === 1;
|
||||
|
||||
@@ -32,7 +32,8 @@ var async = require('async'),
|
||||
config: {},
|
||||
settings: {},
|
||||
email: {},
|
||||
analytics: {}
|
||||
analytics: {},
|
||||
logs: {}
|
||||
};
|
||||
|
||||
SocketAdmin.before = function(socket, method, next) {
|
||||
@@ -207,6 +208,14 @@ SocketAdmin.analytics.get = function(socket, data, callback) {
|
||||
}
|
||||
};
|
||||
|
||||
SocketAdmin.logs.get = function(socket, data, callback) {
|
||||
meta.logs.get(callback);
|
||||
};
|
||||
|
||||
SocketAdmin.logs.clear = function(socket, data, callback) {
|
||||
meta.logs.clear(callback);
|
||||
};
|
||||
|
||||
function getHourlyStatsForSet(set, hours, callback) {
|
||||
var hour = new Date(),
|
||||
terms = {},
|
||||
|
||||
@@ -84,6 +84,11 @@ module.exports = (function(Digest) {
|
||||
|
||||
notifications = notifications.filter(Boolean);
|
||||
|
||||
// If there are no notifications and no new topics, don't bother sending a digest
|
||||
if (!notifications.length && !data.topics.topics.length) {
|
||||
return next();
|
||||
}
|
||||
|
||||
for(var i=0; i<notifications.length; ++i) {
|
||||
if (notifications[i].image.indexOf('http') !== 0) {
|
||||
notifications[i].image = nconf.get('url') + notifications[i].image;
|
||||
|
||||
@@ -30,6 +30,7 @@ module.exports = function(User) {
|
||||
settings.followTopicsOnReply = parseInt(settings.followTopicsOnReply, 10) === 1;
|
||||
settings.sendChatNotifications = parseInt(settings.sendChatNotifications, 10) === 1;
|
||||
settings.restrictChat = parseInt(settings.restrictChat, 10) === 1;
|
||||
settings.topicSearchEnabled = parseInt(settings.topicSearchEnabled, 10) === 1;
|
||||
|
||||
callback(null, settings);
|
||||
});
|
||||
@@ -94,7 +95,8 @@ module.exports = function(User) {
|
||||
followTopicsOnCreate: data.followTopicsOnCreate,
|
||||
followTopicsOnReply: data.followTopicsOnReply,
|
||||
sendChatNotifications: data.sendChatNotifications,
|
||||
restrictChat: data.restrictChat
|
||||
restrictChat: data.restrictChat,
|
||||
topicSearchEnabled: data.topicSearchEnabled
|
||||
}, callback);
|
||||
};
|
||||
|
||||
|
||||
@@ -7,4 +7,13 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="panel panel-default affix">
|
||||
<div class="panel-heading">Logs Control Panel</div>
|
||||
<div class="panel-body">
|
||||
<button class="btn btn-primary" data-action="reload"><i class="fa fa-refresh"></i> Reload Logs</button>
|
||||
<button class="btn btn-warning" data-action="clear"><i class="fa fa-eraser"></i> Clear Logs</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user