Skip to content

Commit

Permalink
fix custom logo and url_prefix issues
Browse files Browse the repository at this point in the history
use config.web.logo instead of config.web['logo-sm']
  • Loading branch information
rlidwka committed Mar 29, 2015
1 parent bf40ceb commit d7c95d6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/GUI/css/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
20 changes: 12 additions & 8 deletions lib/index-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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)
})
Expand Down
2 changes: 1 addition & 1 deletion lib/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit d7c95d6

Please sign in to comment.