Skip to content

Node.js based forum software built for the modern web

closes #6502, also fixed issue with type: 'literal' in config.json

Julian Lam943d33ed09f3
diff --git a/install/web.js b/install/web.js
index 792dfc6aee..ea24d25fb2 100644
--- a/install/web.js
+++ b/install/web.js
@@ -99,6 +99,8 @@ function welcome(req, res) {
var defaults = require('./data/defaults');
res.render('install/index', {
+ url: nconf.get('url') || (req.protocol + '://' + req.get('host')),
+ skipGeneralSetup: !!nconf.get('url'),
databases: databases,
skipDatabaseSetup: !!nconf.get('database'),
error: !!res.locals.error,
diff --git a/src/install.js b/src/install.js
index 8534ef6529..90db5dd861 100644
--- a/src/install.js
+++ b/src/install.js
@@ -2,6 +2,7 @@
var async = require('async');
var fs = require('fs');
+var url = require('url');
var path = require('path');
var prompt = require('prompt');
var winston = require('winston');
@@ -16,9 +17,7 @@ questions.main = [
name: 'url',
description: 'URL used to access this NodeBB',
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',
+ nconf.get('url') || 'http://localhost:4567',
pattern: /^http(?:s)?:\/\//,
message: 'Base URL must begin with \'http://\' or \'https://\'',
},
@@ -162,7 +161,6 @@ function completeConfigSetup(config, next) {
config.package_manager = nconf.get('package_manager');
}
- nconf.overrides(config);
async.waterfall([
function (next) {
require('./database').init(next);
@@ -171,6 +169,22 @@ function completeConfigSetup(config, next) {
require('./database').createIndices(next);
},
function (next) {
+ // Sanity-check/fix url/port
+ if (!/^http(?:s)?:\/\//.test(config.url)) {
+ config.url = 'http://' + config.url;
+ }
+ var urlObj = url.parse(config.url);
+ if (urlObj.port) {
+ config.port = urlObj.port;
+ }
+ urlObj.pathname = null;
+ urlObj.path = null;
+
+ config.url = url.format(urlObj);
+
+ // ref: https://github.com/indexzero/nconf/issues/300
+ delete config.type;
+
install.save(config, next);
},
], next);
diff --git a/src/views/install/index.tpl b/src/views/install/index.tpl
index 39cc52f305..67cb007cad 100644
--- a/src/views/install/index.tpl
+++ b/src/views/install/index.tpl
@@ -33,6 +33,22 @@
You are just a few steps away from launching your own NodeBB forum!
</p>
<form id="install" action="/" method="post">
+ <!-- IF !skipGeneralSetup -->
+ <div class="general">
+ <p>
+ <h1><small>General Instance Setup</small></h1>
+ <hr />
+ </p>
+
+ <div class="row input-row">
+ <div class="col-sm-7 col-xs-12 input-field">
+ <label for="url">Web Address (URL)</label>
+ <input type="text" class="form-control" name="url" value="<!-- IF url -->{url}<!-- ENDIF url -->" placeholder="http://localhost:4567" />
+ </div>
+ <div class="col-sm-5 help-text" data-help="This is the address that resolves to your NodeBB forum. If no port is specified, <code>4567</code> will be used."></div>
+ </div>
+ </div>
+ <!-- END -->
<div class="admin">
<p>
<h1><small>Create an Administrator account</small></h1>