Merge branch 'master' of ssh://git.indexdata.com:222/home/git/private/mkws into wosch
authorWolfram Schneider <wosch@indexdata.dk>
Thu, 20 Jun 2013 11:45:34 +0000 (11:45 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Thu, 20 Jun 2013 11:45:34 +0000 (11:45 +0000)
Conflicts:
experiments/spclient/mkws.js

etc/apache2/spclient-live [new file with mode: 0644]
etc/apache2/spclient-proxy [new file with mode: 0644]
experiments/spclient/README
experiments/spclient/index-mkws.html [new file with mode: 0644]
experiments/spclient/index-somesite.html [new file with mode: 0644]
experiments/spclient/index.html
experiments/spclient/mkws.js
experiments/spclient/mkwsStyle.css [new file with mode: 0644]
experiments/spclient/styles.css [deleted file]

diff --git a/etc/apache2/spclient-live b/etc/apache2/spclient-live
new file mode 100644 (file)
index 0000000..59e5a2b
--- /dev/null
@@ -0,0 +1,43 @@
+# Configuration for the apache web server
+# Running on caliban
+
+<VirtualHost *:80>
+    ServerName mkws.indexdata.com
+
+    ErrorLog /var/log/apache2/mkws-error.log
+    CustomLog /var/log/apache2/mkws-access.log combined
+
+    DocumentRoot /home/indexdata/mkws/experiments/spclient/
+    Alias /libjs-pz2/ /home/indexdata/libjs-pz2/
+    Alias /index.html /home/indexdata/mkws/experiments/spclient/index-mkws.html
+
+    RewriteEngine on
+    RewriteLogLevel 1
+    RewriteLog /var/log/apache2/mkws-rewrite.log 
+    RewriteRule /service-proxy-auth /service-proxy/?command=auth&action=login&username=guest&password=guest [P] # [NE,P]
+
+    Header set Access-Control-Allow-Origin "http://somesite.indexdata.com"
+
+    # For MKC Service Proxy
+    ProxyPass        /service-proxy/ http://mkc.indexdata.com:9009/service-proxy/
+    ProxyPassReverse /service-proxy/ http://mkc.indexdata.com:9009/service-proxy/
+</VirtualHost>
+
+<VirtualHost *:80>
+    ServerName somesite.indexdata.com
+
+    ErrorLog /var/log/apache2/somesite-error.log
+    CustomLog /var/log/apache2/somesite-access.log combined
+
+    DocumentRoot /home/indexdata/mkws/experiments/spclient/
+    Alias /index.html /home/indexdata/mkws/experiments/spclient/index-somesite.html
+
+    RewriteEngine on
+    RewriteLogLevel 1
+    RewriteLog /var/log/apache2/mkws-rewrite.log 
+    RewriteRule /service-proxy-auth /service-proxy/?command=auth&action=login&username=guest&password=guest [P] # [NE,P]
+
+    # For MKC Service Proxy
+    ProxyPass        /service-proxy/ http://mkc.indexdata.com:9009/service-proxy/
+    ProxyPassReverse /service-proxy/ http://mkc.indexdata.com:9009/service-proxy/
+</VirtualHost>
diff --git a/etc/apache2/spclient-proxy b/etc/apache2/spclient-proxy
new file mode 100644 (file)
index 0000000..4e16c51
--- /dev/null
@@ -0,0 +1,19 @@
+<VirtualHost *:80>
+    ServerName mkws.indexdata.com
+    ServerAlias somesite.indexdata.com
+
+    ProxyRequests off
+    ProxyVia On
+    ProxyPreserveHost On
+    <Proxy *>
+      Order deny,allow
+      Allow from all
+    </Proxy>
+
+    ProxyPass         / http://caliban:80/
+    ProxyPassReverse  / http://caliban:80/
+
+    # These are the logs for the proxying operation
+    ErrorLog /var/log/apache2/mkws-proxy-error.log
+    CustomLog /var/log/apache2/mkws-proxy-access.log combined
+</VirtualHost>
index be54707..16b3bc3 100644 (file)
@@ -1,20 +1,73 @@
-In its current form, this is very close to
-/usr/local/src/git/pazpar2/www/jsdemo/
-
-- It uses indexdata_logo.png directly from that location
-- It uses styles.css directly from that location
-- It uses pz2.js directly from /usr/local/src/git/pazpar2/js
-- Its HTML (index.html) differs only in a few lines:
-       diff /usr/local/src/git/pazpar2/www/jsdemo/index.html index.html
-       - It has a boolean indicating whether the SP is in use
-       - When that is set it performs simple authentication
-         (The username/pw are hardwired into the Apache2 config)
-- Its JavaScript (example_client.js) differs only in a few lines:
-       diff /usr/local/src/git/pazpar2/www/jsdemo/example_client.js example_client.js
-       - usesessions and pazpar2path are set differently if SP is in use
-       - authURLServiceProxy is defined (to be used in the HTML)
-       - status info has extra info to say whether SP is in use
-- A simple favicon.ico is added to avoid spamming the error-log with 404s
-- A simple robots.txt is added
+An embryonic MasterKey Widget Set
+=================================
+
+This directory contains an embryonic MasterKey Widget Set, based
+initially on "jsdemo" though now far removed from those beginnnings.
+
+
+How this works
+--------------
+
+The goal is to make it that as much of the searching functionality as
+possible is hosted on
+       http://mkws.indexdata.com/
+so that very simple websites such as
+       http://somesite.indexdata.com/
+can have MasterKey searching with minimal effort.
+
+The following files must be hosted on mkws.indexdata.com:
+       mkws.js
+       mkwsStyle.css
+       /libjs-pz2/pz2api.1.js
+
+The following files make up the application:
+       index.html
+       favicon.ico [optional]
+       robots.txt [optional]
+
+(At present, the client application's configuruation also needs an
+Alias for /service-proxy/, to avoid cross-site scripting issues. We
+will fix this.)
+
+
+Configuring a client
+--------------------
+
+The application's HTML must contains the following elements as well as
+whatever makes up the application itself:
+
+Prerequisites:
+    <link rel="stylesheet" href="mkwsStyle.css" />
+    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
+    <script type="text/javascript" src="/libjs-pz2/pz2api.1.js"></script>
+    <script type="text/javascript" src="mkws.js"></script>
+(Yes, we're using JQuery. We use it only in the most trivial ways, and
+could probably get rid of it without too much pain. I'd like to have
+mkws.js automatically pull in pz2api.1.js, too, so you don't need to
+do so many things, but that's not quite trivial.)
+
+Then the following special <div>s can be added (with no content), and
+will be filled in by MKWS:
+    <div id="mkwsSwitch"></div> -- switch between record and target views
+    <div id="mkwsSearch"></div> -- search box and button
+    <div id="mkwsRecords"></div> -- result list, including pager/sorting
+    <div id="mkwsTargets"></div> -- target list, including status
+    <div id="mkwsStat"></div> -- summary statistics
+
+At present, MKWS will not work correctly if any of these is
+missing. One of the TODOs is to fix it so that it doesn't try to use
+whatever is not there, and just uses what is.
+
+
+What next?
+----------
+
+Main areas of work:
+* Fix cross-site issues proper
+* Make MKWS robust to missing widgets
+* Make CSS more tightly targeted at MKWS elements only
+* Make CSS prettier
+* Embed in a real, existing, site
+* Clean up the code
 
 
diff --git a/experiments/spclient/index-mkws.html b/experiments/spclient/index-mkws.html
new file mode 100644 (file)
index 0000000..9efe0cb
--- /dev/null
@@ -0,0 +1,36 @@
+<p>
+  There is no content on the MKWS site, just tools:
+</p>
+<ul>
+  <li>
+    <a href="mkws.js">mkws.js</a>
+    --
+    JavaScript code that powers the MasterKey Widget Set
+  </li>
+  <li>
+    <a href="/libjs-pz2/pz2api.1.js">/libjs-pz2/pz2api.1.js</a>
+    --
+    Low-level JavaScript library for access to the MasterKey web
+    service.
+  </li>
+  <li>
+    <a href="mkwsStyle.css">mkwsStyle.css</a>
+    --
+    A stylesheet which styles only MasterKey widgets, and does not
+    otherwise interfere with application-site's styles.
+    <p style="color:darkred">
+      Note. This is not yet quite true: the stylesheet needs tweaking
+      to make it more specific to only the MKWS components. At present
+      it spills over into styling parts of the containing site, too.
+    </p>
+  </li>
+</ul>
+<p>
+  For a very simple application that uses these, see
+  <a href="http://somesite.indexdata.com/"
+          >http://somesite.indexdata.com/</a>.
+  It's worth viewing the source to see how small it is
+</p>
+<p>
+  See also the <a href="README">README</a>.
+</p>
diff --git a/experiments/spclient/index-somesite.html b/experiments/spclient/index-somesite.html
new file mode 100644 (file)
index 0000000..2d9077a
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <title>MKWS demo client</title>
+    <!-- Next four lines required by MKWS -->
+    <link rel="stylesheet" href="http://mkws.indexdata.com/mkwsStyle.css" />
+    <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
+    <script type="text/javascript" src="http://mkws.indexdata.com/libjs-pz2/pz2api.1.js"></script>
+    <script type="text/javascript" src="http://mkws.indexdata.com/mkws.js"></script>
+  </head>
+  <body>
+    <!-- These five <div>s are provided by MKWS -->
+    <div id="mkwsSwitch"></div>
+    <div id="mkwsSearch"></div>
+    <div id="mkwsRecords"></div>
+    <div id="mkwsTargets"></div>
+    <div id="mkwsStat"></div>
+  </body>
+</html>
index 87edf8e..f1d0982 100644 (file)
@@ -4,38 +4,18 @@
   <head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     <title>MKWS demo client</title>
-    <link rel="stylesheet" href="styles.css" />
+    <!-- Next four lines required by MKWS -->
+    <link rel="stylesheet" href="mkwsStyle.css" />
     <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="/libjs-pz2/pz2api.1.js"></script>
     <script type="text/javascript" src="mkws.js"></script>
   </head>
   <body>
+    <!-- These five <div>s are provided by MKWS -->
     <div id="mkwsSwitch"></div>
     <div id="mkwsSearch"></div>
-    <div id="mkwsRecords">
-      <table width="100%" border="0" cellpadding="6" cellspacing="0">
-        <tr>
-          <td width="250" valign="top">
-            <div id="termlist"></div>
-          </td>
-          <td valign="top">
-            <div id="ranking">
-              <form name="select" id="select">
-        Sort by
-        <select name="sort" id="sort"><option value="relevance" selected="selected">relevance</option><option value="title:1">title</option><option value="date:0">newest</option><option value="date:1">oldest</option></select>
-        and show 
-        <select name="perpage" id="perpage"><option value="10">10</option><option value="20" selected="selected">20</option><option value="30">30</option><option value="50">50</option></select>
-        per page.
-       </form>
-            </div>
-            <div id="pager"></div>
-            <div id="navi"></div>
-            <div id="results"></div>
-          </td>
-        </tr>
-      </table>
-    </div>
+    <div id="mkwsRecords"></div>
     <div id="mkwsTargets"></div>
-    <div id="stat"></div>
+    <div id="mkwsStat"></div>
   </body>
 </html>
index 82f7603..3c8d76e 100644 (file)
@@ -72,7 +72,7 @@ function my_onshow(data) {
 }
 
 function my_onstat(data) {
-    var stat = document.getElementById("stat");
+    var stat = document.getElementById("mkwsStat");
     if (stat == null)
        return;
 
@@ -373,15 +373,17 @@ function renderDetails(data, marker)
 
 
 $(document).ready(function() {
-    $("#mkwsSwitch").html($("<a/>", { href: '#',
-                                     onclick: "switchView(\'records\')",
-                                     text: "Record Browser",
-                                   }));
+    $("#mkwsSwitch").html($("<a/>", {
+       href: '#',
+       onclick: "switchView(\'records\')",
+       text: "Records",
+    }));
     $("#mkwsSwitch").append($("<span/>", { text: " | " }));
-    $("#mkwsSwitch").append($("<a/>", { href: '#',
-                                       onclick: "switchView(\'targets\')",
-                                       text: "Target Info",
-                                     }));
+    $("#mkwsSwitch").append($("<a/>", {
+       href: '#',
+       onclick: "switchView(\'targets\')",
+       text: "Targets",
+    }));
 
     // For some reason, doing this programmatically results in
     // document.search.query being undefined, hence the raw HTML.
@@ -391,6 +393,30 @@ $(document).ready(function() {
       <input id="button" type="submit" value="Search" />\
     </form>');
 
+    $("#mkwsRecords").html('\
+      <table width="100%" border="0" cellpadding="6" cellspacing="0">\
+        <tr>\
+          <td width="250" valign="top">\
+            <div id="termlist"></div>\
+          </td>\
+          <td valign="top">\
+            <div id="ranking">\
+              <form name="select" id="select">\
+        Sort by\
+        <select name="sort" id="sort"><option value="relevance" selected="selected">relevance</option><option value="title:1">title</option><option value="date:0">newest</option><option value="date:1">oldest</option></select>\
+        and show \
+        <select name="perpage" id="perpage"><option value="10">10</option><option value="20" selected="selected">20</option><option value="30">30</option><option value="50">50</option></select>\
+        per page.\
+       </form>\
+            </div>\
+            <div id="pager"></div>\
+            <div id="navi"></div>\
+            <div id="results"></div>\
+          </td>\
+        </tr>\
+      </table>\
+    </div>');
+
     $("#mkwsTargets").html('\
       <div id="bytarget">\
        No information available yet.\
@@ -401,22 +427,19 @@ $(document).ready(function() {
 });
 
 $(document).ready(function() {
-    if (useServiceProxy) {
-       var jqxhr = jQuery.get(authURLServiceProxy)
-           .fail(function() {
-             alert("service proxy authentifiction failed for URL " + authURLServiceProxy + " , give up!");
-           })
-           .success(function(data) {
-              if (!jQuery.isXMLDoc(data)) {
-                alert("service proxy auth response document is not valid XML document, give up!");
-                return;
-              }
-
-              var status = $(data).find("status");
-              if (status.text() != "OK") {
+    var jqxhr = jQuery.get("/service-proxy-auth")
+       .fail(function() {
+           alert("service proxy authentification failed, give up!");
+       })
+       .success(function(data) {
+           if (!jQuery.isXMLDoc(data)) {
+               alert("service proxy auth response document is not valid XML document, give up!");
+               return;
+           }
+           var status = $(data).find("status");
+           if (status.text() != "OK") {
                alert("service proxy auth repsonse status: " + status.text() + ", give up!");
                return;
-              }
-             });
-    }
+           }
+       });
 });
diff --git a/experiments/spclient/mkwsStyle.css b/experiments/spclient/mkwsStyle.css
new file mode 100644 (file)
index 0000000..f17c546
--- /dev/null
@@ -0,0 +1,71 @@
+a {
+    color: #005701; 
+    text-decoration: none;
+}
+
+a:hover {
+    text-decoration: underline;
+}
+
+a.crossout:hover {
+    text-decoration: line-through;
+}
+
+input#button {
+    border: 3px outset #132194;
+    background-color: #132194;
+    padding: 2px;
+    width: 6em;
+    color: #FFFFFF;
+    font-weight: bold;
+    text-transform: uppercase;
+    font-size: 10px;
+    margin-left: 8px;
+    cursor: pointer;
+}
+
+input#query {
+    border: 2px inset #34cc67;
+    padding: 3px;
+    font-size: 12px;
+}
+
+div.termtitle {
+    margin: 4px;
+    font-weight: bold;
+}
+
+div.record {
+    padding: 5px;
+}
+
+div.details {
+    border: 3px dashed gray;
+    color: gray;
+    padding: 5px;
+    margin: 4px;
+}
+
+#mkwsSwitch, #mkwsSearch, #mkwsRecords, #mkwsTargets {
+    font-family: Gill Sans, "Gillius ADF", Gillius, GilliusADF, Verdana, Sans-Serif;
+}
+
+#mkwsSwitch {
+    float: right;
+    padding-left: 1em;
+    padding-top: 0.4em;
+}
+
+#mkwsSearch {
+    float: right;
+}
+
+#mkwsRecords {
+    background-color: #fafafa;
+    border-bottom: 1px solid  #156a16;
+}
+
+#mkwsTargets {
+    background-color: #fafafa;
+    border-bottom: 1px solid  #156a16;
+}
diff --git a/experiments/spclient/styles.css b/experiments/spclient/styles.css
deleted file mode 100644 (file)
index 8e50008..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-a {
-    color: #005701; 
-    text-decoration: none;
-}
-
-a:hover {
-    text-decoration: underline;
-}
-
-a.crossout:hover {
-    text-decoration: line-through;
-}
-
-input#button {
-    border: 3px outset #132194;
-    background-color: #132194;
-    padding: 2px;
-    width: 6em;
-    color: #FFFFFF;
-    font-weight: bold;
-    text-transform: uppercase;
-    font-size: 10px;
-    margin-left: 8px;
-    cursor: pointer;
-}
-
-input#query {
-    border: 2px inset #34cc67;
-    padding: 3px;
-    font-size: 12px;
-}
-
-div.termtitle {
-    margin: 4px;
-    font-weight: bold;
-}
-
-div.record {
-    padding: 5px;
-}
-
-div.details {
-    border: 3px dashed gray;
-    color: gray;
-    padding: 5px;
-    margin: 4px;
-}
-
-#mkwsSwitch {
-    padding-bottom: 3px;
-    text-align: right;
-}
-
-#mkwsRecords {
-    background-color: #fafafa;
-    border-bottom: 1px solid  #156a16;
-}
-
-#mkwsTargets {
-    background-color: #fafafa;
-    border-bottom: 1px solid  #156a16;
-}