fix custom logo and url_prefix issues

use config.web.logo instead of config.web['logo-sm']
This commit is contained in:
Alex Kocharin 2015-03-29 22:59:08 +03:00
parent bf40ceb064
commit d7c95d6cd6
3 changed files with 15 additions and 10 deletions

View File

@ -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;

View File

@ -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)
})

View File

@ -7241,7 +7241,7 @@ Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiac
.body .main-header .npm-logo {
width: 79px;
height: 50px;
background-image: url(/-/logo-sm );
background-image: url(../../-/logo );
background-repeat: no-repeat;
background-position: center center;
}