commit: ff91d68f30f8768ac44d644a71e10b5d10a6692f
parent 489611c13b0096efc0d7de6c32656a6e976c6159
Author: rekkabell <rekkabell@gmail.com>
Date: Tue, 14 Jan 2020 20:44:14 -0500
Merge branch 'master' of https://github.com/hundredrabbits/Grimgrains
Diffstat:
M | 404.html | 37 | +++++++++++++++++++++++++------------ |
1 file changed, 25 insertions(+), 12 deletions(-)
diff --git a/404.html b/404.html
@@ -13,17 +13,30 @@ permalink: /404.html
<title>GrimGrains</title>
</head>
<body>
- <header>
- <a id='logo' href='home.html'><img src='../media/interface/logo.png' alt='Grimgrains'></a>
- </header>
- <nav>
- <ul><li class='home'><a href='home.html'>Home</a></li><li class='about'><a href='about.html'>About</a></li><li class='tools'><a href='tools.html'>Tools</a></li><li class='nutrition'><a href='nutrition.html'>Nutrition</a></li><li class='right'><a href='http://twitter.com/grimgrains' target='_blank'>Twitter</a></li></ul>
- </nav>
- <main>
- <p>The page you were looking for does not exist, if you think this was a mistake, please report the broken link <a href='https://github.com/hundredrabbits/Grimgrains' target='_blank'>here</a>, or go back to the <a href='/site/home.html'>home</a>.</p>
- </main>
- <footer>
- <a href='about.html'>Grimgrains</a> © 2014—2020<br><a href='http://100r.co/' target='_blank'>Hundred Rabbits</a>
- </footer>
+ <p>The page you were looking for does not exist, if you think this was a mistake, please report the broken link <a href='https://github.com/hundredrabbits/Grimgrains' target='_blank'>here</a>, or go back to the <a href='/site/home.html'>home</a>.</p>
+
+ <script>
+ 'use strict'
+
+ const parts = window.location.pathname.split("/")
+ const target = parts.slice(-1)
+ const filename = toFilename(target[0])
+ const filepath = `https:/grimgrains.com/site/${filename}.html`
+
+ if(UrlExists(filepath)){
+ window.location.replace(filepath)
+ }
+
+ function UrlExists(url) {
+ const http = new XMLHttpRequest()
+ http.open('HEAD', url, false)
+ http.send()
+ return http.status!=404
+ }
+
+ function toFilename(str){
+ return `${str}`.replace('#','').replace(/[\W_]+/g,"_").toLowerCase().trim()
+ }
+ </script>
</body>
</html>