Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Support deploying on github pages with /docs and /libs generated by sphinx #33

Merged
merged 5 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"src/assets/icons/favicon.ico",
"src/assets",
"src/robots.txt",
"src/sitemap.xml"
"src/sitemap.xml",
"src/404.html"
],
"styles": [
"src/styles.scss",
Expand Down
41 changes: 41 additions & 0 deletions src/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<!DOCTYPE html>
<!-- Taken from https://github.com/rafgraph/spa-github-pages -->
<html>
<head>
<meta charset="utf-8">
<title>Single Page Apps for GitHub Pages</title>
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script takes the current url and converts the path and query
// string into just a query string, and then redirects the browser
// to the new url with only a query string and hash fragment,
// e.g. https://www.foo.tld/one/two?a=b&c=d#qwe, becomes
// https://www.foo.tld/?/one/two&a=b~and~c=d#qwe
// Note: this 404.html file must be at least 512 bytes for it to work
// with Internet Explorer (it is currently > 512 bytes)

// If you're creating a Project Pages site and NOT using a custom domain,
// then set pathSegmentsToKeep to 1 (enterprise users may need to set it to > 1).
// This way the code will only replace the route part of the path, and not
// the real directory in which the app resides, for example:
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
// https://username.github.io/repo-name/?/one/two&a=b~and~c=d#qwe
// Otherwise, leave pathSegmentsToKeep as 0.
var pathSegmentsToKeep = 1;

var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);

</script>
</head>
<body>
</body>
</html>
34 changes: 0 additions & 34 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { AboutComponent } from './about';
import { DocComponent,
DocsResolver } from './doc';
import { HomeComponent } from './home';
import { LibComponent } from './lib';
import { LibsComponent } from './libs';
import { MaritimeComponent } from './projects/maritime';
import { NotFoundComponent } from './not-found';
import { OmniverseComponent } from './projects/omniverse';
Expand All @@ -24,28 +20,6 @@ const routes: Routes = [
path: 'about',
component: AboutComponent,
},
{
path: 'docs',
component: DocComponent,
resolve: {
docsInfo: DocsResolver
}
},
{
path: 'docs/:version',
component: DocComponent,
resolve: {
docsInfo: DocsResolver
}
},
{
// Gets the page associated with a specific version
path: 'docs/:version/:page',
component: DocComponent,
resolve: {
docsInfo: DocsResolver
}
},
{
path: 'features',
component: FeaturesComponent,
Expand All @@ -54,14 +28,6 @@ const routes: Routes = [
path: 'home',
component: HomeComponent,
},
{
path: 'libs',
component: LibsComponent,
},
{
path: 'libs/:lib',
component: LibComponent,
},
{
path: 'media',
component: MediaComponent,
Expand Down
4 changes: 2 additions & 2 deletions src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div></div>
<a routerLink='/features' routerLinkActive='active'>Features</a>
<a routerLink='/showcase' routerLinkActive='active'>Showcase</a>
<a routerLink='/docs' routerLinkActive='active'>Docs</a>
<a href='docs'>Docs</a>
<a href='https://community.gazebosim.org' title="Discussion forum">Community</a>
<a class="moreButton" role="button" [matMenuTriggerFor]="moreMenu">More</a>
<mat-menu #moreMenu="matMenu">
Expand All @@ -37,7 +37,7 @@
<mat-menu x-position="before" #menu="matMenu">
<button mat-menu-item routerLink="/about">About</button>
<button mat-menu-item routerLink="/features">Features</button>
<button mat-menu-item routerLink="/docs">Docs</button>
<a mat-menu-item href='docs'>Docs</a>
<a mat-menu-item href='https://community.gazebosim.org' title="Discussion forum">Community</a>
<a mat-menu-item href='https://answers.gazebosim.org' title="Technical help">Answers</a>
<a mat-menu-item href="https://blog.openrobotics.org/tag/gazebo">Blog</a>
Expand Down
16 changes: 0 additions & 16 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,40 +23,27 @@ import { MarkdownModule, MarkedOptions } from 'ngx-markdown';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { AboutComponent } from './about';
import { DocComponent,
DocsResolver } from './doc';
import { DocService } from './doc/doc.service';
import { ErrorInterceptor } from './error-interceptor';
import { FeaturesComponent } from './features';
import { HomeComponent } from './home';
import { LibComponent } from './lib';
import { LibsComponent } from './libs';
import { LibsService } from './libs';
import { MediaComponent } from './media';
import { MaritimeComponent } from './projects/maritime';
import { NotFoundComponent } from './not-found';
import { OmniverseComponent } from './projects/omniverse';
import { ShowcaseComponent } from './showcase';
import { SupportComponent } from './support';
import { ListedFilterPipe } from './doc/listed-filter.pipe';
import { SafePipe } from './doc/safe.pipe';

@NgModule({
declarations: [
AppComponent,
AboutComponent,
DocComponent,
FeaturesComponent,
LibComponent,
LibsComponent,
ListedFilterPipe,
MediaComponent,
HomeComponent,
MaritimeComponent,
NotFoundComponent,
OmniverseComponent,
SupportComponent,
SafePipe,
],
imports: [
AppRoutingModule,
Expand Down Expand Up @@ -93,10 +80,7 @@ import { SafePipe } from './doc/safe.pipe';
ShowcaseComponent,
],
providers: [
DocsResolver,
DocService,
ErrorInterceptor,
LibsService
],
bootstrap: [AppComponent]
})
Expand Down
26 changes: 25 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,31 @@
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

<!-- Start Single Page Apps for GitHub Pages -->
<!-- Taken from https://github.com/rafgraph/spa-github-pages -->
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// MIT License
// https://github.com/rafgraph/spa-github-pages
// This script checks to see if a redirect is present in the query string,
// converts it back into the correct url and adds it to the
// browser's history using window.history.replaceState(...),
// which won't cause the browser to attempt to load the new url.
// When the single page app is loaded further down in this file,
// the correct url will be waiting in the browser's history for
// the single page app to route accordingly.
(function(l) {
if (l.search[1] === '/' ) {
var decoded = l.search.slice(1).split('&').map(function(s) {
return s.replace(/~and~/g, '&')
}).join('?');
window.history.replaceState(null, null,
l.pathname.slice(0, -1) + decoded + l.hash
);
}
}(window.location))
</script>
<!-- End Single Page Apps for GitHub Pages -->
<style>
body, html {
background-color: #ffffff;
Expand Down