Merge branch 'master' into templateallthemarkup
authorJason Skomorowski <jason@indexdata.com>
Mon, 22 Sep 2014 13:32:46 +0000 (09:32 -0400)
committerJason Skomorowski <jason@indexdata.com>
Mon, 22 Sep 2014 13:32:46 +0000 (09:32 -0400)
15 files changed:
Makefile
doc/Makefile
doc/drupaljson.pl [new file with mode: 0755]
examples/apache2/mkws-examples-mike
examples/htdocs/mike.html
examples/htdocs/mkws-widget-wimp.css [new file with mode: 0644]
examples/htdocs/mkws-widget-wimp.html [new file with mode: 0644]
examples/htdocs/mkws-widget-wimp.js [new file with mode: 0644]
src/mkws-core.js
src/mkws-team.js
src/mkws-widget-categories.js
test/Makefile
test/package.json
test/spec/mkws-config.js
tools/apache2/mkws-live

index e80e8e3..dc14855 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ phantomjs p p-all phantomjs-all jsb:
        ${MAKE} -C./test $@
 
 # must be called once after GIT checkout
-setup: 
+setup: all
        ${MAKE} -C./test node-modules
 
 check: setup check-js phantomjs
index 2a6b99b..d87c1f8 100644 (file)
@@ -45,9 +45,16 @@ all: $(DOCS)
 
 clean:
        rm -f $(DOCS)
+       rm -f *.drupal.html
 
 distclean: clean uninstall
 
+push:
+       pandoc --toc README.markdown > README.drupal.html
+       pandoc --toc mkws-manual.markdown > mkws-manual.drupal.html
+       cat README.drupal.html | ./drupaljson.pl | curl --upload-file - http://www.indexdata.com/script/node/332?services_token=cda1e26e5733ce3f604773e94f0721df5c31a948 -v --header "Content-Type:application/json"
+       cat mkws-manual.drupal.html | ./drupaljson.pl | curl --upload-file - http://www.indexdata.com/script/node/323?services_token=cda1e26e5733ce3f604773e94f0721df5c31a948 -v --header "Content-Type:application/json"
+
 help:
-       @echo "make [ all | install | clean | distclean ]"
+       @echo "make [ all | install | clean | distclean | push ]"
 
diff --git a/doc/drupaljson.pl b/doc/drupaljson.pl
new file mode 100755 (executable)
index 0000000..0135867
--- /dev/null
@@ -0,0 +1,9 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use JSON;
+
+local $/; # enable localized slurp mode
+my %rec_hash = ('body' => {'und' => [{'value' => <STDIN>}]});
+my $json = encode_json \%rec_hash;
+print $json;
index 7b1b31a..757e785 100644 (file)
@@ -1,10 +1,10 @@
 <VirtualHost *:80>
     ServerName x.example.indexdata.com
-    DocumentRoot /usr/local/src/git/mkws/examples/htdocs/
-    Alias /tools/htdocs/ /usr/local/src/git/mkws/tools/htdocs/
-    Alias /src/ /usr/local/src/git/mkws/src/
-    Alias /jasmine/ /usr/local/src/git/mkws/examples/jasmine/
-    Alias /test/ /usr/local/src/git/mkws/test/
+    DocumentRoot /Users/mike/git/work/mkws/examples/htdocs/
+    Alias /tools/htdocs/ /Users/mike/git/work/mkws/tools/htdocs/
+    Alias /src/ /Users/mike/git/work/mkws/src/
+    Alias /jasmine/ /Users/mike/git/work/mkws/examples/jasmine/
+    Alias /test/ /Users/mike/git/work/mkws/test/
 
     <Directory />
         Allow from all
index 5d794a0..2419ac5 100644 (file)
@@ -2,19 +2,12 @@
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>MKWS demo</title>
-    <link rel="stylesheet" type="text/css" href="tools/htdocs/mkws.css" />
     <script type="text/javascript">
       var mkws_config = {
-        // For now, we have to provide known-bad credentials to skip user/pw login: see bug MKSP-125
-        // Was: //sp-mkws.indexdata.com/service-proxy/?command=auth&action=perconfig&username=XXX&password=XXX
-        pp2_hostname: "x.sp-mkws.indexdata.com",
-        sp_path: "service-proxy/",
-        sp_auth_query: "command=auth&action=perconfig",
-        sp_auth_credentials: "XXX/XXX",
-        // ### This should automatically follow pp2_hostname
-       pazpar2_url:        "//x.sp-mkws.indexdata.com/service-proxy/",
+//        pp2_hostname: "x.sp-mkws.indexdata.com",
       };
     </script>
+    <link rel="stylesheet" type="text/css" href="tools/htdocs/mkws.css" />
     <script type="text/javascript" src="tools/htdocs/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
     <script type="text/javascript" src="tools/htdocs/handlebars-v1.1.2.js"></script>
diff --git a/examples/htdocs/mkws-widget-wimp.css b/examples/htdocs/mkws-widget-wimp.css
new file mode 100644 (file)
index 0000000..2212e25
--- /dev/null
@@ -0,0 +1,37 @@
+.mkwsWimp {
+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+  background: #FCFBFA;
+  padding: 0.5em 1em 0.25em;
+  box-shadow: 0 0 2px 0 #7F8F93;
+  border-radius: 0 0 1.5em;
+  -moz-border-radius: 0 0 1.5em;
+  -webkit-border-radius: 0 0 1.5em;
+  line-height: 1.4;
+  color: #86979B;
+  background: radial-gradient(ellipse at center,  #ffffff 0%,#f8f8f8 100%);
+}
+
+h2 {
+  font-size: 100%;
+  color: #4A5456;
+  padding-bottom: .5em;
+}
+
+ul {
+  margin: 0;
+  padding: 0;
+}
+
+li {
+  margin: .95em .25em;
+  padding-top: .75em;
+  border-top: 1px dotted #BEC8CC;
+  font-size: 90%;
+  list-style: none;
+}
+
+a {
+  text-decoration: none;
+  font-weight:bold;
+  color: #2B77AF;
+}
diff --git a/examples/htdocs/mkws-widget-wimp.html b/examples/htdocs/mkws-widget-wimp.html
new file mode 100644 (file)
index 0000000..b203ef2
--- /dev/null
@@ -0,0 +1,8 @@
+<html>
+  <div style="max-width: 18em; margin: 1.5em 1.5em">
+    <script src="//mkws.indexdata.com/mkws-complete.js"></script>
+    <script src="mkws-widget-wimp.js"></script>
+    <link rel="stylesheet" type="text/css" href="mkws-widget-wimp.css" />
+    <div class="mkwsWimp" autosearch="!param!q"></div>
+  </div>
+</html>
diff --git a/examples/htdocs/mkws-widget-wimp.js b/examples/htdocs/mkws-widget-wimp.js
new file mode 100644 (file)
index 0000000..4b1425b
--- /dev/null
@@ -0,0 +1,36 @@
+var mkws_config = {
+   service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=wimp&password=wimp6363"
+};
+
+mkws.registerWidgetType('Wimp', function() {
+  if (!this.config.perpage) this.config.perpage = 5;
+  if (!this.config.sort) this.config.sort = "position";
+  this.team.registerTemplate('Wimp', '\
+<h2>Results from Wimp</h2>\
+<ul>\
+{{#each hits}}\
+  <li>\
+    {{#mkws-first md-electronic-url}}\
+    <a href="{{this}}">\
+    {{/mkws-first}}\
+      {{md-title}}\
+    </a>\
+  {{#if md-title-remainder}}\
+    <span>{{md-title-remainder}}</span>\
+  {{/if}}\
+  {{#if md-title-responsibility}}\
+    <span><i>{{md-title-responsibility}}</i></span>\
+  {{/if}}\
+  </li>\
+{{/each}}\
+</ul>\
+');
+
+  var that = this;
+  var template = that.team.loadTemplate(that.config.template || "Wimp");
+  this.team.queue("records").subscribe(function(data) {
+    that.node.html(template(data));
+  }); 
+  that.autosearch();
+});
+
index b44ca58..718c350 100644 (file)
@@ -168,13 +168,13 @@ 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
-    pp2_hostname: "mkws.indexdata.com",
-    sp_path: "service-proxy-auth",
-    sp_auth_query: undefined, // Will be: "command=auth&action=perconfig",
-    sp_auth_credentials: undefined,
+    pazpar2_url: undefined,
+    pp2_hostname: "sp-mkws.indexdata.com",
+    pp2_path: "service-proxy",
+    service_proxy_auth: undefined,
+    sp_auth_path: "service-proxy/",
+    sp_auth_query: "command=auth&action=perconfig",
+    sp_auth_credentials: "XXX/XXX", // Should be undefined: see bug MKSP-125.
     lang: "",
     sort_options: [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]],
     perpage_options: [10, 20, 30, 50],
@@ -257,6 +257,18 @@ mkws.pagerNext = function(tname) {
 };
 
 
+mkws.pazpar2_url = function() {
+  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;
+  }
+};
+
+
 // wrapper to provide local copy of the jQuery object.
 (function($) {
   var log = mkws.log;
@@ -533,9 +545,9 @@ mkws.pagerNext = function(tname) {
       }
 
       // 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.config.pazpar2_url);
+        log("adjusted protocol independent link to " + mkws.pazpar2_url());
       }
 
       if (mkws.config.responsive_design_width) {
@@ -574,7 +586,7 @@ mkws.pagerNext = function(tname) {
       } else {
        var s = '//';
        s += config.auth_hostname ? config.auth_hostname : config.pp2_hostname;
-       s += '/' + config.sp_path;
+       s += '/' + config.sp_auth_path;
         var q = config.sp_auth_query;
         if (q) {
           s += '?' + q;
@@ -592,7 +604,7 @@ mkws.pagerNext = function(tname) {
     if (mkws.config.use_service_proxy && !mkws.authenticated && !mkws.authenticating) {
       authenticateSession(sp_auth_url(mkws.config),
                           mkws.config.service_proxy_auth_domain,
-                          mkws.config.pazpar2_url);
+                          mkws.pazpar2_url());
     } else if (!mkws.authenticating) {
       // raw pp2 or we have a session already open
       runAutoSearches();
index c2d7fca..92536f1 100644 (file)
@@ -96,7 +96,7 @@ function team($, teamName) {
   // then register the form submit event with the pz2.search function
   // autoInit is set to true on default
   m_paz = new pz2({ "windowid": teamName,
-                    "pazpar2path": config.pazpar2_url,
+                    "pazpar2path": mkws.pazpar2_url(),
                     "usesessions" : config.use_service_proxy ? false : true,
                     "oninit": onInit,
                     "onbytarget": onBytarget,
index 339e28b..6982db8 100644 (file)
@@ -7,7 +7,7 @@ mkws.registerWidgetType('Categories', function() {
   }
 
   this.team.queue("authenticated").subscribe(function(authName, realm) {
-    var req = new pzHttpRequest(that.config.pazpar2_url + "?command=categories", function(err) {
+    var req = new pzHttpRequest(mkws.pazpar2_url() + "?command=categories", function(err) {
       alert("HTTP call for categories failed: " + err)
     });
 
index 89c0c02..4fbc15d 100644 (file)
@@ -103,7 +103,7 @@ apache-stop:
        else \
           killall apache2 2> /dev/null; \
        fi
-       @sleep 0.3
+       @sleep 0.6
        rm -f ${TMP_DIR}/mkws-jasmine.pid
 
 help:
index 1416efa..5450176 100644 (file)
@@ -12,7 +12,7 @@
     "devDependencies": {
         "jQuery": "*",
         "xmlhttprequest": "*",
-        "jsdom": "*",
+        "jsdom": "<= 0.11.1",
         "request": "*",
         "jasmine-reporters": "<= 0.4.1",
         "jasmine-node": "*",
index 59a0132..b6852a9 100644 (file)
@@ -34,8 +34,8 @@ describe("Check mkws.config object", function () {
 
 
 describe("Check pazpar2 config", function () {
-    it("pazpar2path is a path or an full URL", function () {
-        expect(mkws.config.pazpar2_url).toMatch(/^(\/|https?:\/\/)/)
+    it("pazpar2_url is a path or an full URL", function () {
+        expect(mkws.config.pazpar2_url).toMatch(/^(\/|https?:\/\/|undefined$)/)
     });
 });
 
index e0cfd60..54a1b64 100644 (file)
 
     # For MKC Service Proxy
 #    ProxyPreserveHost On
-    ProxyPass        /service-proxy/ http://sp-mkc.indexdata.com/service-proxy/
-    ProxyPassReverse /service-proxy/ http://sp-mkc.indexdata.com/service-proxy/
+    #ProxyPass        /service-proxy/ http://sp-mkc.indexdata.com/service-proxy/
+    #ProxyPassReverse /service-proxy/ http://sp-mkc.indexdata.com/service-proxy/
+    ProxyPass        /service-proxy/ http://sp-mkc-sansa.indexdata.com:8080/service-proxy/
+    ProxyPassReverse /service-proxy/ http://sp-mkc-sansa.indexdata.com:8080/service-proxy/
     # Or use: sp-mkc-sansa.indexdata.com:8080 or sp-mkc-arya.indexdata.com:8080
 
     PerlOptions +Parent