Merge branch 'master' into prettysimple prettysimple
authorJason Skomorowski <jason@indexdata.com>
Tue, 4 Nov 2014 17:16:28 +0000 (12:16 -0500)
committerJason Skomorowski <jason@indexdata.com>
Tue, 4 Nov 2014 17:16:28 +0000 (12:16 -0500)
Conflicts:
src/templates/facets.handlebars

19 files changed:
doc/mkws-manual.markdown
examples/htdocs/custom.css
examples/htdocs/heikki-motd.html
examples/htdocs/heikki.html
examples/htdocs/jasmine-pp2.html
examples/htdocs/language.html
examples/htdocs/local-auto.html
examples/htdocs/lowlevel.html
src/mkws-core.js
src/mkws-widget-facets.js
src/templates/results.handlebars
test/bin/bomb.pl
test/spec/mkws-pazpar2.js
test/widgets/Makefile
test/widgets/url.demos
test/widgets/url.koha
tools/apache2/mkws-mike-mac
tools/apache2/sp-mkws-mike-mac [new file with mode: 0644]
tools/htdocs/mkws.css

index 7c0dd06..9abebd5 100644 (file)
@@ -267,7 +267,7 @@ etc., customised layouts may wish to treat each of these components
 separately. In this case, `mkws-results` can be omitted, and the
 following lower-level widgets provided instead:
 
-* `mkws-termlists` -- provides the facets
+* `mkws-facets` -- provides the facets
 
 * `mkws-ranking` -- provides the options for how records are sorted and
    how many are included on each page of results.
@@ -659,6 +659,9 @@ Name              Description
                   widget be subclassed to store the generated widget
                   definitions in more useful places.
 
+`button`          The search button. Usually generated a `search`
+                  widget.
+
 `categories`      Obtains from the Service Proxy a list of the target
                   categories associated with the library in use, and
                   displays them in a drop-down list. When a category
@@ -699,55 +702,141 @@ Name              Description
                   be changed by overriding the `done` template using
                   `<script class="mkws-template-done" type="text/x-handlebars-template">`.
 
-`facet`           x
-
-`google-image`    x
-
-`images`          x
-
-`lang`            x
-
-`log`             x
-
-`lolcat`          x
-
-`motd-container`  x
-
-`motd`            x
-
-`navi`            x
-
-`pager`           x
-
-`per-page`        x
-
-`progress`        x
-
-`query`           x
-
-`ranking`         x
-
-`record`          x
-
-`records`         x
-
-`reference`       x
-
-`results`         x
-
-`search-form`     x
-
-`search`          x
-
-`sort`            x
-
-`stat`            x
-
-`switch`          x
-
-`targets`         x
+`facet`           A facet that displays the frequency with which a set
+                  of terms occur within a specific field. The specific
+                  field whose contents are analysed must be specified
+                  by the widget's `facet` configuration item, which
+                  may conveniently be done by means of the
+                  `data-mkws-facet` attribute on the HTML
+                  element. The supported facets are "subject",
+                  "author" and "xtargets" -- the latter a special case
+                  which treats the target providing a record as a
+                  facet. Most often, `facet` widgets are generated
+                  by a `facets` widget, which knows which facets are
+                  required, but they can also be placed individually.
+
+`facets`          An area that contains a "Facets" heading and several
+                  `facet` widgets. The set of facet widgets generated
+                  is specified by the `facets` configuration item,
+                  which may be set globally or at the level of the
+                  widget or the team. The value of this configuration
+                  item is an array of zero or more strings, each
+                  naming a facet.
+
+`google-image`    A specialisation of the `images` widget which
+                  defaults to the `Google_Images` target.
+
+`images`          A specialisation of the `records` widget which
+                  defaults to the `images` template. Unlike the default
+                  summary template, this displays an image from the
+                  URL specified by the `md-thumburl` field of each
+                  record.
+
+`lang`            Provides a selection between the supported set of
+                  languages (which defaults to English, German and
+                  Danish, but can be configured by the `lang`
+                  configuration item, whose value is an array of
+                  two-letter language codes).
+
+`log`             Initially empty, this widget accumulates a log of
+                  messages generated by the widget set, similar to
+                  those emitted on the JavaScript console.
+
+`lolcat`          A specialisation of the `google-image` widget which
+                  defaults to the search-term "kitteh" and
+                  auto-executes.
+
+`motd-container`  An empty container which the `motd` widget, if any,
+                  is moved into for initial display. Usually generated
+                  as part of the `results` widget.
+
+`motd`            May be provided, containing content to appear in the
+                  area where records will later appear. It is moved
+                  into this area (the `motd-container` widget) and
+                  initially displayed; then hidden when the first
+                  search is run. It can be used to provide a "message
+                  of the day".
+
+`navi`            Shows a list of the facets that have been selected,
+                  and allows them to be deselected.
+
+`pager`           Shows a list of the available pages of results, and
+                  allows the user to navigate to a selected page.
+
+`per-page`        Provides a dropdown allowing the user to choose how
+                  many records should appear on each page. The
+                  available set of page-sizes can be set as the
+                  `perpage_options` configuration item, whose value is
+                  an array of integers. The initial selected value can
+                  be set by the `perpage_default` configuration item.
+
+`progress`        Shows a progress bar which indicates how many of the
+                  targets have responded to the search.
+
+`query`           The input area for a query. Usually generated a `search`
+                  widget.
 
-`termlists`       x
+`ranking`         The result-ranking area, consisting of a `sort`
+                  widget and a `per-page` widget. These may instead
+                  be specified separately if preferred.
+
+`record`          A detailed display of a single record, usually
+                  appearing when the user clicks on a summary
+                  record. This is generated by the `records` widget.
+
+`records`         The area in which summary records appear. (Clicking
+                  on a summary record make it pop up as a detailed
+                  record.)
+
+`reference`       A short summary about a subject specified by the
+                  `autosearch` configuration item. This is created by
+                  drawing a picture and a paragraph of text from
+                  Wikipedia. To work correctly, this widget must be
+                  used in a library that provides the
+                  `wikimedia_wikipedia_single_result` target.
+
+`results`         A large compound widget used to provide the most
+                  important results-oriented widgets in a pre-packaged
+                  framework: `facets`, `ranking`, `pager`, `navi` and
+                  `records`.
+
+`search-form`     The search form, containing the query area and the
+                  button. Usually generated a `search` widget.
+
+`search`          The search box, consisting of a form containing a
+                  query area and a button.
+
+`sort`            Provides a dropdown allowing the user to choose how
+                  the displayed records should be sorted. The
+                  available set of sort criteria can be set as the
+                  `sort_options` configuration item, whose value is
+                  an array of two-element arrays. The first item of
+                  each sub-array is a pazpar2 sort-expression such as
+                  `data:0` and the second is a human-readable label
+                  such as `newest`. The initial selected
+                  value can be set by the `sort_default` configuration
+                  item.
+
+`stat`            A summary line stating how many targets remain
+                  active, how many records have been found, and how
+                  many of them have been retrieved for display. For
+                  most purposes, the `progress` widget may be
+                  preferable.
+
+`summary`         A short record, included in the list shown when a
+                  search is run. When clicked, this generally pops up
+                  a detailed `record` widget. This widget is generated
+                  by the toolkit in response to search results.
+
+`switch`          A pair of buttons allowing the user to switch
+                  between viewing the search results (the usual case)
+                  or the target list.
+
+`targets`         A list of all targets in the present library,
+                  showing their ID, the number of records they have
+                  found for the current search, any diagnostics they
+                  have returned, the number of records that have been
+                  returned for display, and the connection state.
 ----
 
 
@@ -874,7 +963,7 @@ The following strings occurring in the UI can be translated:
 `Search`,
 `Sort by`,
 `Targets`,
-`Termlists`,
+`Facets`,
 `and show`,
 `found`,
 `of`,
@@ -949,7 +1038,7 @@ In order to override the default CSS styles provided by the MasterKey Widget
 Set, it's necessary to understand that structure of the HTML elements that are
 generated within the widgets. This knowledge make it possible, for example,
 to style each `<div>` with class `term` but only when it occurs inside an
-element with class `mkws-termlists`, so as to avoid inadvertently styling other
+element with class `mkws-facets`, so as to avoid inadvertently styling other
 elements using the same class in the non-MKWS parts of the page.
 
 The HTML structure is as follows. As in CSS, #ID indicates a unique identifier
index 0a99dec..80eb04a 100644 (file)
@@ -1,4 +1,4 @@
-.mkws-termlists {
+.mkws-facets {
     background: white;
 }
 .mkws-facet {
index aa53154..843d3bc 100644 (file)
@@ -19,7 +19,7 @@
     <script type="text/javascript" src="tools/htdocs/mkws.js"></script>
 
     <style type="text/css">
-      .mkws-termlists div.facet {
+      .mkws-facets div.facet {
       float:left;
       width: 30%;
       margin: 0.3em;
index 8a92369..5138bfe 100644 (file)
@@ -21,7 +21,7 @@
     <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
     <script type="text/javascript" src="tools/htdocs/mkws.js"></script>
     <style type="text/css">
-      .mkws-termlists div.facet {
+      .mkws-facets div.facet {
       float:left;
       width: 30%;
       margin: 0.3em;
@@ -56,7 +56,7 @@
       <tr>
         <td>
           <div style="height:300px; overflow: hidden">
-            <div class="mkws-termlists"></div>
+            <div class="mkws-facets"></div>
           </div>
         </td>
       </tr>
index dbe236a..8a8e64b 100644 (file)
@@ -22,7 +22,7 @@
 
     <link rel="stylesheet" type="text/css" href="tools/htdocs/mkws.css" />
     <style type="text/css">
-      .mkws-termlists div.facet {
+      .mkws-facets div.facet {
       float:left;
       width: 30%;
       margin: 0.3em;
@@ -71,7 +71,7 @@
       <tr>
         <td>
           <div style="height:300px; overflow: hidden">
-            <div class="mkws-termlists"></div>
+            <div class="mkws-facets"></div>
           </div>
         </td>
       </tr>
index d24e017..2cbd8be 100644 (file)
@@ -40,7 +40,7 @@
                        "Subject": "موضوع",
                        "Location": "موقع",
                        // Facet heading and individual facet names
-                       "Termlists": "العضو الأجل",
+                       "Facets": "العضو الأجل",
                        "Sources": "مصادر",
                        "Subjects": "المواضيع",
                        "Authors": "الكتاب",
index 27336ef..1c5604d 100644 (file)
@@ -30,7 +30,7 @@
        sort='relevance'
        targets='pz:id~josiah.brown.edu:210/innopac|connect.indexdata.com:9000/mit_opencourseware'
 >News will appear here</div>
-       <div class='mkws-termlists mkws-team-news'/>
+       <div class='mkws-facets mkws-team-news'/>
        </td>
        <td width="30%">
          <h2>Blog</h2>
@@ -39,7 +39,7 @@
        sort='relevance'
        targets='pz:id~josiah.brown.edu:210/innopac|connect.indexdata.com:9000/mit_opencourseware'
 >Blog entries will appear here</div>
-       <div class='mkws-termlists mkws-team-blog'/>
+       <div class='mkws-facets mkws-team-blog'/>
        </td>
       </tr>
     </table>
index ebf4043..74b55d2 100644 (file)
@@ -5,7 +5,7 @@
     <link rel="stylesheet" type="text/css" href="//mkws.indexdata.com/mkws.css" />
     <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
     <style type="text/css">
-      .mkws-termlists div.facet {
+      .mkws-facets div.facet {
       float:left;
       width: 30%;
       margin: 0.3em;
@@ -38,7 +38,7 @@
       <tr>
         <td>
           <div style="height:300px; overflow: hidden">
-            <div class="mkws-termlists"></div>
+            <div class="mkws-facets"></div>
           </div>
         </td>
       </tr>
index 7d3d444..6b71bc1 100644 (file)
@@ -298,7 +298,8 @@ mkws.log("Using window.name '" + window.name + "'");
     'MOTDContainer': 'motd-container',
     'Perpage': 'per-page',
     'SearchForm': 'search-form',
-    'ReferenceUniverse': 'reference-universe'
+    'ReferenceUniverse': 'reference-universe',
+    'Termlists': 'facets'
   };
   // Annoyingly, there is no built-in way to invert a hash
   var _new2old = {};
index ce47068..478bf0a 100644 (file)
@@ -1,4 +1,4 @@
-mkws.registerWidgetType('termlists', function() {
+mkws.registerWidgetType('facets', function() {
   // Initially hide the facets; display when we get results
   var that = this;
   var team = this.team;
index fcda1bc..fc87e4c 100644 (file)
@@ -5,8 +5,8 @@ team - team for this widget
 }}
 <table width="100%" border="0" cellpadding="6" cellspacing="0">
   <tr>
-    <td class="mkws-termlists-container-wide mkws-team-{{team}}" width="250" valign="top">
-      <div class="mkws-termlists mkwsTermlists mkws-team-{{team}}"></div>
+    <td class="mkws-facets-container-wide mkws-team-{{team}}" width="250" valign="top">
+      <div class="mkws-facets mkwsTermlists mkws-team-{{team}}"></div>
     </td>
     <td class="mkws-motd-container mkwsMOTDContainer mkws-team-{{team}}" valign="top">
       <div class="mkws-ranking mkwsRanking mkws-team-{{team}}"></div>
@@ -17,7 +17,7 @@ team - team for this widget
   </tr>
   <tr>
     <td colspan="2">
-      <div class="mkws-termlists-container-narrow mkws-team-{{team}}"></div>
+      <div class="mkws-facets-container-narrow mkws-team-{{team}}"></div>
     </td>
   </tr>
 </table>
index 0f434d0..b91f049 100755 (executable)
@@ -42,26 +42,31 @@ die usage if !@system;
 # be ignored
 eval {
     require BSD::Resource;
-    BSD::Resource::setrlimit("RLIMIT_CPU", $timeout, 2*$timeout) or die "Cannot set CPU limit: $!\n";
+    BSD::Resource::setrlimit( "RLIMIT_CPU", $timeout, 2 * $timeout )
+      or die "Cannot set CPU limit: $!\n";
 };
 if ($@) {
-    warn "WARNING: things would go more nicely with the BSD::Resource package\n";
+    warn
+      "WARNING: things would go more nicely with the BSD::Resource package\n";
 }
 
-
 #
-# use fork/exec instead system()
+# configure signal handlers
 #
-$pid = fork();
-die "fork() failed: $!" unless defined $pid;
+$SIG{ALRM} = sub {
+    my $pgid = getpgrp();
 
-# child
-if ($pid) {
-    alarm($timeout);
-    exec(@system) or die "exec @system: $!\n";
-}
+    # kill process group
+    kill "INT", -$pgid;
+};
 
-# parent
-else { }
+# don't kill ourself
+$SIG{INT} = "IGNORE";
+
+alarm($timeout);
+
+system(@system) == 0
+  or die "system @system failed: $?";
 
 1;
+
index 21ea770..2cfe93d 100644 (file)
@@ -227,13 +227,13 @@ describe("Check pazpar2 hit counter", function () {
     });
 });
 
-describe("Check Termlist", function () {
+describe("Check Facets", function () {
     var $ = mkws.$;
 
-    it("found Termlist", function () {
-        var termlist = $("div.mkws-termlists");
-        debug("Termlist success: " + termlist.length);
-        expect(termlist.length).toBe(1);
+    it("found Facets", function () {
+        var facets = $("div.mkws-facets");
+        debug("Facet success: " + facets.length);
+        expect(facets.length).toBe(1);
 
         waitsFor(function () {
             return $("div.mkws-facet[data-mkws-facet='xtargets']").length == 1 ? true : false;
@@ -242,7 +242,7 @@ describe("Check Termlist", function () {
         // everything displayed?
         runs(function () {
             var sources = $("div.mkws-facet[data-mkws-facet='xtargets']");
-            debug("Termlist sources success: " + sources.length);
+            debug("Facet sources success: " + sources.length);
             expect(sources.length).toBe(1);
 
             var subjects = $("div.mkws-facet[data-mkws-facet='subject']");
index 18a303c..e2d3581 100644 (file)
@@ -1,7 +1,7 @@
 # Copyright (c) 2013-2014 Index Data ApS. http://indexdata.com
 
 PHANTOMJS_TIMEOUT=30
-PHANTOMJS=     ../node_modules/phantomjs/bin/phantomjs
+PHANTOMJS=     perl ../bin/bomb.pl --timeout=${PHANTOMJS_TIMEOUT} ../node_modules/phantomjs/bin/phantomjs
 IMAGES=                ./images
 SCREENSHOT_WIDTH_HEIGHT=       1000 1200
 PERL_SCRIPTS=  ../bin/bomb.pl
@@ -18,6 +18,7 @@ all: help
 
 clean:
        rm -f index-*.html
+       rm -f iframe-*.html
        rm -f ${IMAGES}/*.png
 
 distclean: clean
@@ -30,7 +31,7 @@ screenshot:
          ${PHANTOMJS} ${PROG} ${PHANTOMJS_URL} ${IMAGES}/tmp.$$file.png ${SCREENSHOT_WIDTH_HEIGHT} ${TIMEOUT}; \
          mv -f  ${IMAGES}/tmp.$$file.png  ${IMAGES}/$$file.png
 
-screenshots: clean estimate-time
+screenshots: clean estimate-time iframe
        for t in ${TESTS}; do \
            for i in $$(cat url.$$t); do \
                ${MAKE} PHANTOMJS_URL="$$i" TIMEOUT=4 PREFIX=$$t screenshot; \
@@ -45,10 +46,14 @@ estimate-time:
 index:
        ( cd ${IMAGES}; ls -tr ${PREFIX}.*.png | perl -ne 'chomp; print qq{<h2>$$_</h2><img src="'${IMAGES}/'$$_"/><br/><br/><p/>\n}' ) > index-${PREFIX}.html
 
+iframe: index-iframe-demo
+index-iframe-demo:
+       ( cat url.demos | perl -ne 'chomp; print qq{<h2>$$_</h2><iframe width="900px" height="600px" src="$$_"></iframe>\n}' ) > iframe-demos.html
+
 help:
        @echo "make [ all | clean | distclean ]"
        @echo "     [ screenshots ]"
-       @echo "     [ screenshot | index ]"
+       @echo "     [ screenshot | index | iframe ]"
        @echo ""
        @echo "Examples: "
        @echo ""
index 8fd213d..6ef9d58 100644 (file)
@@ -8,3 +8,5 @@ http://example.indexdata.com/popup.html
 http://example.indexdata.com/auto.html
 http://example.indexdata.com/localauth.html
 http://www.indexdata.com/news/2014/06/using-smart-widgets-integrate-information-access
+http://example.indexdata.com/topic.html?q=sushi
+http://example.indexdata.com/prettysimple.html
index c5b8207..2ebec85 100644 (file)
@@ -2,6 +2,3 @@ http://cph.koha.indexdata.com/cgi-bin/koha/opac-search.pl?q=sushi
 http://demo.koha.indexdata.com/cgi-bin/koha/opac-search.pl?q=sushi
 http://demo.koha.indexdata.com/cgi-bin/koha/opac-search.pl?q=sushi2
 http://boston.koha.indexdata.com/cgi-bin/koha/opac-search.pl?q=sushi
-http://example.indexdata.com/topic.html?q=sushi
-http://example.indexdata.com/simple.html
-
index d756148..7db0c62 100644 (file)
@@ -3,16 +3,16 @@
 
 <VirtualHost *:80>
     ServerName x.mkws.indexdata.com
-    ErrorLog /opt/local/apache2/logs/mkws-error.log
-    CustomLog /opt/local/apache2/logs/mkws-access.log combined
+    ErrorLog /var/log/apache2/mkws-error.log
+    CustomLog /var/log/apache2/mkws-access.log combined
 
-    DocumentRoot /usr/local/src/git/mkws/tools/htdocs
-    Alias /libjs-pz2/ /usr/local/src/git/libjs-pz2/
-    Alias /pazpar2/ /usr/local/src/git/pazpar2/
+    DocumentRoot /Users/mike/git/work/mkws/tools/htdocs
+    Alias /libjs-pz2/ /Users/mike/git/work/libjs-pz2/
+    Alias /pazpar2/ /Users/mike/git/work/pazpar2/
 
     RewriteEngine on
     RewriteLogLevel 1
-    RewriteLog /opt/local/apache2/logs/spclient-rewrite.log 
+    RewriteLog /var/log/apache2/spclient-rewrite.log 
     RewriteRule /service-proxy-auth(/)?(;jsessionid=.+)? /service-proxy/$2?command=auth&action=login&username=guest&password=guest [P] # [NE,P]
 
     # For MKC Service Proxy
         Allow from all
     </Directory>
 </VirtualHost>
-
-<VirtualHost *:80>
-    ServerName x.example.indexdata.com
-    ErrorLog /opt/local/apache2/logs/example-error.log
-    CustomLog /opt/local/apache2/logs/example-access.log combined
-
-    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/
-
-    # Needed on Mac, which locks Apache down hard by default.
-    <Directory />
-        Allow from all
-    </Directory>
-</VirtualHost>
diff --git a/tools/apache2/sp-mkws-mike-mac b/tools/apache2/sp-mkws-mike-mac
new file mode 100644 (file)
index 0000000..e942550
--- /dev/null
@@ -0,0 +1,25 @@
+<VirtualHost *:80>
+    ServerName x.sp-mkws.indexdata.com
+
+    ErrorLog /var/log/apache2/sp-mkws-error.log
+    CustomLog /var/log/apache2/sp-mkws-access.log combined
+
+    DocumentRoot /Users/mike/git/work/mkws/tools/sp-htdocs
+
+    Header set Access-Control-Allow-Credentials true
+
+    ProxyPreserveHost On
+    # We could use any of the following:
+    ProxyPass        /service-proxy/ http://x.sp-mkws.indexdata.com:8585/service-proxy/
+    ProxyPassReverse /service-proxy/ http://x.sp-mkws.indexdata.com:8585/service-proxy/
+
+    <Directory />
+        Allow from all
+    </Directory>
+
+#    PerlOptions +Parent
+#    PerlSwitches -I/home/indexdata/mkws/tools/mod_perl
+#    <Location /service-proxy>
+#        PerlOutputFilterHandler MyApache2::SetACAO
+#    </Location>
+</VirtualHost>
index 86636a6..5964b65 100644 (file)
@@ -1,7 +1,7 @@
 .mkwsLang, .mkws-lang,
 .mkwsSwitch, .mkws-switch,
 .mkwsSearch, .mkws-search,
-.mkwsTermlists, .mkws-termlists,
+.mkwsTermlists, .mkws-facets,
 .mkwsFacet, .mkws-facet,
 .mkwsRanking, .mkws-ranking,
 .mkwsPager, .mkws-pager,
     background: #f0f8ff;
 }
 
-.mkwsTermlistsTitle, .mkws-termlists-title {
+.mkwsTermlistsTitle, .mkws-facets-title {
     font-size: large;
     font-weight: bold;
     text-transform: uppercase;
 }
 
-.mkwsTermlists, .mkws-termlists {
+.mkwsTermlists, .mkws-facets {
     background: #d0e0ff;
     padding: 0.7em;
     font-size: small;
     -webkit-border-top-right-radius: 10px;
 }
 
-.mkwsTermlists.active, .mkws-termlists.active {
+.mkwsTermlists.active, .mkws-facets.active {
     display: block;
 }