Merge branch 'install_script'
commit
878a678643
@ -1,54 +1,131 @@
|
||||
var categories = require('./src/categories.js'),
|
||||
templates = require('./public/src/templates.js'),
|
||||
webserver = require('./src/webserver.js'),
|
||||
websockets = require('./src/websockets.js'),
|
||||
admin = {
|
||||
'categories': require('./src/admin/categories.js')
|
||||
},
|
||||
fs = require('fs');
|
||||
|
||||
DEVELOPMENT = true;
|
||||
|
||||
global.configuration = {};
|
||||
global.templates = {};
|
||||
|
||||
(function(config) {
|
||||
config['ROOT_DIRECTORY'] = __dirname;
|
||||
|
||||
templates.init([
|
||||
'header', 'footer', 'logout', 'admin/header', 'admin/footer', 'admin/index',
|
||||
'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext',
|
||||
'emails/header.tpl', 'emails/footer.tpl'
|
||||
]);
|
||||
|
||||
templates.ready(function() {
|
||||
webserver.init();
|
||||
});
|
||||
|
||||
//setup scripts to be moved outside of the app in future.
|
||||
function setup_categories() {
|
||||
console.log('Checking categories...');
|
||||
categories.getAllCategories(function(data) {
|
||||
if (data.categories.length === 0) {
|
||||
console.log('Setting up default categories...');
|
||||
|
||||
fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, default_categories) {
|
||||
default_categories = JSON.parse(default_categories);
|
||||
|
||||
for (var category in default_categories) {
|
||||
admin.categories.create(default_categories[category]);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log('Good.');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
setup_categories();
|
||||
|
||||
|
||||
|
||||
}(global.configuration));
|
||||
// Read config.js to grab redis info
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
utils = require('./public/src/utils.js');
|
||||
|
||||
console.log('Info: Checking for valid base configuration file');
|
||||
fs.readFile(path.join(__dirname, 'config.json'), function(err, data) {
|
||||
if (!err) {
|
||||
global.config = JSON.parse(data);
|
||||
global.config.url = global.config.base_url + (global.config.use_port ? ':' + global.config.port : '') + '/';
|
||||
global.config.upload_url = global.config.url + 'uploads/';
|
||||
console.log('Info: Base Configuration OK.');
|
||||
|
||||
var meta = require('./src/meta.js');
|
||||
meta.config.get(function(config) {
|
||||
for(c in config) {
|
||||
if (config.hasOwnProperty(c)) {
|
||||
global.config[c] = config[c];
|
||||
}
|
||||
}
|
||||
|
||||
var categories = require('./src/categories.js'),
|
||||
templates = require('./public/src/templates.js'),
|
||||
webserver = require('./src/webserver.js'),
|
||||
websockets = require('./src/websockets.js'),
|
||||
admin = {
|
||||
'categories': require('./src/admin/categories.js')
|
||||
};
|
||||
|
||||
DEVELOPMENT = true;
|
||||
|
||||
global.configuration = {};
|
||||
global.templates = {};
|
||||
|
||||
(function(config) {
|
||||
config['ROOT_DIRECTORY'] = __dirname;
|
||||
|
||||
templates.init([
|
||||
'header', 'footer', 'logout', 'admin/header', 'admin/footer', 'admin/index',
|
||||
'emails/reset', 'emails/reset_plaintext', 'emails/email_confirm', 'emails/email_confirm_plaintext',
|
||||
'emails/header', 'emails/footer', 'install/header', 'install/footer', 'install/redis'
|
||||
]);
|
||||
|
||||
templates.ready(function() {
|
||||
webserver.init();
|
||||
});
|
||||
|
||||
//setup scripts to be moved outside of the app in future.
|
||||
function setup_categories() {
|
||||
console.log('Info: Checking categories...');
|
||||
categories.getAllCategories(function(data) {
|
||||
if (data.categories.length === 0) {
|
||||
console.log('Info: Setting up default categories...');
|
||||
|
||||
fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, default_categories) {
|
||||
default_categories = JSON.parse(default_categories);
|
||||
|
||||
for (var category in default_categories) {
|
||||
admin.categories.create(default_categories[category]);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
console.log('Info: Good.');
|
||||
}
|
||||
});
|
||||
}
|
||||
setup_categories();
|
||||
}(global.configuration));
|
||||
});
|
||||
} else {
|
||||
// New install, ask setup questions
|
||||
console.log('Info: Configuration not found, starting NodeBB setup');
|
||||
var ask = function(question, callback) {
|
||||
process.stdin.resume();
|
||||
process.stdout.write(question + ': ');
|
||||
|
||||
process.stdin.once('data', function(data) {
|
||||
callback(data.toString().trim());
|
||||
});
|
||||
}
|
||||
|
||||
process.stdout.write(
|
||||
"\nWelcome to NodeBB!\nThis looks like a new installation, so you'll have to answer a " +
|
||||
"few questions about your environment before we can proceed with the setup.\n\n\nWhat is...\n\n"
|
||||
);
|
||||
|
||||
ask('... the publically accessible URL of this installation? (http://localhost)', function(base_url) {
|
||||
ask('... the port number of your install? (4567)', function(port) {
|
||||
ask('Will you be using a port number to access NodeBB? (y)', function(use_port) {
|
||||
ask('... the host IP or address of your Redis instance? (127.0.0.1)', function(redis_host) {
|
||||
ask('... the host port of your Redis instance? (6379)', function(redis_port) {
|
||||
ask('... your NodeBB secret? (keyboard mash for a bit here)', function(secret) {
|
||||
if (!base_url) base_url = 'http://localhost';
|
||||
if (!port) port = 4567;
|
||||
if (!use_port) use_port = true; else use_port = (use_port === 'y' ? true : false);
|
||||
if (!redis_host) redis_host = '127.0.0.1';
|
||||
if (!redis_port) redis_port = 6379;
|
||||
if (!secret) secret = utils.generateUUID();
|
||||
|
||||
var fs = require('fs'),
|
||||
path = require('path'),
|
||||
config = {
|
||||
secret: secret,
|
||||
base_url: base_url,
|
||||
port: port,
|
||||
use_port: use_port,
|
||||
redis: {
|
||||
host: redis_host,
|
||||
port: redis_port
|
||||
}
|
||||
}
|
||||
|
||||
fs.writeFile(path.join(__dirname, 'config.json'), JSON.stringify(config, null, 4), function(err) {
|
||||
if (err) throw err;
|
||||
else {
|
||||
process.stdout.write(
|
||||
"\n\nConfiguration Saved OK\n\nPlease start NodeBB again and navigate to " +
|
||||
base_url + (use_port ? ':' + port : '') + "/install to continue setup.\n\n"
|
||||
);
|
||||
process.exit();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
@ -1,23 +1,27 @@
|
||||
{
|
||||
"custom_mapping": {
|
||||
"admin/topics[^]*": "admin/topics",
|
||||
"admin/categories[^]*": "admin/categories",
|
||||
"admin/users[^]*": "admin/users",
|
||||
"admin/redis[^]*": "admin/redis",
|
||||
"admin/index[^]*": "admin/index",
|
||||
"admin/themes[^]*": "admin/themes",
|
||||
"admin/settings[^]*": "admin/settings",
|
||||
"admin/twitter[^]*": "admin/twitter",
|
||||
"admin/facebook[^]*": "admin/facebook",
|
||||
"admin/gplus[^]*": "admin/gplus",
|
||||
"users[^]*edit": "accountedit",
|
||||
"users[^]*friends": "friends",
|
||||
"users/[^]*": "account",
|
||||
"latest": "category",
|
||||
"popular": "category",
|
||||
"active": "category"
|
||||
},
|
||||
"force_refresh": {
|
||||
"logout": true
|
||||
}
|
||||
"custom_mapping": {
|
||||
"admin/topics[^]*": "admin/topics",
|
||||
"admin/categories[^]*": "admin/categories",
|
||||
"admin/users[^]*": "admin/users",
|
||||
"admin/redis[^]*": "admin/redis",
|
||||
"admin/index[^]*": "admin/index",
|
||||
"admin/themes[^]*": "admin/themes",
|
||||
"admin/settings[^]*": "admin/settings",
|
||||
"admin/twitter[^]*": "admin/twitter",
|
||||
"admin/facebook[^]*": "admin/facebook",
|
||||
"admin/gplus[^]*": "admin/gplus",
|
||||
"install/?$": "install/mail",
|
||||
"install/mail/?": "install/mail",
|
||||
"install/social/?": "install/social",
|
||||
"install/privileges/?": "install/privileges",
|
||||
"users[^]*edit": "accountedit",
|
||||
"users[^]*friends": "friends",
|
||||
"users/[^]*": "account",
|
||||
"latest": "category",
|
||||
"popular": "category",
|
||||
"active": "category"
|
||||
},
|
||||
"force_refresh": {
|
||||
"logout": true
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
|
||||
<h1>Step 2 – Basic Information</h1>
|
||||
|
||||
<form class="form-inline">
|
||||
<h3>Path Information</h3>
|
||||
<p>
|
||||
Please enter the web-accessible url that will be used to point to the NodeBB installation. If you are using a port number in the address,
|
||||
<strong>include it in the field below, not here</strong>. Do not include a trailing slash.<br />
|
||||
<input type="text" class="input-large" data-field="base_url" placeholder="http://www.example.org" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label class="checkbox"><input type="checkbox" data-field="use_port" checked /> Use port</label>
|
||||
</p>
|
||||
<p>
|
||||
<label>Port</label> <input type="number" class="input-mini" data-field="port" value="4567" placeholder="4567" />
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Path to uploads folder (relative to the root of the NodeBB install)<br />
|
||||
<input type="text" class="input-large" data-field="upload_url" value="/public/uploads" placeholder="/public/uploads" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<h3>NodeBB Secret</h3>
|
||||
<p>
|
||||
This "secret" is used to encode user sessions, so they are not stored in plaintext. Enter a bunch of random characters below:
|
||||
</p>
|
||||
<input type="text" class="input-xxlarge" data-field="secret" placeholder="n239he#dh9j9$jc4h%y4yuhnx9y(&#y9ryn9c3" />
|
||||
|
||||
<hr />
|
||||
<div class="pull-right">
|
||||
<button data-path="mail" class="btn btn-primary btn-large">Next – <i class="icon-envelope"></i> Mail</button>
|
||||
</div>
|
||||
<div>
|
||||
<button data-path="redis" class="btn btn-primary btn-large">Previous – <i class="icon-hdd"></i> Redis</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
nodebb_setup.prepare();
|
||||
|
||||
var portToggle = document.querySelector('input[data-field="use_port"]'),
|
||||
portEl = document.querySelector('input[data-field="port"]');
|
||||
|
||||
portToggle.addEventListener('change', function(e) {
|
||||
if (e.target.checked) portEl.disabled = false;
|
||||
else portEl.disabled = true;
|
||||
});
|
||||
})();
|
||||
</script>
|
@ -0,0 +1,144 @@
|
||||
|
||||
</div>
|
||||
<script>
|
||||
var nodebb_setup = {
|
||||
config: undefined,
|
||||
prepare: function() {
|
||||
// Bounce if config is not ready
|
||||
// if (nodebb_setup.config === undefined) {
|
||||
// ajaxify.go('install/redis');
|
||||
// app.alert({
|
||||
// alert_id: 'config-ready',
|
||||
// type: 'error',
|
||||
// timeout: 10000,
|
||||
// title: 'NodeBB Configuration Not Ready!',
|
||||
// message: 'NodeBB cannot proceed with setup at this time as Redis database information ' +
|
||||
// 'was not found. Please enter the information below.'
|
||||
// });
|
||||
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Come back in 500ms if the config isn't ready yet
|
||||
if (nodebb_setup.config === undefined) {
|
||||
console.log('Config not ready...');
|
||||
setTimeout(function() {
|
||||
nodebb_setup.prepare();
|
||||
}, 500);
|
||||
return;
|
||||
}
|
||||
|
||||
// Populate the fields on the page from the config
|
||||
var fields = document.querySelectorAll('#content [data-field]'),
|
||||
numFields = fields.length,
|
||||
x, key, inputType;
|
||||
for(x=0;x<numFields;x++) {
|
||||
key = fields[x].getAttribute('data-field');
|
||||
inputType = fields[x].getAttribute('type');
|
||||
if (nodebb_setup.config[key]) {
|
||||
switch(inputType) {
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'number':
|
||||
fields[x].value = nodebb_setup.config[key];
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
fields[x].checked = nodebb_setup.config[key] ? true : false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Save defaults, if they're not found in the config
|
||||
var defaultFields = [
|
||||
'use_port', 'port', 'upload_url', 'mailer:host',
|
||||
'mailer:port', 'privileges:manage_content',
|
||||
'privileges:manage_topic'
|
||||
],
|
||||
defaultVal;
|
||||
if (defaultFields.indexOf(key) !== -1) {
|
||||
console.log('saving default value: ', key);
|
||||
switch(inputType) {
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'number':
|
||||
defaultVal = fields[x].value;
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
defaultVal = fields[x].checked ? '1' : '0';
|
||||
break;
|
||||
}
|
||||
socket.emit('api:config.set', {
|
||||
key: key,
|
||||
value: defaultVal
|
||||
});
|
||||
nodebb_setup.config[key] = defaultVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
(function() {
|
||||
// Listen for field changes and auto-save on change
|
||||
var contentEl = document.getElementById('content');
|
||||
|
||||
contentEl.addEventListener('change', function(e) {
|
||||
if (e.target.hasAttribute('data-field')) {
|
||||
var key = e.target.getAttribute('data-field'),
|
||||
value;
|
||||
|
||||
switch(e.target.getAttribute('type')) {
|
||||
case 'text':
|
||||
case 'textarea':
|
||||
case 'number':
|
||||
value = e.target.value;
|
||||
break;
|
||||
case 'checkbox':
|
||||
value = e.target.checked ? 1 : 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
|
||||
socket.emit('api:config.set', { key: key, value: value });
|
||||
nodebb_setup.config[key] = value;
|
||||
}
|
||||
}, false);
|
||||
contentEl.addEventListener('click', function(e) {
|
||||
if (e.target.hasAttribute('data-path')) {
|
||||
var href = 'install/' + e.target.getAttribute('data-path');
|
||||
console.log(href);
|
||||
if (!e.target.disabled) ajaxify.go(href);
|
||||
}
|
||||
}, false);
|
||||
|
||||
socket.emit('api:config.get');
|
||||
socket.on('api:config.get', function(data) {
|
||||
nodebb_setup.config = data;
|
||||
});
|
||||
|
||||
socket.on('api:config.set', function(data) {
|
||||
if (data.status === 'ok') {
|
||||
app.alert({
|
||||
alert_id: 'config_status',
|
||||
timeout: 2500,
|
||||
title: 'Configuration Saved',
|
||||
message: 'Your changes to the NodeBB configuration have been saved',
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
app.alert({
|
||||
alert_id: 'config_status',
|
||||
timeout: 2500,
|
||||
title: 'Configuration Not Saved',
|
||||
message: 'NodeBB encountered a problem saving your changes',
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</body>
|
@ -0,0 +1,52 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>NodeBB</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="title" CONTENT="NodeBB">
|
||||
<meta name="description" content="Node.js/Redis/Socket.io powered forums for a new generation">
|
||||
<link href="/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||
<link href="/vendor/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" media="screen">
|
||||
<link rel="stylesheet" href="/vendor/fontawesome/css/font-awesome.min.css">
|
||||
<script type="text/javascript" src="http://code.jquery.com/jquery.js"></script>
|
||||
<script type="text/javascript" src="/vendor/jquery/js/jquery-ui-1.10.3.custom.min.js"></script>
|
||||
<script type="text/javascript" src="/vendor/bootstrap/js/bootstrap.min.js"></script>
|
||||
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
|
||||
<script type="text/javascript" src="/src/app.js"></script>
|
||||
<script type="text/javascript" src="/src/templates.js"></script>
|
||||
<script type="text/javascript" src="/src/ajaxify.js"></script>
|
||||
<script type="text/javascript" src="/src/jquery.form.js"></script>
|
||||
<script type="text/javascript" src="/src/utils.js"></script>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="/css/style.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="/install">NodeBB Installation</a>
|
||||
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<div class="nav-collapse collapse">
|
||||
<ul class="nav nodebb-inline-block">
|
||||
<li>
|
||||
<a data-tab="email" href="/install/email"><i class="icon-envelope"></i> Mail</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-tab="social" href="/install/social"><i class="icon-facebook"></i> Social</a>
|
||||
</li>
|
||||
<li>
|
||||
<a data-tab="privileges" href="/install/privileges"><i class="icon-legal"></i> Privileges</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="alert_window"></div>
|
||||
|
||||
<div class="container" id="content">
|
@ -0,0 +1,33 @@
|
||||
|
||||
<h1>Mailer Information</h1>
|
||||
|
||||
<form class="form-inline">
|
||||
<p>
|
||||
The mailer information is used when sending out registration confirmation emails to new users.
|
||||
It is also used to send password reset emails to users who have forgotten their password.
|
||||
</p>
|
||||
<p>
|
||||
The defaults here correspond to a local <code>sendmail</code> server, although any third-party
|
||||
mail server can be used.
|
||||
</p>
|
||||
<p>
|
||||
<label>Hostname</label> <input type="text" class="input-medium" data-field="mailer:host" value="127.0.0.1" placeholder="127.0.0.1" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Port</label> <input type="number" class="input-mini" data-field="mailer:port" value="25" placeholder="25" />
|
||||
</p>
|
||||
<p>
|
||||
<label>From</label> <input type="text" class="input-large" data-field="mailer:from" placeholder="John Smith <jsmith@example.org>" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
<div class="pull-right">
|
||||
<button data-path="social" class="btn btn-primary btn-large">Next – <i class="icon-facebook"></i> Social</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
nodebb_setup.prepare();
|
||||
})();
|
||||
</script>
|
@ -0,0 +1,46 @@
|
||||
|
||||
<h1>User Privilege Thresholds</h1>
|
||||
|
||||
<form class="form-inline">
|
||||
<p>
|
||||
Privilege thresholds grants a community membership the ability to moderate itself.
|
||||
These numbers denote the minimum amount of user reputation required before the
|
||||
corresponding privilege is unlocked.
|
||||
</p>
|
||||
<p>
|
||||
Reputation is gained when other users favourite posts that you have made.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<label>Manage Content</label> <input type="number" class="input-mini" value="1000" placeholder="1000" data-field="privileges:manage_content" />
|
||||
</p>
|
||||
<p>
|
||||
Users with reach the "Manage Content" threshold are able to edit/delete other users' posts.
|
||||
</p>
|
||||
<p>
|
||||
<label>Manage Topics</label> <input type="number" class="input-mini" value="2000" placeholder="2000" data-field="privileges:manage_topic" />
|
||||
</p>
|
||||
<p>
|
||||
Users with reach the "Manage Topics" threshold are able to edit, lock, pin, close, and delete topics.
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
<div class="pull-right">
|
||||
<button id="start-nodebb" class="btn btn-success btn-large"><i class="icon-thumbs-up"></i> Start using NodeBB!</button>
|
||||
</div>
|
||||
<div>
|
||||
<button data-path="social" class="btn btn-primary btn-large">Previous – <i class="icon-facebook"></i> Social</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
nodebb_setup.prepare();
|
||||
|
||||
var startEl = document.getElementById('start-nodebb');
|
||||
startEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
document.location.href = '/';
|
||||
});
|
||||
})();
|
||||
</script>
|
@ -0,0 +1,81 @@
|
||||
|
||||
<h1>Step 1 – Establish Redis Connection</h1>
|
||||
|
||||
<p class="lead">
|
||||
Thanks for choosing to install NodeBB! We'll need some information to set up your installation
|
||||
configuration...
|
||||
</p>
|
||||
<p>
|
||||
Please enter the details of your Redis server here. If redis is hosted on the same
|
||||
server as NodeBB, you can leave the default values as-is.
|
||||
</p>
|
||||
|
||||
<form class="form-horizontal">
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="redis-hostname">Hostname</label>
|
||||
<div class="controls">
|
||||
<input type="text" id="redis-hostname" class="input-medium" placeholder="127.0.0.1" value="127.0.0.1" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label" for="redis-port">Port</label>
|
||||
<div class="controls">
|
||||
<input type="number" id="redis-port" class="input-mini" placeholder="6379" value="6379" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<button class="btn" id="test-redis">Test</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
<div class="pull-right">
|
||||
<button data-path="basic" class="btn btn-primary btn-large" disabled>Next – <i class="icon-cog"></i> Basic</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
var testRedisEl = document.getElementById('test-redis');
|
||||
testRedisEl.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
if (e.target.className.indexOf('testing') === -1) {
|
||||
e.target.className += ' testing';
|
||||
e.target.innerHTML = '<i class="icon-spinner icon-spin"></i> Testing';
|
||||
socket.once('api:config.redisTest', function(data) {
|
||||
if (data && data.status === 'ok') {
|
||||
e.target.className = 'btn btn-success testing';
|
||||
e.target.innerHTML = 'Redis Connection Successful!';
|
||||
|
||||
app.alert({
|
||||
type: 'success',
|
||||
timeout: 10000,
|
||||
alert_id: 'config-ready',
|
||||
title: 'Setup Ready!',
|
||||
message: 'NodeBB is ready to continue with the setup process. ' +
|
||||
'Any changes you make now will be saved automatically'
|
||||
});
|
||||
|
||||
// Grab configs from the db and enable the 'next' button
|
||||
socket.emit('api:config.setup', {
|
||||
'redis/host': document.getElementById('redis-hostname').value,
|
||||
'redis/port': document.getElementById('redis-port').value
|
||||
});
|
||||
} else {
|
||||
e.target.className = 'btn btn-danger';
|
||||
e.target.innerHTML = 'Could not connect to Redis, click here to test again';
|
||||
}
|
||||
});
|
||||
socket.emit('api:config.redisTest');
|
||||
}
|
||||
});
|
||||
|
||||
var nextBtn = document.querySelector('button[data-path="basic"]');
|
||||
socket.once('api:config.setup', function(data) {
|
||||
nodebb_setup.config = data;
|
||||
nextBtn.disabled = false;
|
||||
});
|
||||
})();
|
||||
</script>
|
@ -0,0 +1,47 @@
|
||||
|
||||
<h1>Social Media Logins</h1>
|
||||
|
||||
<form class="form-inline">
|
||||
<p>
|
||||
You may opt to allow users to register and login in via a social media account, if that
|
||||
social network supports doing so.
|
||||
</p>
|
||||
|
||||
<h3>Facebook</h3>
|
||||
<p>
|
||||
<label>Application ID</label> <input type="text" class="input-medium" data-field="social:facebook:app_id" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Application Secret</label> <input type="text" class="input-large" data-field="social:facebook:secret" />
|
||||
</p>
|
||||
|
||||
<h3>Twitter</h3>
|
||||
<p>
|
||||
<label>Application Key</label> <input type="text" class="input-medium" data-field="social:twitter:key" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Application Secret</label> <input type="text" class="input-large" data-field="social:twitter:secret" />
|
||||
</p>
|
||||
|
||||
<h3>Google</h3>
|
||||
<p>
|
||||
<label>Application ID</label> <input type="text" class="input-xxlarge" data-field="social:google:id" />
|
||||
</p>
|
||||
<p>
|
||||
<label>Application Secret</label> <input type="text" class="input-large" data-field="social:google:secret" />
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
<div class="pull-right">
|
||||
<button data-path="privileges" class="btn btn-primary btn-large">Next – <i class="icon-legal"></i> Privileges</button>
|
||||
</div>
|
||||
<div>
|
||||
<button data-path="mail" class="btn btn-primary btn-large">Previous – <i class="icon-envelope"></i> Mail</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function() {
|
||||
nodebb_setup.prepare();
|
||||
})();
|
||||
</script>
|
@ -0,0 +1,58 @@
|
||||
var utils = require('./../public/src/utils.js'),
|
||||
RDB = require('./redis.js'),
|
||||
async = require('async');
|
||||
|
||||
(function(Meta) {
|
||||
Meta.testRedis = function(callback) {
|
||||
RDB.set('nodebb-redis-test', 'foobar', function(err, res) {
|
||||
if (!err) {
|
||||
RDB.get('nodebb-redis-test', function(err, res) {
|
||||
if (!err && res === 'foobar') {
|
||||
callback(true);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Meta.config = {
|
||||
get: function(callback) {
|
||||
var config = {};
|
||||
|
||||
async.waterfall([
|
||||
function(next) {
|
||||
RDB.hkeys('config', function(err, keys) {
|
||||
next(err, keys);
|
||||
});
|
||||
},
|
||||
function(keys, next) {
|
||||
async.each(keys, function(key, next) {
|
||||
RDB.hget('config', key, function(err, value) {
|
||||
if (!err) {
|
||||
config[key] = value;
|
||||
}
|
||||
|
||||
next(err);
|
||||
});
|
||||
}, next);
|
||||
}
|
||||
], function(err) {
|
||||
if (!err) {
|
||||
config.status = 'ok';
|
||||
callback(config);
|
||||
} else callback({
|
||||
status: 'error'
|
||||
});
|
||||
});
|
||||
},
|
||||
set: function(field, value, callback) {
|
||||
RDB.hset('config', field, value, function(err, res) {
|
||||
callback(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
}(exports));
|
@ -0,0 +1,44 @@
|
||||
|
||||
var RDB = require('../redis.js');
|
||||
|
||||
(function(Install) {
|
||||
Install.create_routes = function(app) {
|
||||
|
||||
(function() {
|
||||
var routes = ['basic', 'redis', 'mail', 'social', 'privileges'];
|
||||
|
||||
for (var i=0, ii=routes.length; i<ii; i++) {
|
||||
(function(route) {
|
||||
app.get('/install/' + route, function(req, res) {
|
||||
res.send(templates['install/header'] + app.create_route('install/' + route) + templates['install/footer']);
|
||||
});
|
||||
}(routes[i]));
|
||||
}
|
||||
}());
|
||||
|
||||
//todo consolidate.
|
||||
app.get('/install', function(req, res) {
|
||||
res.send(templates['install/header'] + app.create_route('install/basic') + templates['install/footer']);
|
||||
});
|
||||
app.get('/install/index', function(req, res) {
|
||||
res.send(templates['install/header'] + app.create_route('install/basic') + templates['install/footer']);
|
||||
});
|
||||
|
||||
|
||||
function api_method(req, res) {
|
||||
switch(req.params.method) {
|
||||
case 'basic' :
|
||||
res.send('{}');
|
||||
break;
|
||||
|
||||
default :
|
||||
res.send('{}');
|
||||
}
|
||||
}
|
||||
|
||||
app.get('/api/install/:method/:tab?*', api_method);
|
||||
app.get('/api/install/:method*', api_method);
|
||||
};
|
||||
|
||||
|
||||
}(exports));
|
Loading…
Reference in New Issue