mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 12:05:57 +01:00
1
.gitignore
vendored
1
.gitignore
vendored
@@ -63,3 +63,4 @@ build
|
|||||||
*.log
|
*.log
|
||||||
test/files/normalise.jpg.png
|
test/files/normalise.jpg.png
|
||||||
test/files/normalise-resized.jpg
|
test/files/normalise-resized.jpg
|
||||||
|
package-lock.json
|
||||||
|
|||||||
@@ -46,7 +46,6 @@
|
|||||||
"json-2-csv": "^2.0.22",
|
"json-2-csv": "^2.0.22",
|
||||||
"less": "^2.0.0",
|
"less": "^2.0.0",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"lodash.padstart": "^4.6.1",
|
|
||||||
"logrotate-stream": "^0.2.3",
|
"logrotate-stream": "^0.2.3",
|
||||||
"lru-cache": "4.0.2",
|
"lru-cache": "4.0.2",
|
||||||
"mime": "^1.3.4",
|
"mime": "^1.3.4",
|
||||||
@@ -138,4 +137,4 @@
|
|||||||
"url": "https://github.com/barisusakli"
|
"url": "https://github.com/barisusakli"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,53 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
var fs = require('fs');
|
||||||
|
var async = require('async');
|
||||||
|
|
||||||
var file = require('../../file');
|
var file = require('../../file');
|
||||||
|
|
||||||
var themesController = {};
|
var themesController = {};
|
||||||
|
|
||||||
themesController.get = function (req, res, next) {
|
var defaultScreenshotPath = path.join(__dirname, '../../../public/images/themes/default.png');
|
||||||
var themeDir = path.join(__dirname, '../../../node_modules/' + req.params.theme);
|
|
||||||
file.exists(themeDir, function (err, exists) {
|
|
||||||
if (err || !exists) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
var themeConfig = require(path.join(themeDir, 'theme.json'));
|
themesController.get = function (req, res, next) {
|
||||||
var screenshotPath = path.join(themeDir, themeConfig.screenshot);
|
var themeDir = path.join(__dirname, '../../../node_modules', req.params.theme);
|
||||||
if (themeConfig.screenshot && file.existsSync(screenshotPath)) {
|
var themeConfigPath = path.join(themeDir, 'theme.json');
|
||||||
res.sendFile(screenshotPath);
|
|
||||||
} else {
|
async.waterfall([
|
||||||
res.sendFile(path.join(__dirname, '../../../public/images/themes/default.png'));
|
function (next) {
|
||||||
}
|
file.exists(themeConfigPath, function (err, exists) {
|
||||||
});
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
if (!exists) {
|
||||||
|
return next(Error('invalid-data'));
|
||||||
|
}
|
||||||
|
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
function (next) {
|
||||||
|
fs.readFile(themeConfigPath, next);
|
||||||
|
},
|
||||||
|
function (themeConfig, next) {
|
||||||
|
try {
|
||||||
|
themeConfig = JSON.parse(themeConfig);
|
||||||
|
next(null, themeConfig.screenshot ? path.join(themeDir, themeConfig.screenshot) : defaultScreenshotPath);
|
||||||
|
} catch (e) {
|
||||||
|
next(e);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
function (screenshotPath, next) {
|
||||||
|
file.exists(screenshotPath, function (err, exists) {
|
||||||
|
if (err) {
|
||||||
|
return next(err);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.sendFile(exists ? screenshotPath : defaultScreenshotPath);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
], next);
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = themesController;
|
module.exports = themesController;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
var async = require('async');
|
var async = require('async');
|
||||||
var winston = require('winston');
|
var winston = require('winston');
|
||||||
var nconf = require('nconf');
|
var nconf = require('nconf');
|
||||||
var padstart = require('lodash.padstart');
|
var _ = require('lodash');
|
||||||
|
|
||||||
var cacheBuster = require('./cacheBuster');
|
var cacheBuster = require('./cacheBuster');
|
||||||
var meta;
|
var meta;
|
||||||
@@ -122,7 +122,7 @@ function buildTargets(targets, parallel, callback) {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
all(targets, function (target, next) {
|
all(targets, function (target, next) {
|
||||||
targetHandlers[target](parallel, step(padstart(target, length) + ' ', next));
|
targetHandlers[target](parallel, step(_.padStart(target, length) + ' ', next));
|
||||||
}, callback);
|
}, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
15
src/meta/debugParams.js
Normal file
15
src/meta/debugParams.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = function () {
|
||||||
|
var debugArg = process.execArgv.find(function (arg) {
|
||||||
|
return /^--(debug|inspect)/.test(arg);
|
||||||
|
});
|
||||||
|
if (global.v8debug || debugArg) {
|
||||||
|
debugArg = debugArg ? debugArg.split('=') : ['--debug', 5859];
|
||||||
|
var num = parseInt(debugArg[1], 10) + 1;
|
||||||
|
|
||||||
|
return { execArgv: [debugArg[0] + '=' + num, '--nolazy'] };
|
||||||
|
}
|
||||||
|
|
||||||
|
return { execArgv: [] };
|
||||||
|
};
|
||||||
@@ -107,15 +107,15 @@ function getTranslationTree(callback) {
|
|||||||
// 2. old language string (en_GB)
|
// 2. old language string (en_GB)
|
||||||
// 3. corrected plugin defaultLang (en-US)
|
// 3. corrected plugin defaultLang (en-US)
|
||||||
// 4. old plugin defaultLang (en_US)
|
// 4. old plugin defaultLang (en_US)
|
||||||
async.eachLimit(plugins, 10, function (pluginData, done) {
|
async.eachLimit(plugins, 20, function (pluginData, done) {
|
||||||
var pluginLanguages = path.join(__dirname, '../../node_modules/', pluginData.id, pluginData.languages);
|
var pluginLanguages = path.join(__dirname, '../../node_modules/', pluginData.id, pluginData.languages);
|
||||||
var defaultLang = pluginData.defaultLang || 'en-GB';
|
var defaultLang = pluginData.defaultLang || 'en-GB';
|
||||||
|
|
||||||
async.some([
|
async.eachSeries([
|
||||||
lang,
|
|
||||||
lang.replace('-', '_').replace('-x-', '@'),
|
|
||||||
defaultLang.replace('_', '-').replace('@', '-x-'),
|
|
||||||
defaultLang.replace('-', '_').replace('-x-', '@'),
|
defaultLang.replace('-', '_').replace('-x-', '@'),
|
||||||
|
defaultLang.replace('_', '-').replace('@', '-x-'),
|
||||||
|
lang.replace('-', '_').replace('-x-', '@'),
|
||||||
|
lang,
|
||||||
], function (language, next) {
|
], function (language, next) {
|
||||||
fs.readFile(path.join(pluginLanguages, language, namespace + '.json'), function (err, buffer) {
|
fs.readFile(path.join(pluginLanguages, language, namespace + '.json'), function (err, buffer) {
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|||||||
@@ -11,31 +11,10 @@ var postcss = require('postcss');
|
|||||||
var autoprefixer = require('autoprefixer');
|
var autoprefixer = require('autoprefixer');
|
||||||
var clean = require('postcss-clean');
|
var clean = require('postcss-clean');
|
||||||
|
|
||||||
|
var debugParams = require('./debugParams');
|
||||||
|
|
||||||
var Minifier = module.exports;
|
var Minifier = module.exports;
|
||||||
|
|
||||||
function setupDebugging() {
|
|
||||||
/**
|
|
||||||
* Check if the parent process is running with the debug option --debug (or --debug-brk)
|
|
||||||
*/
|
|
||||||
var forkProcessParams = {};
|
|
||||||
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
|
|
||||||
/**
|
|
||||||
* use the line below if you want to debug minifier.js script too (or even --debug-brk option, but
|
|
||||||
* you'll have to setup your debugger and connect to the forked process)
|
|
||||||
*/
|
|
||||||
// forkProcessParams = { execArgv: ['--debug=' + (global.process.debugPort + 1), '--nolazy'] };
|
|
||||||
|
|
||||||
/**
|
|
||||||
* otherwise, just clean up --debug/--debug-brk options which are set up by default from the parent one
|
|
||||||
*/
|
|
||||||
forkProcessParams = {
|
|
||||||
execArgv: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return forkProcessParams;
|
|
||||||
}
|
|
||||||
|
|
||||||
var pool = [];
|
var pool = [];
|
||||||
var free = [];
|
var free = [];
|
||||||
|
|
||||||
@@ -68,7 +47,7 @@ function getChild() {
|
|||||||
return free.shift();
|
return free.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
var forkProcessParams = setupDebugging();
|
var forkProcessParams = debugParams();
|
||||||
var proc = childProcess.fork(__filename, [], Object.assign({}, forkProcessParams, {
|
var proc = childProcess.fork(__filename, [], Object.assign({}, forkProcessParams, {
|
||||||
cwd: __dirname,
|
cwd: __dirname,
|
||||||
env: {
|
env: {
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
||||||
var fork = require('child_process').fork;
|
var fork = require('child_process').fork;
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
|
||||||
|
var debugParams = require('./meta/debugParams');
|
||||||
|
|
||||||
exports.hash = function (rounds, password, callback) {
|
exports.hash = function (rounds, password, callback) {
|
||||||
forkChild({ type: 'hash', rounds: rounds, password: password }, callback);
|
forkChild({ type: 'hash', rounds: rounds, password: password }, callback);
|
||||||
};
|
};
|
||||||
@@ -16,11 +17,7 @@ exports.compare = function (password, hash, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
function forkChild(message, callback) {
|
function forkChild(message, callback) {
|
||||||
var forkProcessParams = {};
|
var child = fork(path.join(__dirname, 'bcrypt'), [], debugParams());
|
||||||
if (global.v8debug || parseInt(process.execArgv.indexOf('--debug'), 10) !== -1) {
|
|
||||||
forkProcessParams = { execArgv: ['--debug=' + (5859), '--nolazy'] };
|
|
||||||
}
|
|
||||||
var child = fork(path.join(__dirname, 'bcrypt'), [], forkProcessParams);
|
|
||||||
|
|
||||||
child.on('message', function (msg) {
|
child.on('message', function (msg) {
|
||||||
if (msg.err) {
|
if (msg.err) {
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ module.exports = function (Plugins) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runNpmCommand(command, pkgName, version, callback) {
|
function runNpmCommand(command, pkgName, version, callback) {
|
||||||
require('child_process').execFile((process.platform === 'win32') ? 'npm.cmd' : 'npm', [command, pkgName + (command === 'install' ? '@' + version : '')], function (err, stdout) {
|
require('child_process').execFile((process.platform === 'win32') ? 'npm.cmd' : 'npm', [command, pkgName + (command === 'install' ? '@' + version : ''), '--no-save'], function (err, stdout) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return callback(err);
|
return callback(err);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user