Improve the 404 page (#2550)

- Don't actually change the URL
- Give more choices about what to do in the event of a 404
This commit is contained in:
Misty Stanley-Jones 2017-03-30 12:56:20 -07:00 committed by GitHub
parent bfca2777ae
commit 9902ceb84c
2 changed files with 29 additions and 34 deletions

34
404.md
View File

@ -1,7 +1,9 @@
---
layout: null
title: 404 Redirector
title: "Sorry, we can't find that page"
permalink: /404.html
noratings: true
notoc: true
tree: false
---
<script language="JavaScript">
@ -71,6 +73,8 @@ if (archive==false) {
} // end of check for .md
} // end of check for archive
var path = window.location.pathname.replace("#","");
var phrase = decodeURIComponent(path.replace(/\/+/g, ' ').trim());
if (gonnaFwd) {
newURL = baseURL + newURL;
@ -79,8 +83,28 @@ if (gonnaFwd) {
window.location.href = newURL;
document.write('<meta http-equiv="refresh" content="0; url=' + newURL + '">')
} else {
window.location.replace("/sorry/#" + forwardingURL);
window.location.href = "/sorry/#" + forwardingURL;
document.write('<meta http-equiv="refresh" content="0; url=/sorry/#' + forwardingURL + '">')
function populateTicket()
{
var searchVal = phrase;
var output = new Array();
output.push("<ul><li><a href='https://github.com/docker/docker.github.io/issues/new?title=404 at: ");
output.push(path);
output.push("&body=URL: ");
output.push(path);
output.push("' class='nomunge'>File a ticket</a></li>");
output.push("<li><a href='/search/?q=" + phrase + "'</a>Search for <tt>&quot;" + phrase + "&quot;</tt></a></li>");
output.push("<li><a href='/search/'>Try a different search</a></li>");
output.push("<li><a href='/'>Go to the index</a></li></ul><br />");
document.getElementById("sorryMsg").innerHTML = output.join("");
}
window.onload = populateTicket;
}
</script>
<br/>
We tried to forward you to where we think you might be going, but we couldn't
find a good match. You've got some choices:
<span id="sorryMsg" />

View File

@ -1,29 +0,0 @@
---
title: "Sorry, we can't find that page"
noratings: true
notoc: true
tree: false
---
<script language="JavaScript">
function populateTicket()
{
var output = new Array();
output.push("You can <a href='https://github.com/docker/docker.github.io/issues/new?title=404 at: ");
output.push(window.location.hash.replace("#",""));
output.push("&body=URL: ");
output.push(window.location.hash.replace("#",""));
output.push("' class='nomunge'>file a ticket</a> or <a href='/search/?q=");
output.push(window.location.hash.replace("#",""));
output.push("'>try a search</a>!");
document.getElementById("sorryMsg").innerHTML = output.join("");
}
window.onload = populateTicket;
</script>
<br/>
We tried to forward you to where we think you might be going, but we couldn't
find a good match.
<span id="sorryMsg" />