Fix issue with wrong base-href for github.io

This commit is contained in:
ziajka 2018-04-09 15:24:41 +02:00
parent b0461d69ea
commit 6286980327
6 changed files with 21 additions and 8 deletions

View File

@ -29,7 +29,8 @@
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"electronProd": "environments/environment.electron.prod.ts",
"electronDev": "environments/environment.electron.ts"
"electronDev": "environments/environment.electron.ts",
"githubProd": "environments/environment.github.prod.ts"
}
}
],

View File

@ -55,7 +55,7 @@ after_script:
# greenkeeper-lockfile support
- greenkeeper-lockfile-upload
# publish on gns3.github.io
- yarn ng build --base-href /${TRAVIS_BRANCH}/
- yarn buildforgithub --base-href /${TRAVIS_BRANCH}/
- export GIT_LAST_LOG="$(git log -1 --pretty=%B)"
- git clone https://${GITHUB_CREDENTIALS}@github.com/GNS3/gns3.github.io.git github-pages
- mkdir -p github-pages/${TRAVIS_BRANCH}

View File

@ -13,6 +13,7 @@
"startforelectron": "ng serve -e electronDev",
"build": "ng build",
"buildforelectron": "ng build -e electronProd",
"buildforgithub": "ng build -e githubProd",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",

View File

@ -0,0 +1,5 @@
export const environment = {
production: true,
electron: false,
githubio: true
};

View File

@ -5,5 +5,6 @@
export const environment = {
production: false,
electron: false
electron: false,
githubio: false
};

View File

@ -3,15 +3,20 @@
<head>
<meta charset="utf-8">
<title>GNS3 Web UI Demo</title>
<!-- It's important to have base here because of the script below //-->
<base href="/">
<script>
var userAgent = navigator.userAgent.toLowerCase();
// in case we're running in electron because we need it for resources
if (userAgent.indexOf(' electron/') > -1) {
document.write('<base href="' + document.location + '" />');
}
// in case base href is not set, when not defined during the build time (for instance github.io pages)
else if (document.getElementsByTagName('base').length == 0) {
document.write('<base href="/" />');
var base = document.getElementsByTagName('base');
if(base.length > 0) {
base.href = document.location;
}
else {
document.write('<base href="' + document.location + '" />');
}
}
</script>