better templating and styling for #2099

v1.18.x
Julian Lam 10 years ago
parent 6f40a731f5
commit 24ac7ba316

@ -12,5 +12,8 @@
"user.posts": "Posts made by %1", "user.posts": "Posts made by %1",
"user.topics": "Topics created by %1", "user.topics": "Topics created by %1",
"user.favourites": "%1's Favourite Posts", "user.favourites": "%1's Favourite Posts",
"user.settings": "User Settings" "user.settings": "User Settings",
"maintenance.text": "%1 is currently undergoing maintenance. Please come back another time.",
"maintenance.messageIntro": "Additionally, the administator has left this message:"
} }

@ -0,0 +1,94 @@
'use strict';
(function(module) {
var winston = require('winston'),
async = require('async'),
nconf = require('nconf'),
session = require('express-session'),
db, pg;
module.questions = [
{
name: 'postgres:host',
description: 'Host IP or address of your PostgreSQL instance',
'default': nconf.get('postgres:host') || '127.0.0.1'
},
{
name: 'postgres:port',
description: 'Host port of your MongoDB instance',
'default': nconf.get('postgres:port') || 5432
},
{
name: 'postgres:role',
description: 'PostgreSQL Role name'
},
// {
// name: 'postgres:password',
// description: 'Password of your MongoDB database',
// hidden: true
// },
{
name: "postgres:database",
description: "Which database to use",
'default': nconf.get('postgres:database') || 'nodebb'
}
];
module.init = function(callback) {
try {
var sessionStore;
pg = require('pg');
if (!nconf.get('redis')) {
sessionStore = require('connect-pg-simple')(session);
} else {
sessionStore = require('connect-redis')(session);
}
} catch (err) {
winston.error('Unable to initialize PostgreSQL! Is PostgreSQL installed? Error :' + err.message);
process.exit(0);
}
if (!nconf.get('postgres:password') {
winston.warn('You have no PostgreSQL password setup!');
}
var connString = 'postgres://' + nconf.get('postgres:role') + ':' + nconf.get('postgres:password') + '@' + nconf.get('mongopostgres:host') + ':' + nconf.get('postgres:port') + '/' + nconf.get('postgres:database');
mongoClient.connect(connString, function(err, _db, done) {
if(err) {
winston.error("NodeBB could not connect to your PostgreSQL database. PostgreSQL returned the following error: " + err.message);
process.exit(0);
}
db = _db;
module.client = db;
if (!nconf.get('redis')) {
module.sessionStore = new sessionStore({
pg: pg,
conString: conString,
tableName: 'user_sessions'
});
} else {
module.sessionStore = new sessionStore({
client: require('./redis').connect(),
ttl: 60 * 60 * 24 * 14
});
}
require('./postgres/main')(db, module, done);
require('./postgres/hash')(db, module, done);
require('./postgres/sets')(db, module, done);
require('./postgres/sorted')(db, module, done);
require('./postgres/list')(db, module, done);
});
};
module.close = function() {
db.close();
};
}(exports));

@ -355,6 +355,7 @@ middleware.renderHeader = function(req, res, callback) {
templateValues.user = results.user; templateValues.user = results.user;
templateValues.customCSS = results.customCSS; templateValues.customCSS = results.customCSS;
templateValues.customJS = results.customJS; templateValues.customJS = results.customJS;
templateValues.maintenanceHeader = meta.config.maintenanceMode === '1' ^ !!results.isAdmin
app.render('header', templateValues, callback); app.render('header', templateValues, callback);
}); });
@ -443,13 +444,19 @@ middleware.addExpiresHeaders = function(req, res, next) {
}; };
middleware.maintenanceMode = function(req, res, next) { middleware.maintenanceMode = function(req, res, next) {
var render = function() { var allowedRoutes = [
res.render('maintenance', { '/login'
site_title: meta.config.site_title || 'NodeBB' ],
}); render = function() {
}; middleware.buildHeader(req, res, function() {
res.render('maintenance', {
site_title: meta.config.site_title || 'NodeBB',
message: meta.config.maintenanceModeMessage
});
});
};
if (meta.config.maintenanceMode === '1') { if (meta.config.maintenanceMode === '1' && allowedRoutes.indexOf(req.url) === -1) {
if (!req.user) { if (!req.user) {
return render(); return render();
} else { } else {

@ -13,6 +13,10 @@
When the forum is in maintenance mode, all requests will be redirected to a static holding page. When the forum is in maintenance mode, all requests will be redirected to a static holding page.
Administrators are exempt from this redirection, and are able to access the site normally. Administrators are exempt from this redirection, and are able to access the site normally.
</p> </p>
<div class="form-group">
<label for="maintenanceModeMessage">Maintenance Message</label>
<textarea class="form-control" data-field="maintenanceModeMessage"></textarea>
</div>
</form> </form>
</div> </div>
</div> </div>

@ -1,9 +1,12 @@
<!DOCTYPE html> <h1 class="text-center">[[pages:maintenance.text, {site_title}]]</h1>
<html> <h2 class="text-center"><i class="fa fa-wrench fa-3x"></i></h2>
<head> <!-- IF message -->
<title>{site_title} is currently in Maintenance Mode</title> <div class="row maintenance">
</head> <div class="col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2">
<body> <p class="lead text-center">[[pages:maintenance.messageIntro]]</p>
<h1>This site is in maintenance mode. Try again later.</h1> <div class="well">
</body> {message}
</html> </div>
</div>
</div>
<!-- ENDIF message -->
Loading…
Cancel
Save