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.
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
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.
----
`Search`,
`Sort by`,
`Targets`,
-`Termlists`,
+`Facets`,
`and show`,
`found`,
`of`,
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
-.mkws-termlists {
+.mkws-facets {
background: white;
}
.mkws-facet {
<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;
<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;
<tr>
<td>
<div style="height:300px; overflow: hidden">
- <div class="mkws-termlists"></div>
+ <div class="mkws-facets"></div>
</div>
</td>
</tr>
<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;
<tr>
<td>
<div style="height:300px; overflow: hidden">
- <div class="mkws-termlists"></div>
+ <div class="mkws-facets"></div>
</div>
</td>
</tr>
"Subject": "موضوع",
"Location": "موقع",
// Facet heading and individual facet names
- "Termlists": "العضو الأجل",
+ "Facets": "العضو الأجل",
"Sources": "مصادر",
"Subjects": "المواضيع",
"Authors": "الكتاب",
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>
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>
<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;
<tr>
<td>
<div style="height:300px; overflow: hidden">
- <div class="mkws-termlists"></div>
+ <div class="mkws-facets"></div>
</div>
</td>
</tr>
'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 = {};
-mkws.registerWidgetType('termlists', function() {
+mkws.registerWidgetType('facets', function() {
// Initially hide the facets; display when we get results
var that = this;
var team = this.team;
}}
<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>
</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>
# 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;
+
});
});
-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;
// 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']");
# 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
clean:
rm -f index-*.html
+ rm -f iframe-*.html
rm -f ${IMAGES}/*.png
distclean: clean
${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; \
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 ""
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
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
-
<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>
--- /dev/null
+<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>
.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;
}