From 9ba819f700105073ac451b794e613d794b9e5982 Mon Sep 17 00:00:00 2001 From: riknoll Date: Fri, 11 Sep 2015 17:37:37 -0700 Subject: [PATCH] Implemented 404 page with redirect for old docs links --- www/http/404.html | 10 +++++++++- www/static/css-src/_home.scss | 21 +++++++++++++++++++++ www/static/js/404.js | 30 ++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 www/static/js/404.js diff --git a/www/http/404.html b/www/http/404.html index 833ba6070ae..425fd20063e 100644 --- a/www/http/404.html +++ b/www/http/404.html @@ -4,4 +4,12 @@ permalink: 404.html --- -Uh-oh. +
+
+

404: Not Found

+
+
+ +
+
+ diff --git a/www/static/css-src/_home.scss b/www/static/css-src/_home.scss index e83bec553b3..d03027a88db 100644 --- a/www/static/css-src/_home.scss +++ b/www/static/css-src/_home.scss @@ -2,7 +2,11 @@ body { + height: 100%; +} +html { + height: 100%; } #hero { @@ -260,3 +264,20 @@ img#logo_top { margin: 15px 0; a { padding-left:30px; } } + +.not-found-container { + height: 60%; + margin: auto; + width: 75%; +} + +.not-found-header { + padding-top: 15%; + text-align: center; +} + +.not-found-redirect { + margin-bottom: 20px; + text-align: center; + display: none; +} diff --git a/www/static/js/404.js b/www/static/js/404.js new file mode 100644 index 00000000000..ec9ce449e06 --- /dev/null +++ b/www/static/js/404.js @@ -0,0 +1,30 @@ + +var splitUrl = window.location.href.split(/(docs\/..\/[\d\.edge]+)/); + +if(splitUrl.length > 2) { + var baseUrl = splitUrl[0]; + var versionString = splitUrl[1]; + var pageExtension = splitUrl.slice(2).join(""); + + pageExtension = pageExtension.split("#")[0]; + pageExtension = pageExtension.replace(".md", ""); + pageExtension = pageExtension.replace(/_/g, "/"); + pageExtension = pageExtension.replace("config/ref", "config_ref"); + pageExtension = pageExtension.replace("plugin/ref", "plugin_ref"); + pageExtension = pageExtension.replace("display/name", "display_name"); + pageExtension = pageExtension.replace("platform/plugin/versioning/ref", "platform_plugin_versioning_ref"); + + var newUrl = baseUrl + versionString + pageExtension; + + // Try the new URL to see if it exists + $.ajax({ + url: newUrl, + statusCode: { + 200: function() { + // If it does, show it to the user + $("#redirect-link").attr("href", newUrl); + $("#not-found-redirect-alert").css("display", "block"); + } + } + }); +}