From e4964da584c6829eb499ac7b51aa6f08d5886de3 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 22 Aug 2014 12:37:41 +0100 Subject: [PATCH] Default pazpar2_url is now undefined. That means mkws.pazpar2_url() generates it from pieces. Add new piece pp2_path, with sensible default. I am not super-happy about how protocol-independent links are adjusted. It turns out that for some reason it's really important to get the leading "http:" in front of the pazpar2_url, but NOT the service_proxy_auth URL. As a result, we have the pazpar2_url() function consulting document.location.protocol to generate its result (while the sp_auth_url() function doesn't need to bother), AND we still have the adjustment code in place but now it only fires when an explicit pazpar_url configuration item is provided by the application. It works, but there has to be a cleaner way. --- src/mkws-core.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/mkws-core.js b/src/mkws-core.js index abe414d..ea6c49c 100644 --- a/src/mkws-core.js +++ b/src/mkws-core.js @@ -167,10 +167,10 @@ mkws.setMkwsConfig = function(overrides) { var config_default = { use_service_proxy: true, - pazpar2_url: "//mkws.indexdata.com/service-proxy/", - service_proxy_auth: undefined, // generally rolled from the next three properties - // Was: //mkws.indexdata.com/service-proxy-auth + pazpar2_url: undefined, pp2_hostname: "mkws.indexdata.com", + pp2_path: "service-proxy", + service_proxy_auth: undefined, sp_path: "service-proxy-auth", sp_auth_query: undefined, // Will be: "command=auth&action=perconfig", sp_auth_credentials: undefined, @@ -360,7 +360,14 @@ mkws.pagerNext = function(tname) { mkws.pazpar2_url = function() { - return mkws.config.pazpar2_url; + if (mkws.config.pazpar2_url) { + mkws.log("using pre-baked pazpar2_url '" + mkws.config.pazpar2_url + "'"); + return mkws.config.pazpar2_url; + } else { + var s = document.location.protocol + "//" + mkws.config.pp2_hostname + "/" + mkws.config.pp2_path + "/"; + mkws.log("generated pazpar2_url '" + s + "'"); + return s; + } }; @@ -640,7 +647,7 @@ mkws.pazpar2_url = function() { } // protocol independent link for pazpar2: "//mkws/sp" -> "https://mkws/sp" - if (mkws.config.pazpar2_url.match(/^\/\//)) { + if (mkws.pazpar2_url().match(/^\/\//)) { mkws.config.pazpar2_url = document.location.protocol + mkws.config.pazpar2_url; log("adjusted protocol independent link to " + mkws.pazpar2_url()); } -- 1.7.10.4