Merge remote branch 'origin/master' into wosch
authorWolfram Schneider <wosch@indexdata.dk>
Mon, 11 Aug 2014 08:30:10 +0000 (08:30 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Mon, 11 Aug 2014 08:30:10 +0000 (08:30 +0000)
examples/htdocs/mike.html
src/mkws-core.js
src/mkws-team.js
src/mkws-widget-categories.js
test/bin/apache-template-update

index 90caf92..934fd6e 100644 (file)
@@ -7,8 +7,11 @@
       var mkws_config = {
        pazpar2_url:        "//sp-mkws.indexdata.com/service-proxy/",
         // For now, we have to provide known-bad credentials to skip user/pw login: see bug MKSP-125
-       service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy/?command=auth&action=perconfig&username=XXX&password=XXX"
-        // For explicit credential-based authentication, add: &username=orex&password=orexmkc
+        service_proxy_auth: undefined,
+        // Was: //sp-mkws.indexdata.com/service-proxy/?command=auth&action=perconfig&username=XXX&password=XXX
+//        pp2_hostname: "sp-mkws.indexdata.com",
+//        sp_path: "service-proxy/",
+//        credentials: "XXX/XXX",
       };
     </script>
     <script type="text/javascript" src="//code.jquery.com/jquery-1.10.0.min.js"></script>
index a3a1ac9..3c2ff2a 100644 (file)
@@ -166,7 +166,11 @@ mkws.setMkwsConfig = function(overrides) {
   var config_default = {
     use_service_proxy: true,
     pazpar2_url:        "//mkws.indexdata.com/service-proxy/",
-    service_proxy_auth: "//mkws.indexdata.com/service-proxy-auth",
+    service_proxy_auth: undefined, // generally rolled from the next three properties
+    // Was: //mkws.indexdata.com/service-proxy-auth
+    pp2_hostname: "mkws.indexdata.com",
+    sp_path: "service-proxy-auth",
+    credentials: undefined,
     lang: "",
     sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]],
     perpage_options: [10, 20, 30, 50],
@@ -623,8 +627,28 @@ mkws.pagerNext = function(tname) {
       }
     */
 
+    function sp_auth_url(config) {
+      if (config.service_proxy_auth) {
+        mkws.log("using pre-baked sp_auth_url '" + config.service_proxy_auth + "'");
+        return config.service_proxy_auth;
+      } else {
+        var s = '//';
+        s += config.auth_hostname ? config.auth_hostname : config.pp2_hostname;
+        s += '/' + config.sp_path + '?command=auth&action=perconfig';
+        var c = config.credentials;
+        if (c) {
+          if (c) {
+            s += ('&username=' + c.substr(0, c.indexOf('/')) +
+                  '&password=' + c.substr(c.indexOf('/')+1));
+          }
+        }
+        mkws.log("generated sp_auth_url '" + s + "'");
+        return s;
+      }
+    }
+
     if (mkws.config.use_service_proxy) {
-      authenticateSession(mkws.config.service_proxy_auth,
+      authenticateSession(sp_auth_url(mkws.config),
                           mkws.config.service_proxy_auth_domain,
                           mkws.config.pazpar2_url);
     } else {
index a2dd506..9abed73 100644 (file)
@@ -293,7 +293,7 @@ function team($, teamName) {
     if (maxrecs) params.maxrecs = maxrecs;
     if (torusquery) {
       if (!mkws.config.use_service_proxy)
-        alert("can't narrow search by torusquery when Service Proxy is not in use");
+        alert("can't narrow search by torusquery when not authenticated");
       params.torusquery = torusquery;
     }
 
index a11e522..339e28b 100644 (file)
@@ -1,8 +1,8 @@
 mkws.registerWidgetType('Categories', function() {
   var that = this;
 
-  if (!this.config.use_service_proxy) {
-    alert("can't use categories widget without Service Proxy");
+  if (!mkws.authenticated) {
+    alert("can't use categories widget when not authenticated");
     return;
   }
 
index 25cfdaf..6c90341 100755 (executable)
@@ -18,7 +18,7 @@ export MKWS_ROOT=$(pwd)/..
 
 MKWS_OS=debian
 APACHE_VERSION=2.2
-apache2=$(env PATH=/usr/bin:/usr/sbin which apache2 httpd false 2>/dev/null | head -1)
+apache2=$(env PATH=/bin:/usr/bin:/usr/sbin which apache2 httpd false 2>/dev/null | head -1)
 
 case $(uname) in
   Darwin ) MKWS_OS=macos