From d7c95d6cd6a62c16aa8c93ea1681dca32111c481 Mon Sep 17 00:00:00 2001 From: Alex Kocharin Date: Sun, 29 Mar 2015 22:59:08 +0300 Subject: [PATCH] fix custom logo and url_prefix issues use config.web.logo instead of config.web['logo-sm'] --- lib/GUI/css/styles.less | 3 ++- lib/index-web.js | 20 ++++++++++++-------- lib/static/main.css | 2 +- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/GUI/css/styles.less b/lib/GUI/css/styles.less index 10ec3dd17..6c99480c3 100644 --- a/lib/GUI/css/styles.less +++ b/lib/GUI/css/styles.less @@ -27,7 +27,8 @@ .npm-logo { width: 79px; height: @mainHeaderHeight; - background-image: url( /-/logo-sm ); + // https://example.org/sinopia/-/static/../../-/logo + background-image: url( ../../-/logo ); background-repeat: no-repeat; background-position: center center; diff --git a/lib/index-web.js b/lib/index-web.js index 5341c2610..2942ca4aa 100644 --- a/lib/index-web.js +++ b/lib/index-web.js @@ -40,7 +40,9 @@ module.exports = function(config, auth, storage) { var template = Handlebars.compile(fs.readFileSync(require.resolve('./GUI/index.hbs'), 'utf8')) } app.get('/', function(req, res, next) { - var base = config.url_prefix || req.protocol + '://' + req.get('host') + var base = config.url_prefix + ? config.url_prefix.replace(/\/$/, '') + : req.protocol + '://' + req.get('host') res.setHeader('Content-Type', 'text/html') storage.get_local(function(err, packages) { @@ -72,11 +74,9 @@ module.exports = function(config, auth, storage) { }) app.get('/-/logo', function(req, res, next) { - res.sendFile(config.web.logo ? config.web.logo : __dirname + '/static/logo.png') - }) - - app.get('/-/logo-sm', function(req, res, next) { - res.sendFile(config.web.logosm ? config.web.logosm : __dirname + '/static/logo-sm.png') + res.sendFile( config.web && config.web.logo + ? config.web.logo + : __dirname + '/static/logo-sm.png' ) }) app.post('/-/login', function(req, res, next) { @@ -89,13 +89,17 @@ module.exports = function(config, auth, storage) { res.cookies.set('token', auth.aes_encrypt(str).toString('base64')) } - var base = config.url_prefix || req.protocol + '://' + req.get('host') + var base = config.url_prefix + ? config.url_prefix.replace(/\/$/, '') + : req.protocol + '://' + req.get('host') res.redirect(base) }) }) app.post('/-/logout', function(req, res, next) { - var base = config.url_prefix || req.protocol + '://' + req.get('host') + var base = config.url_prefix + ? config.url_prefix.replace(/\/$/, '') + : req.protocol + '://' + req.get('host') res.cookies.set('token', '') res.redirect(base) }) diff --git a/lib/static/main.css b/lib/static/main.css index 1a800d6d7..7e6803f04 100644 --- a/lib/static/main.css +++ b/lib/static/main.css @@ -7241,7 +7241,7 @@ Original style from softwaremaniacs.org (c) Ivan Sagalaev