Merge branch 'master' of ssh://git.indexdata.com/home/git/private/mkws
authorMike Taylor <mike@indexdata.com>
Thu, 22 May 2014 14:27:23 +0000 (15:27 +0100)
committerMike Taylor <mike@indexdata.com>
Thu, 22 May 2014 14:27:23 +0000 (15:27 +0100)
examples/htdocs/mike-1efb82332d8d1a9293ad60f7517668cfcce480b0.html [deleted file]
examples/htdocs/mkws-widget-credo-1efb82332d8d1a9293ad60f7517668cfcce480b0.js [deleted file]
examples/htdocs/mkws-widget-credo.css
examples/htdocs/mkws-widget-credo.js
examples/htdocs/ref.html [new file with mode: 0644]
src/mkws-core.js

diff --git a/examples/htdocs/mike-1efb82332d8d1a9293ad60f7517668cfcce480b0.html b/examples/htdocs/mike-1efb82332d8d1a9293ad60f7517668cfcce480b0.html
deleted file mode 100644 (file)
index 0053fb6..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-<html>
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <title>MKWS demo: Reference Universe widget</title>
-    <link rel="stylesheet" type="text/css" href="mkws-widget-credo.css" />
-    <script type="text/javascript">
-      var mkws_config = { service_proxy_auth: "//mkws.indexdata.com/service-proxy-testauth" };
-    </script>
-    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.0.min.js"></script>
-    <script type="text/javascript" src="//x.mkws.indexdata.com/jquery.json-2.4.js"></script>
-    <script type="text/javascript" src="//x.mkws.indexdata.com/handlebars-v1.1.2.js"></script>
-    <script type="text/javascript" src="//x.mkws.indexdata.com/pazpar2/js/pz2.js"></script>
-    <script type="text/javascript" src="src/mkws-handlebars.js"></script>
-    <script type="text/javascript" src="src/mkws-core.js"></script>
-    <script type="text/javascript" src="src/mkws-team.js"></script>
-    <script type="text/javascript" src="src/mkws-filter.js"></script>
-    <script type="text/javascript" src="src/mkws-widget.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-main.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-termlists.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-authname.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-categories.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-log.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-record.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-reference.js"></script>
-    <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
-    <script type="text/javascript" xsrc="mkws-widget-credo.js"></script>
-    <script type="text/javascript" src="mkws-widget-credo-1efb82332d8d1a9293ad60f7517668cfcce480b0.js"></script>
-  </head>
-  <body>
-    <div class='mkwsCredo' autosearch='!param!q'>result will appear here</div>
-  </body>
-</html>
diff --git a/examples/htdocs/mkws-widget-credo-1efb82332d8d1a9293ad60f7517668cfcce480b0.js b/examples/htdocs/mkws-widget-credo-1efb82332d8d1a9293ad60f7517668cfcce480b0.js
deleted file mode 100644 (file)
index 2bb1b1a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-mkws.registerWidgetType('Credo', function() {
-  var that = this;
-  var s = []
-  s.push('<table>');
-
-  // Main panel: encylopaedia and images on the left, topics on the right
-  s.push('<tr class="front">');
-
-  s.push('<td class="main">');
-  s.push(section('encyclopaedia', 'Topic Page: ### title',
-                 this.subwidget('Reference')));
-  s.push(section('image', 'Images',
-                 this.subwidget('Images', { /* ### config */ })));
-  s.push('</td>');
-
-  s.push('<td class="side">');
-  s.push(section('mindmap', 'Create a Mind Map for ### title',
-                 '### Is there a way to make a mind-map?'));
-  s.push(section('topics', 'Related Topics',
-                 this.subwidget('Facet', { facet: 'subject' })));
-  s.push('</td>');
-
-  s.push('</tr>');
-
-  s.push(sectionRow('entries', 'Credo Entries',
-                    this.subwidget('Records', { /* ### config */ })));
-  s.push(sectionRow('articles', 'Articles',
-                    this.subwidget('Records', { /* ### config */ })));
-  s.push(sectionRow('books', 'Books',
-                    this.subwidget('Records', { /* ### config */ })));
-  s.push(sectionRow('news', 'News',
-                    this.subwidget('Records', { /* ### config */ })));
-  s.push(sectionRow('resources', 'Suggested Resources',
-                    this.subwidget('Records', { /* ### config */ })));
-
-  s.push('</table>');
-
-  this.node.html(s.join(''));
-
-
-  function section(xclass, title, content) {
-    var s = [];
-    s.push('<div class="' + xclass + ' section">');
-    s.push('<div class="title">' + title + '</div>');
-    s.push('<div class="content">' + content + '</div>');
-    s.push('</div>');
-    return s.join('');
-  }
-
-  function sectionRow(xclass, title, content) {
-    var s = [];
-    s.push('<tr>');
-    s.push('<td colspan="2">');
-    s.push(section(xclass, title, content));
-    s.push('</td>');
-    s.push('</tr>');
-    return s.join('');
-  }
-});
index ee5a1b4..2b7d71b 100644 (file)
     text-decoration: none;
 }
 
+.mkwsCredo hr.divider {
+    margin: 20px 1%;
+    border-top: 3px dotted #c0c0c0;
+    color: #fff;
+    background-color: #fff;
+    height: 0;
+    width: 98%;
+}
+
index b7f8f4f..e66559e 100644 (file)
@@ -1,3 +1,14 @@
+// The Google Images database returns links like:
+//      http://images.google.com/url?q=http://eofdreams.com/fish.html&sa=U&ei=RAB-U9XNDo2Dqga1o4L4Bw&ved=0CC4Q9QEwAA&usg=AFQjCNFhRtn6GMevHbpITZ6kfx6rsHV2ow
+// This Handlebars helper avoids a pointless redirect by transforming
+// this to the URL of the underling page, in this case
+//      http://eofdreams.com/fish.html
+//
+Handlebars.registerHelper('mkws-googleurl', function(obj) {
+  return mkws.getParameterByName('q', obj[0]);
+});
+
+
 // ### This works inefficiently by having multiple teams all run the
 // same search against different sets of targets. A much better
 // approach would be run a single search, with all these panels
@@ -9,7 +20,7 @@ mkws.registerWidgetType('Credo', function() {
 
   this.team.registerTemplate('CredoImage', '\
       <div>\
-       <a href="{{md-electronic-url}}" target="_blank">\
+       <a href="{{mkws-googleurl md-electronic-url}}" target="_blank">\
         {{#mkws-first md-thumburl}}\
          <img src="{{this}}" alt="{{../md-title}}"/>\
         {{/mkws-first}}\
@@ -35,15 +46,17 @@ mkws.registerWidgetType('Credo', function() {
 
   s.push('<td class="side">');
   s.push(section('mindmap', 'Create a Mind Map for ### title',
-                 '### Is there a way to make a mind-map?'));
+                 this.subwidget('Mindmap', { _team: 'main', facet: 'subject' })));
   s.push(section('topics', 'Related Topics',
-                 this.subwidget('Facet', { facet: 'subject' })));
+                 this.subwidget('Facet', { _team: 'main', facet: 'subject' })));
   s.push('</td>');
 
   s.push('</tr>');
 
+  s.push('<tr><td colspan="2"><hr class="divider"/></td></tr>');
+
   s.push(sectionRow('entries', 'Credo Entries',
-                    1 || this.subwidget('Records', { /* ### config */ })));
+                    this.subwidget('Records', { _team: 'main' })));
   s.push(sectionRow('articles', 'Articles',
                     1 || this.subwidget('Records', { /* ### config */ })));
   s.push(sectionRow('books', 'Books',
@@ -77,3 +90,8 @@ mkws.registerWidgetType('Credo', function() {
     return s.join('');
   }
 });
+
+
+mkws.registerWidgetType('Mindmap', function() {
+  this.node.html("### We do not yet have a Mindmap widget");
+});
diff --git a/examples/htdocs/ref.html b/examples/htdocs/ref.html
new file mode 100644 (file)
index 0000000..f6bb253
--- /dev/null
@@ -0,0 +1,15 @@
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <title>MKWS demo: Compound reference widget</title>
+    <link rel="stylesheet" type="text/css" href="mkws-widget-ref.css" />
+    <script type="text/javascript">
+      var mkws_config = { service_proxy_auth: "//mkws.indexdata.com/service-proxy-credoauth" };
+    </script>
+    <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
+    <script type="text/javascript" src="mkws-widget-credo.js"></script>
+  </head>
+  <body>
+    <div class='mkwsCredo' autosearch='!param!q'></div>
+  </body>
+</html>
index 0af84a9..7091291 100644 (file)
@@ -111,10 +111,11 @@ mkws.M = function(word) {
 
 // This function is taken from a StackOverflow answer
 // http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript/901144#901144
-mkws.getParameterByName = function(name) {
+mkws.getParameterByName = function(name, url) {
+  if (!url) url = location.search;
   name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
   var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
-  results = regex.exec(location.search);
+  results = regex.exec(url);
   return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
 }