mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-12-24 01:10:31 +01:00
merge
This commit is contained in:
10
app.js
10
app.js
@@ -25,6 +25,7 @@ nconf.argv().env();
|
|||||||
|
|
||||||
var fs = require('fs'),
|
var fs = require('fs'),
|
||||||
os = require('os'),
|
os = require('os'),
|
||||||
|
url = require('url'),
|
||||||
async = require('async'),
|
async = require('async'),
|
||||||
semver = require('semver'),
|
semver = require('semver'),
|
||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
@@ -107,6 +108,15 @@ function loadConfig() {
|
|||||||
function start() {
|
function start() {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
|
// nconf defaults, if not set in config
|
||||||
|
if (!nconf.get('upload_path')) nconf.set('upload_path', '/public/uploads');
|
||||||
|
if (!nconf.get('bcrypt_rounds')) nconf.set('bcrypt_rounds', 12);
|
||||||
|
// Parse out the relative_url and other goodies from the configured URL
|
||||||
|
var urlObject = url.parse(nconf.get('url'));
|
||||||
|
nconf.set('use_port', !!urlObject.port);
|
||||||
|
nconf.set('relative_path', urlObject.pathname !== '/' ? urlObject.pathname : '');
|
||||||
|
nconf.set('port', nconf.get('port') || nconf.get('PORT') || 4567);
|
||||||
|
|
||||||
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
|
if (!cluster.isWorker || process.env.cluster_setup === 'true') {
|
||||||
winston.info('Time: %s', (new Date()).toString());
|
winston.info('Time: %s', (new Date()).toString());
|
||||||
winston.info('Initializing NodeBB v%s', pkg.version);
|
winston.info('Initializing NodeBB v%s', pkg.version);
|
||||||
|
|||||||
@@ -4,15 +4,15 @@ var pkg = require('./../../package.json'),
|
|||||||
meta = require('./../meta'),
|
meta = require('./../meta'),
|
||||||
user = require('./../user'),
|
user = require('./../user'),
|
||||||
plugins = require('./../plugins'),
|
plugins = require('./../plugins'),
|
||||||
widgets = require('../widgets');
|
widgets = require('../widgets'),
|
||||||
|
|
||||||
|
nconf = require('nconf');
|
||||||
|
|
||||||
var apiController = {};
|
var apiController = {};
|
||||||
|
|
||||||
apiController.getConfig = function(req, res, next) {
|
apiController.getConfig = function(req, res, next) {
|
||||||
var serverConfig = require('./../../config.json');
|
|
||||||
|
|
||||||
var config = {};
|
var config = {};
|
||||||
config.relative_path = serverConfig.relative_path;
|
config.relative_path = nconf.get('relative_path');
|
||||||
config.version = pkg.version;
|
config.version = pkg.version;
|
||||||
config.siteTitle = meta.config.title || meta.config.browserTitle || 'NodeBB';
|
config.siteTitle = meta.config.title || meta.config.browserTitle || 'NodeBB';
|
||||||
config.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1;
|
config.showSiteTitle = parseInt(meta.config.showSiteTitle, 10) === 1;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
var async = require('async'),
|
var async = require('async'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
url = require('url'),
|
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
prompt = require('prompt'),
|
prompt = require('prompt'),
|
||||||
winston = require('winston'),
|
winston = require('winston'),
|
||||||
@@ -24,29 +23,20 @@ var install = {},
|
|||||||
|
|
||||||
questions.main = [
|
questions.main = [
|
||||||
{
|
{
|
||||||
name: 'base_url',
|
name: 'url',
|
||||||
description: 'URL used to access this NodeBB',
|
description: 'URL used to access this NodeBB',
|
||||||
'default': nconf.get('base_url') ? (nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '')) : 'http://localhost:4567',
|
'default':
|
||||||
|
nconf.get('url') ||
|
||||||
|
(nconf.get('base_url') ? (nconf.get('base_url') + (nconf.get('use_port') ? ':' + nconf.get('port') : '')) : null) || // backwards compatibility (remove for v0.7.0)
|
||||||
|
'http://localhost:4567',
|
||||||
pattern: /^http(?:s)?:\/\//,
|
pattern: /^http(?:s)?:\/\//,
|
||||||
message: 'Base URL must begin with \'http://\' or \'https://\'',
|
message: 'Base URL must begin with \'http://\' or \'https://\'',
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'port',
|
|
||||||
description: 'Port number of your NodeBB',
|
|
||||||
'default': nconf.get('port') || 4567,
|
|
||||||
pattern: /[0-9]{1,4}|[1-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]/,
|
|
||||||
message: 'Please enter a value betweeen 1 and 65535'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'secret',
|
name: 'secret',
|
||||||
description: 'Please enter a NodeBB secret',
|
description: 'Please enter a NodeBB secret',
|
||||||
'default': nconf.get('secret') || utils.generateUUID()
|
'default': nconf.get('secret') || utils.generateUUID()
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: 'bind_address',
|
|
||||||
description: 'IP or Hostname to bind to',
|
|
||||||
'default': nconf.get('bind_address') || '0.0.0.0'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: 'database',
|
name: 'database',
|
||||||
description: 'Which database to use',
|
description: 'Which database to use',
|
||||||
@@ -175,6 +165,7 @@ function completeConfigSetup(err, config, next) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add CI object
|
// Add CI object
|
||||||
if (install.ciVals) {
|
if (install.ciVals) {
|
||||||
config.test_database = {};
|
config.test_database = {};
|
||||||
@@ -185,22 +176,12 @@ function completeConfigSetup(err, config, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
config.bcrypt_rounds = 12;
|
install.save(config, function(err) {
|
||||||
config.upload_path = '/public/uploads';
|
|
||||||
|
|
||||||
var urlObject = url.parse(config.base_url),
|
|
||||||
server_conf = config;
|
|
||||||
|
|
||||||
server_conf.base_url = urlObject.protocol + '//' + urlObject.hostname;
|
|
||||||
server_conf.use_port = urlObject.port !== null ? true : false;
|
|
||||||
server_conf.relative_path = (urlObject.pathname && urlObject.pathname.length > 1) ? urlObject.pathname : '';
|
|
||||||
|
|
||||||
install.save(server_conf, function(err) {
|
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
setupDatabase(server_conf, next);
|
setupDatabase(config, next);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +310,6 @@ function createAdmin(callback) {
|
|||||||
return retryPassword(results);
|
return retryPassword(results);
|
||||||
}
|
}
|
||||||
|
|
||||||
nconf.set('bcrypt_rounds', 12);
|
|
||||||
User.create({username: results.username, password: results.password, email: results.email}, function (err, uid) {
|
User.create({username: results.username, password: results.password, email: results.email}, function (err, uid) {
|
||||||
if (err) {
|
if (err) {
|
||||||
winston.warn(err.message + ' Please try again.');
|
winston.warn(err.message + ' Please try again.');
|
||||||
|
|||||||
@@ -746,7 +746,22 @@ var fs = require('fs'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
Plugins.clearRequireCache = function(next) {
|
Plugins.clearRequireCache = function(next) {
|
||||||
async.map(Plugins.libraryPaths, fs.realpath, function(err, paths) {
|
var cached = Object.keys(require.cache);
|
||||||
|
async.waterfall([
|
||||||
|
async.apply(async.map, Plugins.libraryPaths, fs.realpath),
|
||||||
|
function(paths, next) {
|
||||||
|
paths = paths.map(function(pluginLib) {
|
||||||
|
var parent = path.dirname(pluginLib);
|
||||||
|
return cached.filter(function(libPath) {
|
||||||
|
return libPath.indexOf(parent) !== -1;
|
||||||
|
});
|
||||||
|
}).reduce(function(prev, cur) {
|
||||||
|
return prev.concat(cur);
|
||||||
|
});
|
||||||
|
next(null, paths);
|
||||||
|
}
|
||||||
|
], function(err, paths) {
|
||||||
|
console.log(paths);
|
||||||
for (var x=0,numPaths=paths.length;x<numPaths;x++) {
|
for (var x=0,numPaths=paths.length;x<numPaths;x++) {
|
||||||
delete require.cache[paths[x]];
|
delete require.cache[paths[x]];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,34 +54,33 @@ var path = require('path'),
|
|||||||
topicUrls: function(next) {
|
topicUrls: function(next) {
|
||||||
var topicUrls = [];
|
var topicUrls = [];
|
||||||
|
|
||||||
db.getSortedSetRevRange('topics:recent', 0, 49, function(err, tids) {
|
async.waterfall([
|
||||||
|
function(tids, next) {
|
||||||
|
db.getSortedSetRevRange('topics:recent', 0, -1, next);
|
||||||
|
},
|
||||||
|
function(tids, next) {
|
||||||
|
privileges.topics.filter('read', tids, 0, next);
|
||||||
|
},
|
||||||
|
function(tids, next) {
|
||||||
|
topics.getTopicsFields(tids, ['tid', 'title', 'lastposttime'], next);
|
||||||
|
}
|
||||||
|
], function(err, topics) {
|
||||||
if (err) {
|
if (err) {
|
||||||
return next(err);
|
return next(err);
|
||||||
}
|
}
|
||||||
privileges.topics.filter('read', tids, 0, function(err, tids) {
|
|
||||||
if (err) {
|
|
||||||
return next(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
topics.getTopicsFields(tids, ['tid', 'title', 'lastposttime'], function(err, topics) {
|
topics.forEach(function(topic) {
|
||||||
if (err) {
|
if (topic) {
|
||||||
return next(err);
|
topicUrls.push({
|
||||||
}
|
url: '/topic/' + topic.tid + '/' + encodeURIComponent(utils.slugify(topic.title)),
|
||||||
|
lastmodISO: utils.toISOString(topic.lastposttime),
|
||||||
topics.forEach(function(topic) {
|
changefreq: 'daily',
|
||||||
if (topic) {
|
priority: '0.6'
|
||||||
topicUrls.push({
|
|
||||||
url: '/topic/' + topic.tid + '/' + encodeURIComponent(utils.slugify(topic.title)),
|
|
||||||
lastmodISO: utils.toISOString(topic.lastposttime),
|
|
||||||
changefreq: 'daily',
|
|
||||||
priority: '0.6'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
next(null, topicUrls);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
next(null, topicUrls);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, function(err, data) {
|
}, function(err, data) {
|
||||||
|
|||||||
1131
src/upgrade.js
1131
src/upgrade.js
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ if(nconf.get('ssl')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
(function (app) {
|
(function (app) {
|
||||||
var port = nconf.get('PORT') || nconf.get('port');
|
var port = nconf.get('port');
|
||||||
|
|
||||||
module.exports.init = function() {
|
module.exports.init = function() {
|
||||||
emailer.registerApp(app);
|
emailer.registerApp(app);
|
||||||
|
|||||||
Reference in New Issue
Block a user