From b3984948d031231e3794e53e3105da419e1f6275 Mon Sep 17 00:00:00 2001 From: Rich Leland Date: Tue, 21 Jun 2016 09:49:57 -0400 Subject: [PATCH 1/3] Add redirects for subaccounts docs changes --- js/redirect.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/js/redirect.js b/js/redirect.js index 877593a3..e4d20f16 100644 --- a/js/redirect.js +++ b/js/redirect.js @@ -1,11 +1,27 @@ (function($) { - var PATH = location.pathname, HASH = location.hash, EXTENSION = '', PATH_SPACE = '-', HASH_SPACE = '-'; + var PATH = location.pathname + , HASH = location.hash + , EXTENSION = '' + , PATH_SPACE = '-' + , HASH_SPACE = '-' + , customRedirects; + + customRedirects = { + '#header-subaccounts': '/api/subaccounts#header-introduction', + '#header-terminology': '/api/subaccounts#header-terminology', + '#header-managing-subaccount-data-as-a-service-provider': '/api/subaccounts#header-managing-subaccount-data-as-a-service-provider', + '#header-managing-master-account-data-as-a-service-provider': '/api/subaccounts#header-managing-master-account-data-as-a-service-provider' + }; // check if we are on the API page with an Apiary hash - if ((PATH === '/api/' || PATH === '/api/index.html') && (HASH.indexOf('introduction') >= 0 || HASH.indexOf('reference') >= 0)) { + if ((PATH === '/api/' || PATH === '/api/index' || PATH === '/api/index.html') && (HASH.indexOf('introduction') >= 0 || HASH.indexOf('reference') >= 0)) { var newPath = convertHashToPath(HASH); redirect(location.protocol + '//' + location.host + PATH + newPath); + } else if ((PATH === '/api/' || PATH === '/api/index' || PATH === '/api/index.html')) { + if (HASH in customRedirects) { + redirect(location.protocol + '//' + location.host + customRedirects[HASH]); + } } @@ -50,6 +66,7 @@ */ function customMapping(type, endpoint, method) { var path = ''; + console.log(endpoint); switch (endpoint) { case 'substitutions-reference': // add endpoint From 27b7ea9fe8a393c938300c43f2f4de19c6592d06 Mon Sep 17 00:00:00 2001 From: Rich Leland Date: Tue, 21 Jun 2016 10:13:37 -0400 Subject: [PATCH 2/3] Remove console log --- js/redirect.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/redirect.js b/js/redirect.js index e4d20f16..8b995191 100644 --- a/js/redirect.js +++ b/js/redirect.js @@ -66,7 +66,6 @@ */ function customMapping(type, endpoint, method) { var path = ''; - console.log(endpoint); switch (endpoint) { case 'substitutions-reference': // add endpoint From 0faa41bcfa6fbdbb8f1282739dca5d7b40a274dd Mon Sep 17 00:00:00 2001 From: Rich Leland Date: Tue, 21 Jun 2016 14:25:47 -0400 Subject: [PATCH 3/3] Clean up conditional for redirects --- js/redirect.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/js/redirect.js b/js/redirect.js index 8b995191..84d1c69b 100644 --- a/js/redirect.js +++ b/js/redirect.js @@ -14,12 +14,11 @@ }; // check if we are on the API page with an Apiary hash - if ((PATH === '/api/' || PATH === '/api/index' || PATH === '/api/index.html') && (HASH.indexOf('introduction') >= 0 || HASH.indexOf('reference') >= 0)) { - var newPath = convertHashToPath(HASH); - - redirect(location.protocol + '//' + location.host + PATH + newPath); - } else if ((PATH === '/api/' || PATH === '/api/index' || PATH === '/api/index.html')) { - if (HASH in customRedirects) { + if (PATH === '/api/' || PATH === '/api/index' || PATH === '/api/index.html') { + if (HASH.indexOf('introduction') >= 0 || HASH.indexOf('reference') >= 0) { + var newPath = convertHashToPath(HASH); + redirect(location.protocol + '//' + location.host + PATH + newPath); + } else if (HASH in customRedirects) { redirect(location.protocol + '//' + location.host + customRedirects[HASH]); } }