You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by db...@apache.org on 2015/09/14 21:11:07 UTC

docs commit: Implemented 404 page with redirect for old docs links. This closes #342.

Repository: cordova-docs
Updated Branches:
  refs/heads/cordova-website 1cf05bdfd -> 5fdeeb351


Implemented 404 page with redirect for old docs links. This closes #342.


Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/5fdeeb35
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/5fdeeb35
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/5fdeeb35

Branch: refs/heads/cordova-website
Commit: 5fdeeb35124473ed6eeec93de8837c95a57a363d
Parents: 1cf05bd
Author: riknoll <ri...@microsoft.com>
Authored: Fri Sep 11 17:37:37 2015 -0700
Committer: Dmitry Blotsky <dm...@gmail.com>
Committed: Mon Sep 14 12:10:47 2015 -0700

----------------------------------------------------------------------
 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(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/5fdeeb35/www/http/404.html
----------------------------------------------------------------------
diff --git a/www/http/404.html b/www/http/404.html
index 833ba60..425fd20 100644
--- a/www/http/404.html
+++ b/www/http/404.html
@@ -4,4 +4,12 @@ title: Page Not Found
 permalink: 404.html
 ---
 
-Uh-oh.
+<div class="not-found-container">
+    <div class="not-found-header">
+        <h1>404: Not Found</h1>
+    </div>
+    <div id="not-found-redirect-alert" class="not-found-redirect">
+        <div class="alert alert-warning" role="alert">We recently moved our documentation. It looks like the page you were trying to access may have moved <a id="redirect-link">here</a></div>
+    </div>
+</div>
+<script type="text/javascript" src="{{ site.baseurl }}/static/js/404.js" defer></script>

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/5fdeeb35/www/static/css-src/_home.scss
----------------------------------------------------------------------
diff --git a/www/static/css-src/_home.scss b/www/static/css-src/_home.scss
index e83bec5..d03027a 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;
+}

http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/5fdeeb35/www/static/js/404.js
----------------------------------------------------------------------
diff --git a/www/static/js/404.js b/www/static/js/404.js
new file mode 100644
index 0000000..ec9ce44
--- /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");
+            }
+        }
+    });
+}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org