Skip to content

Commit e5fe873

Browse files
Remove html, body and head tags from 404.html page (#1085)
* Add javascript to 404 page that redirects all /live/... urls to the playtorch.dev website * Change the fallback url to an empty string, and don't perform the redirect if newUrl is an empty string * Remove entire /live folder so that navigating to /live/anything returns a 404 * Fix window.location.path -- should be pathname * Remove html, head and body tags from 404 page because it's already wrapped by those tags by jekyll
1 parent 50f8815 commit e5fe873

File tree

1 file changed

+67
-73
lines changed

1 file changed

+67
-73
lines changed

404.html

+67-73
Original file line numberDiff line numberDiff line change
@@ -5,85 +5,79 @@
55
layout: general
66
---
77

8-
<!DOCTYPE html>
9-
<html>
10-
<head>
11-
<script type="text/javascript" charset="utf-8">
12-
const FALLBACK_URL = '';
13-
const REDIRECT_STYLE = {
14-
// Redirect completely, appending the path to the newly specified location.
15-
// This is useful for project renames or moving to a different org.
16-
FULL: 0,
17-
// Redirect to the specific location, losing path information
18-
// This is useful when you just want to capture the audience to known working page.
19-
SIMPLE: 1,
20-
// Redirect to the project's 404 page, injecting the original URL.
21-
FOUROHFOUR_DEFAULT: 2,
22-
// Redirect to the specified path, replacing ${from} with the original URL.
23-
FOUROHFOUR_CUSTOM: 3,
24-
};
8+
<script type="text/javascript" charset="utf-8">
9+
const FALLBACK_URL = '';
10+
const REDIRECT_STYLE = {
11+
// Redirect completely, appending the path to the newly specified location.
12+
// This is useful for project renames or moving to a different org.
13+
FULL: 0,
14+
// Redirect to the specific location, losing path information
15+
// This is useful when you just want to capture the audience to known working page.
16+
SIMPLE: 1,
17+
// Redirect to the project's 404 page, injecting the original URL.
18+
FOUROHFOUR_DEFAULT: 2,
19+
// Redirect to the specified path, replacing ${from} with the original URL.
20+
FOUROHFOUR_CUSTOM: 3,
21+
};
2522

26-
const PROJECTS = {
27-
live: {
28-
location: 'https://playtorch.dev/',
29-
style: REDIRECT_STYLE.FULL,
30-
},
31-
};
23+
const PROJECTS = {
24+
live: {
25+
location: 'https://playtorch.dev/',
26+
style: REDIRECT_STYLE.FULL,
27+
},
28+
};
3229

33-
// eg "https://facebook.github.io/flux/docs/overview/"
34-
const ORIGINAL_URL = window.location.href;
35-
// eg [ "", "flux", "docs", "overview", "" ]
36-
const PATH_PARTS = window.location.pathname.split('/');
37-
// eg "flux"
38-
const PROJECT = PATH_PARTS[1];
39-
// eg "docs/overview/"
40-
const SUBPATH = PATH_PARTS.slice(2).join('/');
30+
// eg "https://facebook.github.io/flux/docs/overview/"
31+
const ORIGINAL_URL = window.location.href;
32+
// eg [ "", "flux", "docs", "overview", "" ]
33+
const PATH_PARTS = window.location.pathname.split('/');
34+
// eg "flux"
35+
const PROJECT = PATH_PARTS[1];
36+
// eg "docs/overview/"
37+
const SUBPATH = PATH_PARTS.slice(2).join('/');
4138

42-
43-
// Perform the redirect only for explicitly defined projects.
44-
// Otherwise show the 404 page below
45-
if (PROJECTS.hasOwnProperty(PROJECT)) {
46-
let newUrl = '';
47-
let project = PROJECTS[PROJECT];
48-
switch (project.style) {
49-
case REDIRECT_STYLE.FULL:
50-
newUrl = project.location + SUBPATH;
51-
break;
52-
case REDIRECT_STYLE.SIMPLE:
53-
newUrl = project.location;
54-
break;
55-
case REDIRECT_STYLE.FOUROHFOUR_DEFAULT:
56-
newUrl = project.location + '404.html?from=' + ORIGINAL_URL;
57-
break;
58-
case REDIRECT_STYLE.FOUROHFOUR_CUSTOM:
59-
newUrl = project.location.replace('${from}', ORIGINAL_URL);
60-
break;
61-
default:
62-
newUrl = FALLBACK_URL;
63-
}
39+
40+
// Perform the redirect only for explicitly defined projects.
41+
// Otherwise show the 404 page below
42+
if (PROJECTS.hasOwnProperty(PROJECT)) {
43+
let newUrl = '';
44+
let project = PROJECTS[PROJECT];
45+
switch (project.style) {
46+
case REDIRECT_STYLE.FULL:
47+
newUrl = project.location + SUBPATH;
48+
break;
49+
case REDIRECT_STYLE.SIMPLE:
50+
newUrl = project.location;
51+
break;
52+
case REDIRECT_STYLE.FOUROHFOUR_DEFAULT:
53+
newUrl = project.location + '404.html?from=' + ORIGINAL_URL;
54+
break;
55+
case REDIRECT_STYLE.FOUROHFOUR_CUSTOM:
56+
newUrl = project.location.replace('${from}', ORIGINAL_URL);
57+
break;
58+
default:
59+
newUrl = FALLBACK_URL;
60+
}
6461

65-
if (newUrl !== '') {
66-
window.location.href = newUrl;
67-
}
68-
}
62+
if (newUrl !== '') {
63+
window.location.href = newUrl;
64+
}
65+
}
6966

70-
</script>
71-
</head>
72-
<body>
73-
<div style="text-align: center;">
74-
<img src="{{ site.baseurl }}/assets/images/404_sign.png" />
67+
</script>
68+
69+
<div style="text-align: center;">
70+
<img src="{{ site.baseurl }}/assets/images/404_sign.png" />
7571

76-
<h1>Oops!</h1>
72+
<h1>Oops!</h1>
7773

78-
<h4>You've reached a dead end.</h4>
74+
<h4>You've reached a dead end.</h4>
7975

80-
<h4>
81-
If you feel like something should be here, you can <a href="https://github.com/pytorch/pytorch.github.io/issues">open an issue</a> on GitHub.
82-
</h4>
76+
<h4>
77+
If you feel like something should be here, you can <a href="https://github.com/pytorch/pytorch.github.io/issues">open an issue</a> on GitHub.
78+
</h4>
8379

84-
<h4>
85-
Click <a href="/">here</a> to go back to the main page.
86-
</h4>
87-
</div>
88-
</body>
89-
</html>
80+
<h4>
81+
Click <a href="/">here</a> to go back to the main page.
82+
</h4>
83+
</div>

0 commit comments

Comments
 (0)