Skip to content

Commit b50c83d

Browse files
Merge pull request #3 from codeplaysoftware/improved-pages-routes-resolution
Improved Pages Routes Resolution
2 parents f8e1f5f + b1be021 commit b50c83d

File tree

7 files changed

+82
-1
lines changed

7 files changed

+82
-1
lines changed

angular.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"tsConfig": "tsconfig.app.json",
3030
"inlineStyleLanguage": "scss",
3131
"assets": [
32+
"src/404.html",
3233
"src/favicon.png",
3334
"src/robots.txt",
3435
"src/assets",

routes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@
1010
/news
1111
/playground
1212
/contributors
13+
/settings
14+
/privacy
15+
/cookies
16+
/404

scripts/routes/generate.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ def fetch_news_routes(base_url: str):
6262
return routes
6363

6464

65+
def fetch_contributor_routes(base_url: str):
66+
routes = []
67+
68+
for item in load_all_feed_items(base_url, 'contributors'):
69+
routes.append(f'/contributors/{item["_username"]}')
70+
71+
return routes
72+
73+
6574
def fetch_academy_routes(base_url: str):
6675
routes = []
6776

@@ -81,7 +90,7 @@ def fetch_academy_routes(base_url: str):
8190

8291

8392
def generate(base_url: str):
84-
routes = fetch_academy_routes(base_url) + fetch_news_routes(base_url)
93+
routes = fetch_academy_routes(base_url) + fetch_news_routes(base_url) + fetch_contributor_routes(base_url)
8594
return '\n'.join(routes)
8695

8796

src/404.html

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<title>SYCL.tech - 404</title>
5+
<meta http-equiv="refresh" content="0; url=/404">
6+
<script type="text/javascript">window.location.href = "/404"</script>
7+
<link rel="icon" type="image/png" href="favicon.png"/>
8+
</head>
9+
<body></body>
10+
</html>

src/app/app.routes.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { PlaygroundComponent } from './pages/playground/playground.component';
3535
import { CookiesComponent } from './pages/cookies/cookies.component';
3636
import { PrivacyComponent } from './pages/privacy/privacy.component';
3737
import { SettingsComponent } from './pages/settings/settings.component';
38+
import { Error404Component } from './pages/404/error-404.component';
3839

3940
export const routes: Routes = [
4041
{
@@ -114,4 +115,13 @@ export const routes: Routes = [
114115
path: 'contributors/:username',
115116
component: ContributorComponent
116117
},
118+
{
119+
path: '404',
120+
component: Error404Component,
121+
pathMatch: 'full'
122+
},
123+
{
124+
path: '**',
125+
redirectTo: '404'
126+
}
117127
];
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<section id="intro">
2+
<div class="wrapper panel fancy intro">
3+
<div>
4+
<header>
5+
<h1>404 - Page Not Found</h1>
6+
<h2>This page seems to have gone missing. We're sorry about that! Please check back soon if you think this
7+
should be here or report it to us.</h2>
8+
</header>
9+
</div>
10+
<div>
11+
<span class="material-symbols-outlined panel-icon">search_off</span>
12+
</div>
13+
</div>
14+
</section>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*---------------------------------------------------------------------------------------------
2+
*
3+
* Copyright (C) Codeplay Software Ltd.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*--------------------------------------------------------------------------------------------*/
18+
19+
import { ChangeDetectionStrategy, Component } from '@angular/core';
20+
import { CommonModule } from '@angular/common';
21+
22+
@Component({
23+
selector: 'st-error-404',
24+
standalone: true,
25+
imports: [
26+
CommonModule
27+
],
28+
templateUrl: './error-404.component.html',
29+
changeDetection: ChangeDetectionStrategy.OnPush
30+
})
31+
export class Error404Component {
32+
33+
}

0 commit comments

Comments
 (0)