mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-07-12 07:41:33 +02:00
small refactor to install/web.js
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
var winston = require('winston'),
|
||||
express = require('express'),
|
||||
bodyParser = require('body-parser'),
|
||||
fs = require('fs'),
|
||||
path = require('path'),
|
||||
less = require('less'),
|
||||
@@ -24,6 +25,14 @@ web.install = function(port) {
|
||||
port = port || 8080;
|
||||
winston.info('Launching web installer on port ', port);
|
||||
|
||||
app.use(express.static('public', {}));
|
||||
app.engine('tpl', require('templates.js').__express);
|
||||
app.set('view engine', 'tpl');
|
||||
app.set('views', path.join(__dirname, '../src/views'));
|
||||
app.use(bodyParser.urlencoded({
|
||||
extended: true
|
||||
}));
|
||||
|
||||
async.parallel([compileLess, compileJS], function() {
|
||||
setupRoutes();
|
||||
launchExpress(port);
|
||||
@@ -32,11 +41,6 @@ web.install = function(port) {
|
||||
|
||||
|
||||
function launchExpress(port) {
|
||||
app.use(express.static('public', {}));
|
||||
app.engine('tpl', require('templates.js').__express);
|
||||
app.set('view engine', 'tpl');
|
||||
app.set('views', path.join(__dirname, '../src/views'));
|
||||
|
||||
var server = app.listen(port, function() {
|
||||
var host = server.address().address;
|
||||
winston.info('Web installer listening on http://%s:%s', host, port);
|
||||
@@ -44,10 +48,11 @@ function launchExpress(port) {
|
||||
}
|
||||
|
||||
function setupRoutes() {
|
||||
app.get('/', install);
|
||||
app.get('/', welcome);
|
||||
app.post('/', install);
|
||||
}
|
||||
|
||||
function install(req, res, next) {
|
||||
function welcome(req, res) {
|
||||
var dbs = ['redis', 'mongo'],
|
||||
databases = [];
|
||||
|
||||
@@ -63,6 +68,10 @@ function install(req, res, next) {
|
||||
});
|
||||
}
|
||||
|
||||
function install(req, res) {
|
||||
console.log(req.body);
|
||||
}
|
||||
|
||||
function compileLess(callback) {
|
||||
fs.readFile(path.join(__dirname, '../public/less/install.less'), function(err, style) {
|
||||
less.render(style.toString(), function(err, css) {
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
<h1>Welcome to the NodeBB Installer</h1>
|
||||
You are just a few steps away from launching your own NodeBB forum!
|
||||
</p>
|
||||
<form>
|
||||
<form action="/" method="post">
|
||||
<p>
|
||||
<h1><small>Create an Administrator account</small></h1>
|
||||
<hr />
|
||||
@@ -97,6 +97,8 @@
|
||||
</div>
|
||||
|
||||
<div id="database-config"></div>
|
||||
|
||||
<button type="submit" class="btn btn-lg btn-success">Install NodeBB</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user