Merge
authorMike Taylor <mike@indexdata.com>
Mon, 29 Sep 2014 13:02:31 +0000 (14:02 +0100)
committerMike Taylor <mike@indexdata.com>
Mon, 29 Sep 2014 13:02:31 +0000 (14:02 +0100)
96 files changed:
.gitignore
LICENSE
Makefile
README
doc/.gitignore
doc/Makefile
doc/drupaljson.pl [new file with mode: 0755]
doc/mkws-developer.markdown [new file with mode: 0644]
doc/mkws-developer.txt [deleted file]
doc/mkws-doc.css
doc/mkws-manual.markdown
examples/apache2/mkws-examples
examples/apache2/mkws-examples-mike
examples/htdocs/async.html [new file with mode: 0644]
examples/htdocs/auto-paratext-minimal.html
examples/htdocs/auto-paratext.html
examples/htdocs/dict.html
examples/htdocs/heikki-motd.html
examples/htdocs/heikki.html
examples/htdocs/intro.html
examples/htdocs/jasmine-cors-popup.html
examples/htdocs/jasmine-local-popup.html
examples/htdocs/jasmine-popup.html
examples/htdocs/jasmine-pp2.html
examples/htdocs/jasmine.html
examples/htdocs/local-auto.html
examples/htdocs/local-auto3.html
examples/htdocs/mike.html
examples/htdocs/mike2.html
examples/htdocs/mkws-widget-credo-bs.js [deleted file]
examples/htdocs/mkws-widget-ru.js
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]
examples/htdocs/popup-dev.html
examples/htdocs/popup.html
examples/htdocs/ref-bootstrap.html [deleted file]
examples/htdocs/ref.html
examples/htdocs/reference.html
examples/htdocs/surlyauto.html
examples/htdocs/topic-bootstrap.css [new file with mode: 0644]
examples/htdocs/topic-bootstrap.html [new file with mode: 0644]
examples/htdocs/two-teams.html
examples/htdocs/wolfram.html
src/.gitignore [new file with mode: 0644]
src/mkws-core.js
src/mkws-handlebars.js
src/mkws-team.js
src/mkws-widget-builder.js
src/mkws-widget-categories.js
src/mkws-widget-main.js
src/mkws-widget-main.templates/Done.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Image.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Lang.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Navi.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Pager.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Progress.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Ranking.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Record.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Records.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Results.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Search.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Stat.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Switch.handlebars [new file with mode: 0644]
src/mkws-widget-main.templates/Targets.handlebars [new file with mode: 0644]
src/mkws-widget-record.js
src/mkws-widget-reference.js
src/mkws-widget-reference.templates/Reference.handlebars [new file with mode: 0644]
src/mkws-widget-termlists.js
src/mkws-widget-termlists.templates/Facet.handlebars [new file with mode: 0644]
src/mkws-widget-termlists.templates/Termlists.handlebars [new file with mode: 0644]
src/mkws-widget.js
test/.gitignore
test/Makefile
test/bin/bomb.pl
test/bin/yui-compressor [new file with mode: 0755]
test/package.json
test/spec/mkws-config.js
test/spec/mkws-pazpar2.js
tools/apache2/jasmine-dev.template
tools/apache2/mkws-dev
tools/apache2/mkws-live
tools/apache2/sp-mkws-live
tools/apache2/sp-mkws-mike [new file with mode: 0644]
tools/bin/nagios-service-proxy.sh
tools/htdocs/.gitignore
tools/htdocs/Makefile
tools/htdocs/no-service-proxy.html [new file with mode: 0644]
tools/service-proxy/.gitignore [new file with mode: 0644]
tools/service-proxy/Makefile [new file with mode: 0644]
tools/service-proxy/pazpar2/README [new file with mode: 0644]
tools/service-proxy/pazpar2/server.no-icu.xml [new file with mode: 0644]
tools/service-proxy/pazpar2/service.no-icu.xml [new file with mode: 0644]
tools/service-proxy/pazpar2/settings-testserver.xml [new file with mode: 0644]
tools/service-proxy/pazpar2/tmarc.xsl [new symlink]
tools/service-proxy/service-proxy.properties

index b25c15b..b72f9be 100644 (file)
@@ -1 +1,2 @@
 *~
+*.swp
diff --git a/LICENSE b/LICENSE
index 39d8b2e..65c5ca8 100644 (file)
--- a/LICENSE
+++ b/LICENSE
-LICENSE file of MKWS: the MasterKey Widget Set
-Copyright (C) 2013-2014 Index Data.
-
-
-                    GNU GENERAL PUBLIC LICENSE
+                   GNU LESSER GENERAL PUBLIC LICENSE
                        Version 3, 29 June 2007
 
  Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
-                            Preamble
-
-  The GNU General Public License is a free, copyleft license for
-software and other kinds of works.
-
-  The licenses for most software and other practical works are designed
-to take away your freedom to share and change the works.  By contrast,
-the GNU General Public License is intended to guarantee your freedom to
-share and change all versions of a program--to make sure it remains free
-software for all its users.  We, the Free Software Foundation, use the
-GNU General Public License for most of our software; it applies also to
-any other work released this way by its authors.  You can apply it to
-your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Our General Public Licenses are designed to make sure that you
-have the freedom to distribute copies of free software (and charge for
-them if you wish), that you receive source code or can get it if you
-want it, that you can change the software or use pieces of it in new
-free programs, and that you know you can do these things.
-
-  To protect your rights, we need to prevent others from denying you
-these rights or asking you to surrender the rights.  Therefore, you have
-certain responsibilities if you distribute copies of the software, or if
-you modify it: responsibilities to respect the freedom of others.
-
-  For example, if you distribute copies of such a program, whether
-gratis or for a fee, you must pass on to the recipients the same
-freedoms that you received.  You must make sure that they, too, receive
-or can get the source code.  And you must show them these terms so they
-know their rights.
-
-  Developers that use the GNU GPL protect your rights with two steps:
-(1) assert copyright on the software, and (2) offer you this License
-giving you legal permission to copy, distribute and/or modify it.
-
-  For the developers' and authors' protection, the GPL clearly explains
-that there is no warranty for this free software.  For both users' and
-authors' sake, the GPL requires that modified versions be marked as
-changed, so that their problems will not be attributed erroneously to
-authors of previous versions.
-
-  Some devices are designed to deny users access to install or run
-modified versions of the software inside them, although the manufacturer
-can do so.  This is fundamentally incompatible with the aim of
-protecting users' freedom to change the software.  The systematic
-pattern of such abuse occurs in the area of products for individuals to
-use, which is precisely where it is most unacceptable.  Therefore, we
-have designed this version of the GPL to prohibit the practice for those
-products.  If such problems arise substantially in other domains, we
-stand ready to extend this provision to those domains in future versions
-of the GPL, as needed to protect the freedom of users.
-
-  Finally, every program is threatened constantly by software patents.
-States should not allow patents to restrict development and use of
-software on general-purpose computers, but in those that do, we wish to
-avoid the special danger that patents applied to a free program could
-make it effectively proprietary.  To prevent this, the GPL assures that
-patents cannot be used to render the program non-free.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-                       TERMS AND CONDITIONS
-
-  0. Definitions.
-
-  "This License" refers to version 3 of the GNU General Public License.
-
-  "Copyright" also means copyright-like laws that apply to other kinds of
-works, such as semiconductor masks.
-
-  "The Program" refers to any copyrightable work licensed under this
-License.  Each licensee is addressed as "you".  "Licensees" and
-"recipients" may be individuals or organizations.
-
-  To "modify" a work means to copy from or adapt all or part of the work
-in a fashion requiring copyright permission, other than the making of an
-exact copy.  The resulting work is called a "modified version" of the
-earlier work or a work "based on" the earlier work.
-
-  A "covered work" means either the unmodified Program or a work based
-on the Program.
-
-  To "propagate" a work means to do anything with it that, without
-permission, would make you directly or secondarily liable for
-infringement under applicable copyright law, except executing it on a
-computer or modifying a private copy.  Propagation includes copying,
-distribution (with or without modification), making available to the
-public, and in some countries other activities as well.
-
-  To "convey" a work means any kind of propagation that enables other
-parties to make or receive copies.  Mere interaction with a user through
-a computer network, with no transfer of a copy, is not conveying.
-
-  An interactive user interface displays "Appropriate Legal Notices"
-to the extent that it includes a convenient and prominently visible
-feature that (1) displays an appropriate copyright notice, and (2)
-tells the user that there is no warranty for the work (except to the
-extent that warranties are provided), that licensees may convey the
-work under this License, and how to view a copy of this License.  If
-the interface presents a list of user commands or options, such as a
-menu, a prominent item in the list meets this criterion.
-
-  1. Source Code.
-
-  The "source code" for a work means the preferred form of the work
-for making modifications to it.  "Object code" means any non-source
-form of a work.
-
-  A "Standard Interface" means an interface that either is an official
-standard defined by a recognized standards body, or, in the case of
-interfaces specified for a particular programming language, one that
-is widely used among developers working in that language.
-
-  The "System Libraries" of an executable work include anything, other
-than the work as a whole, that (a) is included in the normal form of
-packaging a Major Component, but which is not part of that Major
-Component, and (b) serves only to enable use of the work with that
-Major Component, or to implement a Standard Interface for which an
-implementation is available to the public in source code form.  A
-"Major Component", in this context, means a major essential component
-(kernel, window system, and so on) of the specific operating system
-(if any) on which the executable work runs, or a compiler used to
-produce the work, or an object code interpreter used to run it.
-
-  The "Corresponding Source" for a work in object code form means all
-the source code needed to generate, install, and (for an executable
-work) run the object code and to modify the work, including scripts to
-control those activities.  However, it does not include the work's
-System Libraries, or general-purpose tools or generally available free
-programs which are used unmodified in performing those activities but
-which are not part of the work.  For example, Corresponding Source
-includes interface definition files associated with source files for
-the work, and the source code for shared libraries and dynamically
-linked subprograms that the work is specifically designed to require,
-such as by intimate data communication or control flow between those
-subprograms and other parts of the work.
-
-  The Corresponding Source need not include anything that users
-can regenerate automatically from other parts of the Corresponding
-Source.
-
-  The Corresponding Source for a work in source code form is that
-same work.
-
-  2. Basic Permissions.
-
-  All rights granted under this License are granted for the term of
-copyright on the Program, and are irrevocable provided the stated
-conditions are met.  This License explicitly affirms your unlimited
-permission to run the unmodified Program.  The output from running a
-covered work is covered by this License only if the output, given its
-content, constitutes a covered work.  This License acknowledges your
-rights of fair use or other equivalent, as provided by copyright law.
-
-  You may make, run and propagate covered works that you do not
-convey, without conditions so long as your license otherwise remains
-in force.  You may convey covered works to others for the sole purpose
-of having them make modifications exclusively for you, or provide you
-with facilities for running those works, provided that you comply with
-the terms of this License in conveying all material for which you do
-not control copyright.  Those thus making or running the covered works
-for you must do so exclusively on your behalf, under your direction
-and control, on terms that prohibit them from making any copies of
-your copyrighted material outside their relationship with you.
-
-  Conveying under any other circumstances is permitted solely under
-the conditions stated below.  Sublicensing is not allowed; section 10
-makes it unnecessary.
-
-  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
-
-  No covered work shall be deemed part of an effective technological
-measure under any applicable law fulfilling obligations under article
-11 of the WIPO copyright treaty adopted on 20 December 1996, or
-similar laws prohibiting or restricting circumvention of such
-measures.
-
-  When you convey a covered work, you waive any legal power to forbid
-circumvention of technological measures to the extent such circumvention
-is effected by exercising rights under this License with respect to
-the covered work, and you disclaim any intention to limit operation or
-modification of the work as a means of enforcing, against the work's
-users, your or third parties' legal rights to forbid circumvention of
-technological measures.
-
-  4. Conveying Verbatim Copies.
-
-  You may convey verbatim copies of the Program's source code as you
-receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice;
-keep intact all notices stating that this License and any
-non-permissive terms added in accord with section 7 apply to the code;
-keep intact all notices of the absence of any warranty; and give all
-recipients a copy of this License along with the Program.
-
-  You may charge any price or no price for each copy that you convey,
-and you may offer support or warranty protection for a fee.
-
-  5. Conveying Modified Source Versions.
-
-  You may convey a work based on the Program, or the modifications to
-produce it from the Program, in the form of source code under the
-terms of section 4, provided that you also meet all of these conditions:
-
-    a) The work must carry prominent notices stating that you modified
-    it, and giving a relevant date.
-
-    b) The work must carry prominent notices stating that it is
-    released under this License and any conditions added under section
-    7.  This requirement modifies the requirement in section 4 to
-    "keep intact all notices".
-
-    c) You must license the entire work, as a whole, under this
-    License to anyone who comes into possession of a copy.  This
-    License will therefore apply, along with any applicable section 7
-    additional terms, to the whole of the work, and all its parts,
-    regardless of how they are packaged.  This License gives no
-    permission to license the work in any other way, but it does not
-    invalidate such permission if you have separately received it.
-
-    d) If the work has interactive user interfaces, each must display
-    Appropriate Legal Notices; however, if the Program has interactive
-    interfaces that do not display Appropriate Legal Notices, your
-    work need not make them do so.
-
-  A compilation of a covered work with other separate and independent
-works, which are not by their nature extensions of the covered work,
-and which are not combined with it such as to form a larger program,
-in or on a volume of a storage or distribution medium, is called an
-"aggregate" if the compilation and its resulting copyright are not
-used to limit the access or legal rights of the compilation's users
-beyond what the individual works permit.  Inclusion of a covered work
-in an aggregate does not cause this License to apply to the other
-parts of the aggregate.
-
-  6. Conveying Non-Source Forms.
-
-  You may convey a covered work in object code form under the terms
-of sections 4 and 5, provided that you also convey the
-machine-readable Corresponding Source under the terms of this License,
-in one of these ways:
-
-    a) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by the
-    Corresponding Source fixed on a durable physical medium
-    customarily used for software interchange.
-
-    b) Convey the object code in, or embodied in, a physical product
-    (including a physical distribution medium), accompanied by a
-    written offer, valid for at least three years and valid for as
-    long as you offer spare parts or customer support for that product
-    model, to give anyone who possesses the object code either (1) a
-    copy of the Corresponding Source for all the software in the
-    product that is covered by this License, on a durable physical
-    medium customarily used for software interchange, for a price no
-    more than your reasonable cost of physically performing this
-    conveying of source, or (2) access to copy the
-    Corresponding Source from a network server at no charge.
-
-    c) Convey individual copies of the object code with a copy of the
-    written offer to provide the Corresponding Source.  This
-    alternative is allowed only occasionally and noncommercially, and
-    only if you received the object code with such an offer, in accord
-    with subsection 6b.
-
-    d) Convey the object code by offering access from a designated
-    place (gratis or for a charge), and offer equivalent access to the
-    Corresponding Source in the same way through the same place at no
-    further charge.  You need not require recipients to copy the
-    Corresponding Source along with the object code.  If the place to
-    copy the object code is a network server, the Corresponding Source
-    may be on a different server (operated by you or a third party)
-    that supports equivalent copying facilities, provided you maintain
-    clear directions next to the object code saying where to find the
-    Corresponding Source.  Regardless of what server hosts the
-    Corresponding Source, you remain obligated to ensure that it is
-    available for as long as needed to satisfy these requirements.
-
-    e) Convey the object code using peer-to-peer transmission, provided
-    you inform other peers where the object code and Corresponding
-    Source of the work are being offered to the general public at no
-    charge under subsection 6d.
-
-  A separable portion of the object code, whose source code is excluded
-from the Corresponding Source as a System Library, need not be
-included in conveying the object code work.
-
-  A "User Product" is either (1) a "consumer product", which means any
-tangible personal property which is normally used for personal, family,
-or household purposes, or (2) anything designed or sold for incorporation
-into a dwelling.  In determining whether a product is a consumer product,
-doubtful cases shall be resolved in favor of coverage.  For a particular
-product received by a particular user, "normally used" refers to a
-typical or common use of that class of product, regardless of the status
-of the particular user or of the way in which the particular user
-actually uses, or expects or is expected to use, the product.  A product
-is a consumer product regardless of whether the product has substantial
-commercial, industrial or non-consumer uses, unless such uses represent
-the only significant mode of use of the product.
-
-  "Installation Information" for a User Product means any methods,
-procedures, authorization keys, or other information required to install
-and execute modified versions of a covered work in that User Product from
-a modified version of its Corresponding Source.  The information must
-suffice to ensure that the continued functioning of the modified object
-code is in no case prevented or interfered with solely because
-modification has been made.
-
-  If you convey an object code work under this section in, or with, or
-specifically for use in, a User Product, and the conveying occurs as
-part of a transaction in which the right of possession and use of the
-User Product is transferred to the recipient in perpetuity or for a
-fixed term (regardless of how the transaction is characterized), the
-Corresponding Source conveyed under this section must be accompanied
-by the Installation Information.  But this requirement does not apply
-if neither you nor any third party retains the ability to install
-modified object code on the User Product (for example, the work has
-been installed in ROM).
-
-  The requirement to provide Installation Information does not include a
-requirement to continue to provide support service, warranty, or updates
-for a work that has been modified or installed by the recipient, or for
-the User Product in which it has been modified or installed.  Access to a
-network may be denied when the modification itself materially and
-adversely affects the operation of the network or violates the rules and
-protocols for communication across the network.
-
-  Corresponding Source conveyed, and Installation Information provided,
-in accord with this section must be in a format that is publicly
-documented (and with an implementation available to the public in
-source code form), and must require no special password or key for
-unpacking, reading or copying.
-
-  7. Additional Terms.
-
-  "Additional permissions" are terms that supplement the terms of this
-License by making exceptions from one or more of its conditions.
-Additional permissions that are applicable to the entire Program shall
-be treated as though they were included in this License, to the extent
-that they are valid under applicable law.  If additional permissions
-apply only to part of the Program, that part may be used separately
-under those permissions, but the entire Program remains governed by
-this License without regard to the additional permissions.
-
-  When you convey a copy of a covered work, you may at your option
-remove any additional permissions from that copy, or from any part of
-it.  (Additional permissions may be written to require their own
-removal in certain cases when you modify the work.)  You may place
-additional permissions on material, added by you to a covered work,
-for which you have or can give appropriate copyright permission.
-
-  Notwithstanding any other provision of this License, for material you
-add to a covered work, you may (if authorized by the copyright holders of
-that material) supplement the terms of this License with terms:
-
-    a) Disclaiming warranty or limiting liability differently from the
-    terms of sections 15 and 16 of this License; or
-
-    b) Requiring preservation of specified reasonable legal notices or
-    author attributions in that material or in the Appropriate Legal
-    Notices displayed by works containing it; or
-
-    c) Prohibiting misrepresentation of the origin of that material, or
-    requiring that modified versions of such material be marked in
-    reasonable ways as different from the original version; or
-
-    d) Limiting the use for publicity purposes of names of licensors or
-    authors of the material; or
-
-    e) Declining to grant rights under trademark law for use of some
-    trade names, trademarks, or service marks; or
-
-    f) Requiring indemnification of licensors and authors of that
-    material by anyone who conveys the material (or modified versions of
-    it) with contractual assumptions of liability to the recipient, for
-    any liability that these contractual assumptions directly impose on
-    those licensors and authors.
-
-  All other non-permissive additional terms are considered "further
-restrictions" within the meaning of section 10.  If the Program as you
-received it, or any part of it, contains a notice stating that it is
-governed by this License along with a term that is a further
-restriction, you may remove that term.  If a license document contains
-a further restriction but permits relicensing or conveying under this
-License, you may add to a covered work material governed by the terms
-of that license document, provided that the further restriction does
-not survive such relicensing or conveying.
-
-  If you add terms to a covered work in accord with this section, you
-must place, in the relevant source files, a statement of the
-additional terms that apply to those files, or a notice indicating
-where to find the applicable terms.
-
-  Additional terms, permissive or non-permissive, may be stated in the
-form of a separately written license, or stated as exceptions;
-the above requirements apply either way.
-
-  8. Termination.
-
-  You may not propagate or modify a covered work except as expressly
-provided under this License.  Any attempt otherwise to propagate or
-modify it is void, and will automatically terminate your rights under
-this License (including any patent licenses granted under the third
-paragraph of section 11).
-
-  However, if you cease all violation of this License, then your
-license from a particular copyright holder is reinstated (a)
-provisionally, unless and until the copyright holder explicitly and
-finally terminates your license, and (b) permanently, if the copyright
-holder fails to notify you of the violation by some reasonable means
-prior to 60 days after the cessation.
-
-  Moreover, your license from a particular copyright holder is
-reinstated permanently if the copyright holder notifies you of the
-violation by some reasonable means, this is the first time you have
-received notice of violation of this License (for any work) from that
-copyright holder, and you cure the violation prior to 30 days after
-your receipt of the notice.
-
-  Termination of your rights under this section does not terminate the
-licenses of parties who have received copies or rights from you under
-this License.  If your rights have been terminated and not permanently
-reinstated, you do not qualify to receive new licenses for the same
-material under section 10.
-
-  9. Acceptance Not Required for Having Copies.
-
-  You are not required to accept this License in order to receive or
-run a copy of the Program.  Ancillary propagation of a covered work
-occurring solely as a consequence of using peer-to-peer transmission
-to receive a copy likewise does not require acceptance.  However,
-nothing other than this License grants you permission to propagate or
-modify any covered work.  These actions infringe copyright if you do
-not accept this License.  Therefore, by modifying or propagating a
-covered work, you indicate your acceptance of this License to do so.
-
-  10. Automatic Licensing of Downstream Recipients.
-
-  Each time you convey a covered work, the recipient automatically
-receives a license from the original licensors, to run, modify and
-propagate that work, subject to this License.  You are not responsible
-for enforcing compliance by third parties with this License.
-
-  An "entity transaction" is a transaction transferring control of an
-organization, or substantially all assets of one, or subdividing an
-organization, or merging organizations.  If propagation of a covered
-work results from an entity transaction, each party to that
-transaction who receives a copy of the work also receives whatever
-licenses to the work the party's predecessor in interest had or could
-give under the previous paragraph, plus a right to possession of the
-Corresponding Source of the work from the predecessor in interest, if
-the predecessor has it or can get it with reasonable efforts.
-
-  You may not impose any further restrictions on the exercise of the
-rights granted or affirmed under this License.  For example, you may
-not impose a license fee, royalty, or other charge for exercise of
-rights granted under this License, and you may not initiate litigation
-(including a cross-claim or counterclaim in a lawsuit) alleging that
-any patent claim is infringed by making, using, selling, offering for
-sale, or importing the Program or any portion of it.
-
-  11. Patents.
-
-  A "contributor" is a copyright holder who authorizes use under this
-License of the Program or a work on which the Program is based.  The
-work thus licensed is called the contributor's "contributor version".
-
-  A contributor's "essential patent claims" are all patent claims
-owned or controlled by the contributor, whether already acquired or
-hereafter acquired, that would be infringed by some manner, permitted
-by this License, of making, using, or selling its contributor version,
-but do not include claims that would be infringed only as a
-consequence of further modification of the contributor version.  For
-purposes of this definition, "control" includes the right to grant
-patent sublicenses in a manner consistent with the requirements of
-this License.
-
-  Each contributor grants you a non-exclusive, worldwide, royalty-free
-patent license under the contributor's essential patent claims, to
-make, use, sell, offer for sale, import and otherwise run, modify and
-propagate the contents of its contributor version.
-
-  In the following three paragraphs, a "patent license" is any express
-agreement or commitment, however denominated, not to enforce a patent
-(such as an express permission to practice a patent or covenant not to
-sue for patent infringement).  To "grant" such a patent license to a
-party means to make such an agreement or commitment not to enforce a
-patent against the party.
-
-  If you convey a covered work, knowingly relying on a patent license,
-and the Corresponding Source of the work is not available for anyone
-to copy, free of charge and under the terms of this License, through a
-publicly available network server or other readily accessible means,
-then you must either (1) cause the Corresponding Source to be so
-available, or (2) arrange to deprive yourself of the benefit of the
-patent license for this particular work, or (3) arrange, in a manner
-consistent with the requirements of this License, to extend the patent
-license to downstream recipients.  "Knowingly relying" means you have
-actual knowledge that, but for the patent license, your conveying the
-covered work in a country, or your recipient's use of the covered work
-in a country, would infringe one or more identifiable patents in that
-country that you have reason to believe are valid.
-
-  If, pursuant to or in connection with a single transaction or
-arrangement, you convey, or propagate by procuring conveyance of, a
-covered work, and grant a patent license to some of the parties
-receiving the covered work authorizing them to use, propagate, modify
-or convey a specific copy of the covered work, then the patent license
-you grant is automatically extended to all recipients of the covered
-work and works based on it.
-
-  A patent license is "discriminatory" if it does not include within
-the scope of its coverage, prohibits the exercise of, or is
-conditioned on the non-exercise of one or more of the rights that are
-specifically granted under this License.  You may not convey a covered
-work if you are a party to an arrangement with a third party that is
-in the business of distributing software, under which you make payment
-to the third party based on the extent of your activity of conveying
-the work, and under which the third party grants, to any of the
-parties who would receive the covered work from you, a discriminatory
-patent license (a) in connection with copies of the covered work
-conveyed by you (or copies made from those copies), or (b) primarily
-for and in connection with specific products or compilations that
-contain the covered work, unless you entered into that arrangement,
-or that patent license was granted, prior to 28 March 2007.
-
-  Nothing in this License shall be construed as excluding or limiting
-any implied license or other defenses to infringement that may
-otherwise be available to you under applicable patent law.
-
-  12. No Surrender of Others' Freedom.
-
-  If conditions are imposed on you (whether by court order, agreement or
-otherwise) that contradict the conditions of this License, they do not
-excuse you from the conditions of this License.  If you cannot convey a
-covered work so as to satisfy simultaneously your obligations under this
-License and any other pertinent obligations, then as a consequence you may
-not convey it at all.  For example, if you agree to terms that obligate you
-to collect a royalty for further conveying from those to whom you convey
-the Program, the only way you could satisfy both those terms and this
-License would be to refrain entirely from conveying the Program.
-
-  13. Use with the GNU Affero General Public License.
-
-  Notwithstanding any other provision of this License, you have
-permission to link or combine any covered work with a work licensed
-under version 3 of the GNU Affero General Public License into a single
-combined work, and to convey the resulting work.  The terms of this
-License will continue to apply to the part which is the covered work,
-but the special requirements of the GNU Affero General Public License,
-section 13, concerning interaction through a network will apply to the
-combination as such.
-
-  14. Revised Versions of this License.
-
-  The Free Software Foundation may publish revised and/or new versions of
-the GNU General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-  Each version is given a distinguishing version number.  If the
-Program specifies that a certain numbered version of the GNU General
-Public License "or any later version" applies to it, you have the
-option of following the terms and conditions either of that numbered
-version or of any later version published by the Free Software
-Foundation.  If the Program does not specify a version number of the
-GNU General Public License, you may choose any version ever published
-by the Free Software Foundation.
-
-  If the Program specifies that a proxy can decide which future
-versions of the GNU General Public License can be used, that proxy's
-public statement of acceptance of a version permanently authorizes you
-to choose that version for the Program.
-
-  Later license versions may give you additional or different
-permissions.  However, no additional obligations are imposed on any
-author or copyright holder as a result of your choosing to follow a
-later version.
-
-  15. Disclaimer of Warranty.
-
-  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
-APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
-HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
-OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
-THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
-PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
-IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
-ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
-
-  16. Limitation of Liability.
-
-  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
-THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
-GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
-USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
-DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
-PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
-EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
-SUCH DAMAGES.
-
-  17. Interpretation of Sections 15 and 16.
-
-  If the disclaimer of warranty and limitation of liability provided
-above cannot be given local legal effect according to their terms,
-reviewing courts shall apply local law that most closely approximates
-an absolute waiver of all civil liability in connection with the
-Program, unless a warranty or assumption of liability accompanies a
-copy of the Program in return for a fee.
-
-                     END OF TERMS AND CONDITIONS
-
-            How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to the public, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these terms.
-
-  To do so, attach the following notices to the program.  It is safest
-to attach them to the start of each source file to most effectively
-state the exclusion of warranty; and each file should have at least
-the "copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) <year>  <name of author>
-
-    This program is free software: you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation, either version 3 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-Also add information on how to contact you by electronic and paper mail.
-
-  If the program does terminal interaction, make it output a short
-notice like this when it starts in an interactive mode:
-
-    <program>  Copyright (C) <year>  <name of author>
-    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the appropriate
-parts of the General Public License.  Of course, your program's commands
-might be different; for a GUI interface, you would use an "about box".
-
-  You should also get your employer (if you work as a programmer) or school,
-if any, to sign a "copyright disclaimer" for the program, if necessary.
-For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
-
-  The GNU General Public License does not permit incorporating your program
-into proprietary programs.  If your program is a subroutine library, you
-may consider it more useful to permit linking proprietary applications with
-the library.  If this is what you want to do, use the GNU Lesser General
-Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+
+  This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+  0. Additional Definitions.
+
+  As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+  "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+  An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+  A "Combined Work" is a work produced by combining or linking an
+Application with the Library.  The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+  The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+  The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+  1. Exception to Section 3 of the GNU GPL.
+
+  You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+  2. Conveying Modified Versions.
+
+  If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+   a) under this License, provided that you make a good faith effort to
+   ensure that, in the event an Application does not supply the
+   function or data, the facility still operates, and performs
+   whatever part of its purpose remains meaningful, or
+
+   b) under the GNU GPL, with none of the additional permissions of
+   this License applicable to that copy.
+
+  3. Object Code Incorporating Material from Library Header Files.
+
+  The object code form of an Application may incorporate material from
+a header file that is part of the Library.  You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+   a) Give prominent notice with each copy of the object code that the
+   Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the object code with a copy of the GNU GPL and this license
+   document.
+
+  4. Combined Works.
+
+  You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+   a) Give prominent notice with each copy of the Combined Work that
+   the Library is used in it and that the Library and its use are
+   covered by this License.
+
+   b) Accompany the Combined Work with a copy of the GNU GPL and this license
+   document.
+
+   c) For a Combined Work that displays copyright notices during
+   execution, include the copyright notice for the Library among
+   these notices, as well as a reference directing the user to the
+   copies of the GNU GPL and this license document.
+
+   d) Do one of the following:
+
+       0) Convey the Minimal Corresponding Source under the terms of this
+       License, and the Corresponding Application Code in a form
+       suitable for, and under terms that permit, the user to
+       recombine or relink the Application with a modified version of
+       the Linked Version to produce a modified Combined Work, in the
+       manner specified by section 6 of the GNU GPL for conveying
+       Corresponding Source.
+
+       1) Use a suitable shared library mechanism for linking with the
+       Library.  A suitable mechanism is one that (a) uses at run time
+       a copy of the Library already present on the user's computer
+       system, and (b) will operate properly with a modified version
+       of the Library that is interface-compatible with the Linked
+       Version.
+
+   e) Provide Installation Information, but only if you would otherwise
+   be required to provide such information under section 6 of the
+   GNU GPL, and only to the extent that such information is
+   necessary to install and execute a modified version of the
+   Combined Work produced by recombining or relinking the
+   Application with a modified version of the Linked Version. (If
+   you use option 4d0, the Installation Information must accompany
+   the Minimal Corresponding Source and Corresponding Application
+   Code. If you use option 4d1, you must provide the Installation
+   Information in the manner specified by section 6 of the GNU GPL
+   for conveying Corresponding Source.)
+
+  5. Combined Libraries.
+
+  You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+   a) Accompany the combined library with a copy of the same work based
+   on the Library, uncombined with any other library facilities,
+   conveyed under the terms of this License.
+
+   b) Give prominent notice with the combined library that part of it
+   is a work based on the Library, and explaining where to find the
+   accompanying uncombined form of the same work.
+
+  6. Revised Versions of the GNU Lesser General Public License.
+
+  The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+  Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+  If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
index e80e8e3..9e91192 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -17,12 +17,15 @@ phantomjs p p-all phantomjs-all jsb:
        ${MAKE} -C./test $@
 
 # must be called once after GIT checkout
-setup: 
+setup:
        ${MAKE} -C./test node-modules
+       ${MAKE} all
 
 check: setup check-js phantomjs
 
 help:
        @echo "make [ all | setup | clean | distclean ]"
        @echo "     [ check | check-js | phantomjs ]"
+       @echo ""
+       @echo "If 'make check' timeout is too short, extend with: make check PHANTOMJS_TIMEOUT=40"
 
diff --git a/README b/README
index 5696cd1..7aacc48 100644 (file)
--- a/README
+++ b/README
@@ -30,6 +30,11 @@ or you can download the source from http://nodejs.org/download/ and build
 it yourself. Looks like you need node and npm, make install puts them
 into /usr/local/bin.
 
+To compile the default templates you'll need to install the stable version
+of Handlebars. Currently it's at 1.3.0 and available by npm:
+
+  npm install handlebars@1.3.0 -g
+
 For apache setup, see tools/apache2/README
 
 NEWS
index 5d3ccd7..653ed0c 100644 (file)
@@ -4,3 +4,6 @@ README.pdf
 mkws-manual.html
 mkws-manual.odt
 mkws-manual.pdf
+mkws-developer.html
+mkws-developer.odt
+mkws-developer.pdf
index 19b9dfb..d87c1f8 100644 (file)
@@ -1,9 +1,10 @@
 # Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com
 
 DOCS = README.html README.odt README.pdf \
-       mkws-manual.html mkws-manual.odt mkws-manual.pdf
+       mkws-manual.html mkws-manual.odt mkws-manual.pdf \
+       mkws-developer.html mkws-developer.odt mkws-developer.pdf
 
-INSTALLABLE = README.html mkws-manual.html mkws-doc.css
+INSTALLABLE = README.html mkws-manual.html mkws-developer.html mkws-doc.css
 INSTALLED = $(INSTALLABLE:%=../tools/htdocs/%)
 
 install: $(INSTALLED)
@@ -44,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;
diff --git a/doc/mkws-developer.markdown b/doc/mkws-developer.markdown
new file mode 100644 (file)
index 0000000..00a5b59
--- /dev/null
@@ -0,0 +1,261 @@
+% The MasterKey Widget Set developer's guide
+% Mike Taylor
+% 11 August 2014
+
+
+Overview
+========
+
+Core concepts
+-------------
+
+Development with MKWS consists primarily of defining new types of
+widgets. These can interact with the core functionality is several
+defined ways.
+
+You create a new widget type by calling the `mkws.registerWidgetType`
+function, passing in the widget name and a function. The name is used
+to recognise HTML elements as being widgets of this type -- for
+example, if you register a `Foo` widget, elements like
+`<div class="mkwsFoo">` will be widgets of this type.
+
+The function promotes a bare widget object (passed as `this`) into a
+widget of the appropriate type. MKWS doesn't use classes or explicit
+prototypes: it just makes objects that have the necessary
+behaviours. There are _no_ behaviours that Widgets are obliged to
+provide: you can make a doesn't-do-anything-at-all widget if you like:
+
+       mkws.registerWidgetType('Sluggard', function() {});
+
+More commonly, widgets will subscribe to one or more events, so that
+they're notified when something interesting happens. For example, the
+`Log` widget asks to be notified when a `log` event happens, and
+appends the logged message to its node, as follows:
+
+       mkws.registerWidgetType('Log', function() {
+         var that = this;
+
+         this.team.queue("log").subscribe(function(teamName, timestamp, message) {
+           $(that.node).append(teamName + ": " + timestamp + message + "<br/>");
+         });
+       });
+
+This simple widget illustrates several important points:
+
+* The base widget object (`this`) has several baked-in properties and
+  methods that are available to individual widgets. These include
+  `this.team` (the team that this widget is a part of) and `this.node`
+  (the DOM element of the widget). See below for a full list.
+
+* The team object (`this.team`) also has baked-in properties and
+  methods. These include the `queue` function, which takes an event-name
+  as its argument. See below for a full list.
+
+* You can add functionality to a widget by subscribing it to an
+  event's queue using `this.team.queue("EVENT").subscribe`. The
+  argument is a function which is called whenever the event is
+  published. The arguments to the function are different for different
+  events.
+
+* As with so much JavaScript programming, the value of the special
+  variable `this` is lost inside the `subscribez` callback function,
+  so it must be saved if it's to be used inside that callback
+  (typically as a local variable named `that`).
+
+
+Widget specialisation (inheritance)
+-----------------------------------
+
+Many widgets are simple specialisations of existing widgets. For
+example, the `Record` widget is the same as the `Records` widget
+except that it defaults to displaying a single record. It's defined as
+follows:
+
+       mkws.registerWidgetType('Record', function() {
+         mkws.promotionFunction('Records').call(this);
+         if (!this.config.maxrecs) this.config.maxrecs = 1;
+       });
+
+Remember that when a promotion function is called, it's passed a base
+widget object that's not specialised for any particular task. To make
+a specialised widget, you first promote that base widget into the type
+that you want to specialise from -- in this case, `Records` -- using
+the promotion function that's been registered for that type.
+
+Once this has been done, the specialisations can be introduced. In
+this case, it's a very simple matter of changing the `maxrecs`
+configuration setting to 1 unless it's already been given an explicit
+value. (That would occur if the HTML used an element like `<div
+class="mkwsRecord" maxrecs="2">`, though it's not obvious why anyone
+would do that.)
+
+
+Reference Guide
+===============
+
+
+Widget properties and methods
+-----------------------------
+
+The following properties and methods exist in the bare widget object
+that is passed into `registerWidgetType`'s callback function, and can
+be used by the derived widget.
+
+* `String this.type` --
+       A string containing the type of the widget.
+
+* `Team this.team` --
+       The team object to which this widget belongs. The team has
+       several additional important properties and methods, described
+       below.
+
+* `DOMElement this.node` --
+       The DOM element of the widget
+
+* `Hash this.config` --
+       A table of configuration values for the widget. This table
+       inherits missing values from the team's configuration, which
+       in turn inherits from the top-level MKWS configuration, which
+       inherits from the default configuration. Instances of widgets
+       in HTML can set configuration items as HTML attributes: for
+       example, the HTML element
+       `<div class="mkwsRecords" maxrecs="10">`.
+       creates a widget for which `this.config.maxrecs` is set to 10.
+
+* `String this.toString()` --
+       A function returning a string that briefly names this
+       widget. Can be useful in logging.
+
+* `Void this.log(string)` --
+       A function to log a string for debugging purposes. The string
+       is written on the browser console, and also published to any
+       subcribers to the `log` event.
+
+* `String this.value()` --
+       A function returning the value of the widget's HTML element.
+
+* `VOID autosearch()` --
+       Registers that this kind of widget is one that requires an
+       automatic search to be run for it if an `autosearch` attribute
+       is provided on the HTML element. This is appropriate for
+       widgets such as `Records` and `Facet` that display some part
+       of a search result.
+
+* `VOID hideWhenNarrow()` --
+       Registers that this widget should hide itself when the page
+       becomes "narrow" -- that is, fewer pixels in width that the
+       threshhold value specified by the top-level configuration item
+       `responsive_design_width`. Should be used for "unimportant"
+       widgets that can be omitted from the mobile version of a site.
+
+* `expandValue()` --
+       TODO: either document this or remove it from the API.
+
+* `subwidget(type, overrides, defaults)` --
+       Returns the HTML of a subwidget of the specified type, which
+       can then be inserted into the widget using the
+       `this.node.html` function. The subwidget is given the same
+       attributes at the parent widget that invokes this function,
+       except where overrides are passed in. If defaults are also
+       provided, then these are used when the parent widget provides
+       no values. Both the `overrides` and `defaults` arguments are
+       hashes: the latter is optional.
+  
+       See for example the `Credo` widget defined in the example
+       area's `mkws-widget-credo.js` file. This uses several
+       invocations of `subwidget` to create a complex compound widget
+       with numerous text, facet and image panes. TODO: rename this
+       widget and everything related to it.
+
+In addition to these properties and methods of the bare widget object,
+some kinds of specific widget add other properties of their own. For
+example, the `Builder` widget uses a `callback` property as the
+function that it use to publish the widget definition that it
+constructs. This defaults to the builtin function `alert`, but can be
+overridden by derived widgets such as `ConsoleBuilder`.
+
+
+Team methods
+------------
+
+Since the team object is supposed to be opaque to widgets, all access
+is via the following API methods rather than direct access to
+properties.
+
+* `String team.name()`
+* `Bool team.submitted()`
+* `Num team.perpage()`
+* `Num team.totalRecordCount()`
+* `Num team.currentPage();`
+* `String team.currentRecordId()`
+* `String team.currentRecordData()`
+
+These are all simple accessor functions that provide the ability to
+read properties of the team.
+
+* `Array team.filters()` --
+       Another accessor function, providing access to the array of
+       prevailing filters (which narrow the search results by means
+       of Pazpar2 filters and limits). This is really too complicated
+       an object for the widgets to be given access to, but it's
+       convenient to do it this way. If you must insist on using
+       this, see the `Navi` widget, which is the only place it's used.
+
+* `Bool team.targetFiltered(targetId)` --
+       Indicates whether the specified target has been filtered by
+       selection as a facet. This is used only by the `Facet` widget,
+       and there is probably no reason for you to use it.
+
+* `Hash team.config()` --
+       Access to the team's configuration settings. There is almost
+       certainly no reason to use this: the settings that haven't
+       been overridden are accessible via `this.config`.
+
+* `Void team.set_sortOrder(string)`, `Void team.set_perpage(number)` --
+       "Setter" functions for the team's sortOrder and perpage
+       functions. Unlikely to be needed outside of the `Sort` and
+       `Perpage` widgets.
+
+* `Queue team.queue(eventName)` --
+       Returns the queue associated with the named event: this can be
+       used to subscribe to the event (or more rarely to publish it).
+
+* `Void team.newSearch(query, sortOrder, maxrecs, perpage, limit, targets, targetfilter)` --
+       Starts a new search with the specified parameters. All but the
+       query may be omitted, in which case the prevailing defaults
+       are used.
+
+* `Void team.reShow()` --
+       Using the existing search, re-shows the result records after a
+       change in sort-order, per-page count, etc.
+
+* `String team.recordElementId(recordId)` --
+       Utility function for converting a record identifer (returned
+       from Pazpar2) into a version suitable for use as an HTML
+       element ID.
+
+* `String team.renderDetails(recordData)` --
+       Utility function returns an HTML rendering of the record
+       represented by the specified data.
+
+* `Template team.loadTemplate(templateName)` --
+       Loads (or retrieves from cache) the named Handlebars template,
+       and returns it in a form that can be invoked as a function,
+       passed a data-set.
+
+Some of these methods either (A) are really too low-level and should
+not be exposed, or (B) should be widget-level methods. The present
+infelicities reflect the fact that some code that rightly belongs in
+widgets is still in the team. When we finish migrating it, the widget
+API should get simpler.
+
+
+Events
+------
+
+TODO: list of events that can be usefully subscribed to.
+
+
+- - -
+
+Copyright (C) 2013-2014 by IndexData ApS, <http://www.indexdata.com>
diff --git a/doc/mkws-developer.txt b/doc/mkws-developer.txt
deleted file mode 100644 (file)
index 693df63..0000000
+++ /dev/null
@@ -1,188 +0,0 @@
-INTRODUCTION
-============
-
-Development with MKWS consists primarily of defining new types of
-widgets. These can interact with the core functionality is several
-defined ways.
-
-You create a new widget type by calling the mkws.registerWidgetType
-function, passing in the widget name and a function. The name is used
-to recognise HTML elements as being widgets of this type -- for
-example, if you register a "Foo" widget, elements like <div
-class="mkwsFoo"> will be widgets of this type.
-
-The function promotes a bare widget object (passed as `this') into a
-widget of the appropriate type. MKWS doesn't use classes or explicit
-prototypes: it just makes objects that have the necessary
-behaviours. Widgets have *no* behaviours that they have to provide:
-you can make a doesn't-do-anything-at-all widget if you like:
-
-       mkws.registerWidgetType('Sluggard', function() {});
-
-More commonly, widgets will subscribe to one or more events, so that
-they're notified when something interesting happens. For example, the
-"Log" widget asks to be notified when a "log" event happens, and
-appends the logged message to its node, as follows:
-
-       mkws.registerWidgetType('Log', function() {
-           var that = this;
-
-           this.team.queue("log").subscribe(function(teamName, timestamp, message) {
-               $(that.node).append(teamName + ": " + timestamp + message + "<br/>");
-           });
-       });
-
-This simple widget illustrates several important points:
-
-* The base widget object (`this') has several baked-in properties and
-  methods that are available to individual widgets. These include
-  this.team (the team that this widget is a part of) and this.node
-  (the DOM element of the widget).
-
-* The team object (`this.team') also has baked-in properties and
-  methods. These include the queue function, which takes an event-name
-  as its argument. It's possible to subscribe to an event's queue
-  using this.team.queue("EVENT").subscribe. The argument is a function
-  which is called whenever the event is published. The arguments to
-  the function are different for different events.
-
-* The value of `this' is lost inside the subscribe callback, so it
-  must be saved if it's to be used inside that callback (typically as
-  a local variable named `that').
-
-
-SPECIALISATION (INHERITANCE)
-============================
-
-Many widgets are simple specialisations of existing widgets. For
-example, the "Record" widget is the same as the "Records" widget
-except that it defaults to displaying a single record. It's defined as
-follows:
-
-       mkws.registerWidgetType('Record', function() {
-           mkws.promotionFunction('Records').call(this);
-           if (!this.config.maxrecs) this.config.maxrecs = 1;
-       });
-
-Remember that when a promotion function is called, it's passed a base
-widget object that's not specialised for any particular task. To make
-a specialised widget, first promote that base widget into the type
-that you want to specialise from -- in this case, "Records" -- using
-the promotion function that's been registered for that type.
-
-Once this has been done, the specialisations can be introduced. In
-this case, it's a very simple matter of changing the "maxrecs"
-configuration setting to 1 unless it's already been given an explicit
-value. (That would occur if the HTML used an element like <div
-class="mkwsRecord" maxrecs="2">, though it's not obvious why anyone
-would do that.)
-
-
-WIDGET PROPERTIES AND METHODS
-=============================
-
-String this.type
-       A string containing the type of the widget.
-
-Team this.team
-       The team object to which this widget belongs. The team has
-       several additional important properties and methods, described
-       below.
-
-DOMElement this.node
-       The DOM element of the widget
-
-Hash this.config
-       A table of configuration values for the widget. This table
-       inherits missing values from the team's configuration, which
-       in turn inherits from the top-level MKWS configuration, which
-       inherits from the default configuration. Instances of widgets
-       in HTML can set configuration items as HTML attributes, as in
-       <div class="mkwsRecords" maxrecs="2">.
-
-String this.toString()
-       A function returning a string that briefly names this
-       widget. Can be useful in logging.
-
-Void this.log(string)
-       A function to log a string for debugging purposes. The string
-       is written on the browser console, and also published to any
-       "log" subcribers.
-
-String this.value()
-       A function returning the value of the widget's HTML element.
-
-
-TEAM METHODS
-============
-
-Since the team object is supposed to be opaque to widgets, all access
-is via the following API methods rather than direct access to
-properties.
-
-String team.name()
-Bool team.submitted()
-Num team.perpage()
-Num team.totalRecordCount()
-Num team.currentPage();
-String team.currentRecordId()
-String team.currentRecordData()
-       Simple accessor functions that provide the ability to read
-       properties of the team.
-
-Array team.filters()
-       Another accessor function, providing access to the array of
-       prevailing filters (which narrow the search results by means
-       of Pazpar2 filters and limits). This is really too complicated
-       an object for the widgets to be given access to, but it's
-       convenient to do it this way. See the "Navi" widget, which is
-       the only place it's used.
-
-Hash team.config()
-       Access to the team's configuration settings. There is almost
-       certainly no reason to use this: the settings that haven't
-       been overridden are accessible via this.config.
-
-Void team.set_sortOrder(string)
-Void team.set_perpage(number)
-       "Setter" functions for the team's sortOrder and perpage
-       functions. Unlikely to be needed outside of the "Sort" and
-       "Perpage" widgets.
-
-Queue team.queue(eventName)
-       Returns the queue associated with the named event: this can be
-       used to subscribe to the event (or more rarely to publish it).
-
-Bool team.targetFiltered(targetId)
-       Indicates whether the specified target has been filtered by
-       selection as a facet.
-
-Void team.newSearch(query, sortOrder, maxrecs, perpage, limit, targets, targetfilter)
-       Starts a new search with the specified parameters. All but the
-       query may be omitted, in which case the prevailing defaults
-       are used.
-
-Void team.reShow()
-       Using the existing search, re-shows the result records after a
-       change in sort-order, per-page count, etc.
-
-String team.recordElementId(recordId)
-       Utility function for converting a record identifer (returned
-       from Pazpar2) into a version suitable for use as an HTML
-       element ID.
-
-String team.renderDetails(recordData)
-       Utility function returns an HTML rendering of the record
-       represented by the specified data.
-
-Template team.loadTemplate(templateName)
-       Loads (or retrieves from cache) the named Handlebars template,
-       and returns it in a form that can be invoked as a function,
-       passed a data-set.
-
-Some of these methods either (A) are really too low-level and should
-not be exposed, or (B) should be widget-level methods. The present
-infelicities reflect the fact that some code that rightly belongs in
-widgets is still in the team. When we finish migrating it, the widget
-API should get simpler.
-
index 603999a..0eb4a34 100644 (file)
@@ -69,13 +69,3 @@ table tr:nth-child(odd) {
 table tr:nth-child(even) {
     background: #bfdcf8;
 }
-
-/*
- * Works with the HTML emitted by pandoc. It would better if pandoc
- * were to emit class names that we can use. But it doesn't.
- */  
-body > p:last-of-type {
-    font-size: small;
-    max-width: none;
-    text-align: right;
-}
index 2247868..fa86847 100644 (file)
@@ -482,7 +482,7 @@ yourname.com:
 Step 1: add a rewriting authentication alias to the configuration:
 
        RewriteEngine on
-       RewriteRule /spauth/ http://mkws.indexdata.com/service-proxy/?command=auth&action=check,login&username=U&password=PW [P]
+       RewriteRule /spauth/ http://sp-mkws.indexdata.com/service-proxy/?command=auth&action=check,login&username=U&password=PW [P]
 
 Step 2: set the MKWS configuration item `service_proxy_auth` to
 <http://yourname.com/spauth/>
@@ -620,9 +620,9 @@ structure.
 
 3. [10, 20, 30, 50]
 
-4. http://mkws.indexdata.com/service-proxy-auth
+4. http://sp-mkws.indexdata.com/service-proxy-auth
 
-5. http://mkws.indexdata.com/service-proxy/
+5. http://sp-mkws.indexdata.com/service-proxy/
 
 6. [["relevance"], ["title:1", "title"], ["date:0", "newest"], ["date:1", "oldest"]]
 
@@ -701,19 +701,19 @@ from that toolkit. The relevant lines are:
     </div>
 
 ----
-Element    Type    Default           Description
---------   -----   ---------         ------------
-popup_width     string     880       Width of the popup window (if used), in
-                                     pixels.
+Element         Type    Default             Description
+--------        -----   -------             ------------
+popup_width     string  880                 Width of the popup window (if used), in
+                                            pixels.
 
-popup_height    string     760       Height of the popup window (if used), in
-                                     pixels.
+popup_height    string  760                 Height of the popup window (if used), in
+                                            pixels.
 
-popup_button    string      input.mkwsButton  (Never change this.)
+popup_button    string  `input.mkwsButton`  (Never change this.)
 
-popup_modal     string      0       Modal confirmation mode. Valid values are 0 or 1
+popup_modal     string  0                   Modal confirmation mode. Valid values are 0 or 1
 
-popup_autoOpen  string      1       Open popup window on load. Valid values are 0 or 1
+popup_autoOpen  string  1                   Open popup window on load. Valid values are 0 or 1
 
 ----
 
index 42f0673..86f7cf2 100644 (file)
@@ -11,7 +11,7 @@
     CustomLog /var/log/apache2/mkws-examples-access.log combined
 
     RewriteEngine on
-    RewriteRule /service-proxy-auth http://mkws.indexdata.com/service-proxy/?command=auth&action=login&username=mkws&password=mkws [P]
+    RewriteRule /service-proxy-auth http://sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=mkws&password=mkws [P]
     #RewriteLog /var/log/apache2/mkws-examples-rewrite.log
     #RewriteLogLevel 9
 </VirtualHost>
index 4167584..1f0ae6d 100644 (file)
@@ -1,16 +1,20 @@
 <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
+    </Directory>
 
     ErrorLog /var/log/apache2/mkws-examples-error.log
     CustomLog /var/log/apache2/mkws-examples-access.log combined
 
     RewriteEngine on
-    RewriteRule      /service-proxy-auth/ http://mkws.indexdata.com/service-proxy/?command=auth&action=login&username=mkws&password=mkws [P]
+    RewriteRule      /service-proxy-auth/ http://sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=mkws&password=mkws [P]
     #RewriteLog /var/log/apache2/mkws-examples-rewrite.log
     #RewriteLogLevel 9
 </VirtualHost>
diff --git a/examples/htdocs/async.html b/examples/htdocs/async.html
new file mode 100644 (file)
index 0000000..e87ead4
--- /dev/null
@@ -0,0 +1,32 @@
+<?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: Async feeling.</title>
+    <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/jquery.json-2.4.js"></script>
+    <script type="text/javascript" src="http://mkws.indexdata.com/handlebars-v1.3.0.js"></script>
+    <script type="text/javascript" src="http://mkws.indexdata.com/pazpar2/js/pz2.js"></script>
+    <script type="text/javascript" src="http://mkws.local/mkws.js"></script>
+    <link rel="stylesheet" type="text/css" href="mkws-widget-reference.css" />
+  </head>
+  <body>
+    <div id="first"></div>
+    <script type="text/javascript">
+      $("#first").html("<div class='mkwsReference' autosearch='one' sentences='1'>result will appear here</div>");
+      mkws.init("First div", "#first");
+    </script>
+    <div id="second"></div>
+    <script type="text/javascript">
+      $("#second").html("<div class='mkwsReference' autosearch='two' sentences='1'>result will appear here</div>");
+      mkws.init("Second div", document.getElementById("second"));
+    </script>
+    <div id="third"></div>
+    <script type="text/javascript">
+      $("#third").html("<div class='mkwsReference' autosearch='three' sentences='1'>result will appear here</div>");
+      mkws.init("Third div", "#third");
+    </script>
+    <div class='mkwsReference' autosearch='four' sentences='1'>This would have been four but we're not searching it.</div>
+  </body>
+</html>
index 24f14cc..8ee72ab 100644 (file)
@@ -2,7 +2,7 @@
   <link rel="stylesheet" type="text/css" href="//mkws.indexdata.com/mkws.css" />
   <script type="text/javascript">
     mkws_config = {
-      service_proxy_auth: "http://mkws.indexdata.com/service-proxy/?command=auth&action=login&username=paratext&password=paratext_mkc",
+      service_proxy_auth: "http://sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=paratext&password=paratext_mkc",
       perpage_default: 5,
    };
   </script>
index b7c0b88..1d6c86a 100644 (file)
@@ -8,13 +8,13 @@
     <link rel="stylesheet" type="text/css" href="//mkws.indexdata.com/mkws.css" />
     <script type="text/javascript">
       mkws_config = {
-        service_proxy_auth: "http://mkws.indexdata.com/service-proxy/?command=auth&action=login&username=paratext&password=paratext_mkc",
+        service_proxy_auth: "http://sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=paratext&password=paratext_mkc",
        perpage_default: 5,
      };
     </script>
     <script type="text/javascript" src="//code.jquery.com/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="//mkws.indexdata.com/jquery.json-2.4.js"></script>
-    <script type="text/javascript" src="//mkws.indexdata.com/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="//mkws.indexdata.com/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="//mkws.indexdata.com/pazpar2/js/pz2.js"></script>
     <script type="text/javascript" src="//mkws.indexdata.com/mkws.js"></script>
     <style type="text/css">
index 9aac803..a8edd79 100644 (file)
@@ -6,7 +6,7 @@
       var mkws_config = {\r
             //responsive_design_width: 990\r
             //perpage_default: 10,\r
-            service_proxy_auth: "//mkws.indexdata.com/service-proxy/?command=auth&action=login&username=dic&password=dic"\r
+            service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=dic&password=dic"\r
         };\r
     </script>\r
     <link rel="stylesheet" type="text/css" href="//mkws.indexdata.com/mkws.css" />\r
index 10a2a82..501f02f 100644 (file)
@@ -14,7 +14,7 @@
     </script>
     <script type="text/javascript" src="tools/htdocs/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
-    <script type="text/javascript" src="tools/htdocs/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
     <script type="text/javascript" src="tools/htdocs/mkws.js"></script>
 
index 5cebd8f..6fff595 100644 (file)
@@ -17,7 +17,7 @@
     </script>
     <script type="text/javascript" src="tools/htdocs/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
-    <script type="text/javascript" src="tools/htdocs/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <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">
index 8f97ab5..3538d20 100644 (file)
@@ -1,15 +1,15 @@
 <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" />
+    <title>MKWS demo: heading changes when search results appear</title>
     <script type="text/javascript">
-      var mkws_config = { service_proxy_auth: "//mkws.indexdata.com/service-proxy-credoauth" };
+      var mkws_config = { sp_auth_credentials: "credo/emu" };
     </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>
+    <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.3.0.js"></script>
+    <script type="text/javascript" src="tools/htdocs/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>
@@ -23,7 +23,7 @@
     <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" src="mkws-widget-credo.js"></script>
+    <script type="text/javascript" src="src/mkws-templates.js"></script>
   </head>
   <body>
     <script type="text/javascript">
index a910bee..eb0691d 100644 (file)
@@ -49,7 +49,7 @@
 
     <script type="text/javascript">
     var mkws_config = {
-      service_proxy_auth: "//mkws.indexdata.com/service-proxy-testauth",
+      service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=mkwstest&password=mkwstest",
       perpage_default: 10
     };
 
index d5758b3..386e830 100644 (file)
@@ -10,7 +10,7 @@
     <script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
     <script type="text/javascript" src="tools/htdocs/pz2.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>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
 
     <script type="text/javascript" src="src/mkws-handlebars.js"></script>
     <script type="text/javascript" src="src/mkws-core.js"></script>
@@ -24,6 +24,7 @@
     <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-templates.js"></script>
     <script type="text/javascript" src="src/mkws-widget-reference.js"></script>
     <script type="text/javascript" src="src/mkws-widget-builder.js"></script>
 
index b2c7450..80c50bb 100644 (file)
@@ -10,7 +10,7 @@
     <script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
     <script type="text/javascript" src="tools/htdocs/pz2.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>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
 
     <script type="text/javascript" src="src/mkws-handlebars.js"></script>
     <script type="text/javascript" src="src/mkws-core.js"></script>
@@ -18,6 +18,7 @@
     <script type="text/javascript" src="src/mkws-filter.js"></script>
     <script type="text/javascript" src="src/mkws-popup.js"></script>
     <script type="text/javascript" src="src/mkws-widget.js"></script>
+    <script type="text/javascript" src="src/mkws-templates.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>
@@ -52,8 +53,7 @@
     // use a our main service proxy with mkws test account
     var mkws_config = {
       perpage_default: 10,
-      pazpar2_url:          "//mkws.indexdata.com/service-proxy/",
-      service_proxy_auth:   "//mkws.indexdata.com/service-proxy-testauth"
+      sp_auth_credentials: "mkwstest/mkwstest"
     };
 
     var jasmine_config = {
index 3fea281..94a8df5 100644 (file)
@@ -16,7 +16,7 @@
     </script>
     <script type="text/javascript" src="//code.jquery.com/jquery-1.7.2.min.js"></script>
     <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
-    <script type="text/javascript" src="tools/htdocs/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
     <script type="text/javascript" src="tools/htdocs/mkws.js"></script>
 
index afbe943..a761fa8 100644 (file)
@@ -5,14 +5,14 @@
     <link rel="stylesheet" type="text/css" href="tools/htdocs/mkws.css" />
     <script type="text/javascript">
       var mkws_config = {
-         pazpar2_url : "//mkws.indexdata.com/service-proxy/",
-         service_proxy_auth: "//mkws.indexdata.com/service-proxy-testauth",
+         pazpar2_url : "//sp-mkws.indexdata.com/service-proxy/",
+         service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=mkwstest&password=mkwstest",
          perpage_default: 10
       };
     </script>
     <script type="text/javascript" src="//code.jquery.com/jquery-1.7.2.min.js"></script> 
     <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
-    <script type="text/javascript" src="tools/htdocs/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <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">
index 3c5f5b0..aaf3ce6 100644 (file)
@@ -8,7 +8,7 @@
     <link rel="stylesheet" type="text/css" href="http://x.mkws.indexdata.com/mkws.css" />
     <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="http://x.mkws.indexdata.com/jquery.json-2.4.js"></script>
-    <script type="text/javascript" src="http://x.mkws.indexdata.com/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="http://x.mkws.indexdata.com/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="http://x.mkws.indexdata.com/pazpar2/js/pz2.js"></script>
     <script type="text/javascript" src="http://x.mkws.indexdata.com/mkws.js"></script>
     <style type="text/css">
index cb496db..7a05d66 100644 (file)
@@ -7,7 +7,7 @@
     <link rel="stylesheet" type="text/css" href="http://x.mkws.indexdata.com/mkws.css" />
     <script type="text/javascript" src="http://code.jquery.com/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="http://x.mkws.indexdata.com/jquery.json-2.4.js"></script>
-    <script type="text/javascript" src="http://x.mkws.indexdata.com/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="http://x.mkws.indexdata.com/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="http://x.mkws.indexdata.com/pazpar2/js/pz2.js"></script>
     <script type="text/javascript" src="http://x.mkws.indexdata.com/mkws.js"></script>
     <style type="text/css">
index 90caf92..c15c234 100644 (file)
@@ -2,18 +2,15 @@
   <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 = {
-       pazpar2_url:        "//sp-mkws.indexdata.com/service-proxy/",
-        // For now, we have to provide known-bad credentials to skip user/pw login: see bug MKSP-125
-       service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy/?command=auth&action=perconfig&username=XXX&password=XXX"
-        // For explicit credential-based authentication, add: &username=orex&password=orexmkc
+//        pp2_hostname: "x.sp-mkws.indexdata.com",
       };
     </script>
-    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.0.min.js"></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>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
     <script type="text/javascript" src="src/mkws-handlebars.js"></script>
     <script type="text/javascript" src="src/mkws-core.js"></script>
@@ -28,7 +25,7 @@
     <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" src="mkws-widget-credo.js"></script>
+    <script type="text/javascript" src="src/mkws-templates.js"></script>
   </head>
   <body>
     <div class="mkwsAuthname"></div>
index 188cbc2..b0e71da 100644 (file)
@@ -1,16 +1,16 @@
 <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="tools/htdocs/mkws.css" />
+    <title>MKWS demo</title>
     <script type="text/javascript">
       var mkws_config = {
-        service_proxy_auth: "//mkws.indexdata.com/service-proxy/?command=auth&action=check,login&username=mkwstest&password=mkwstest"
+//        pp2_hostname: "x.sp-mkws.indexdata.com",
       };
     </script>
-    <script type="text/javascript" src="//code.jquery.com/jquery-1.10.0.min.js"></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>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="tools/htdocs/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="mkws-widget-credo.js"></script>
   </head>
   <body>
-    <div class="mkwsSwitch"></div>
-    <div class="mkwsLang"></div>
-    <div class="mkwsProgress"></div>
-    <div class="mkwsSearch"></div>
-    <div class="mkwsResults" autosearch="!param!q" targets="!param!t"></div>
-    <div class="mkwsTargets"></div>
-    <div class="mkwsStat"></div>
-    <div class="mkwsBuilder"></div>
+    <h1>SRU example: dinosaurs at LoC</h1>
+    <div class="mkwsSRU" autosearch="dinosaur" maximumRecords="3" recordSchema="dc">Stand by ...</div>
+    <-- Use:
+http://z3950.loc.gov:7090/voyager?version=1.1&operation=searchRetrieve&query=dinosaur&maximumRecords=3&recordSchema=dc
+     -->
   </body>
-  <script class="mkwsTemplate_facetTitle-Sources" type="text/x-handlebars-template">
-    <a href="?q={{query}}">Targets</a>
-  </script>
-  <script class="mkwsTemplate_facet-Sources" type="text/x-handlebars-template">
-    <a href="mike2.html?q={{query}}&t={{field}}">{{term}}</a>
-    <span>{{count}}</span>
-  </script>
 </html>
diff --git a/examples/htdocs/mkws-widget-credo-bs.js b/examples/htdocs/mkws-widget-credo-bs.js
deleted file mode 100644 (file)
index 49651ea..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-// 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) {
-  if (!obj) {
-    return "obj undefined";
-  } else if (!obj[0]) {
-    return "obj[0] undefined, JSON=" + $.toJSON(obj);
-  } else {
-    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
-// members of the same team, but picking out only the results relevant
-// to them. That will be more work.
-
-mkws.registerWidgetType('Credo', function() {
-  var that = this;
-
-  this.team.registerTemplate('CredoImage', '\
-      <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">\
-       <a href="{{mkws-googleurl md-electronic-url}}" target="_blank">\
-        {{#mkws-first md-thumburl}}\
-         <img src="{{this}}" alt="{{../md-title}}"/>\
-        {{/mkws-first}}\
-       <br/>\
-       </a>\
-       <p>{{{md-title}}}</p>\
-      </div>\
-');
-
-  var s = []
-  // Main panel: encylopaedia and images on the left, topics on the right
-  s.push('<div class="row">');
-
-  s.push('<div class="jumbotron panel col-md-8"><div class="panel-body">');
-  //s.push(section('encyclopaedia', 'Topic Page: <span class="x-mkws-title"/>',
-  s.push(this.subwidget('Reference', { _team: 'ref', paragraphs: 1 }));
-  // The Images widget needs to be in our team so we can set its template
-  s.push('</div></div>');
-
-  s.push('<div class="col-md-4">');
-  s.push(section('topics', 'Related Topics',
-                 this.subwidget('Facet', { _team: 'main', facet: 'subject' })));
-  s.push('</div>');
-
-  s.push('</div>');
-  
-  s.push('<div class="row">');
-  s.push(section('image col-md-12', 'Images', this.subwidget('GoogleImage', { maxrecs: 4, template: 'CredoImage', target: 'google_images_js' })));
-  s.push('</div>');
-  
-
-  s.push('<div class="row clearfix">');
-  s.push(section('entries clearfix col-md-4 col-sm-6', 'News',
-                 this.subwidget('Records', { _team: 'news', targetfilter: 'categories=news', perpage: 10 })));
-  s.push(section('articles clearfix col-md-4 col-sm-6', 'Articles',
-                    this.subwidget('Records', { _team: 'articles', targetfilter: 'categories=articles', perpage: 10 })));
-  s.push(section('books clearfix col-md-4 col-sm-6', 'Books',
-                    this.subwidget('Records', { _team: 'books', targetfilter: 'categories=books', perpage: 10 })));
-  s.push(section('news col-md-4 col-sm-6', 'Results from all targets',
-                    this.subwidget('Records', { _team: 'main' })));
-  s.push('</div>');
-  this.node.html(s.join(''));
-
-  // Fill in the titles from the query once widgets have all been prepared
-  var that = this;
-  this.team.queue("ready").subscribe(function() {
-    var query = toTitleCase(that.config.query);
-    that.log("got query '" + query + "' from team config");
-    mkws.$('.x-mkws-title').html(query);
-    mkws.$('title').html("MKWS: " + query);
-
-    mkws.$(".mkwsSummary img").addClass("media-object");
-    console.log(mkws.$("body").html());
-
-    // Derived from http://stackoverflow.com/questions/196972/convert-string-to-title-case-with-javascript
-    function toTitleCase(str) {
-      return str.replace(/\w\S*/g, function(txt) {
-        return txt.charAt(0).toUpperCase() + txt.substr(1);
-      });
-    }
-  });
-
-
-  function section(xclass, title, content) {
-    var s = [];
-    s.push('<div class="' + xclass + '"><div class="panel panel-default">');
-    s.push('<div class="panel-heading title"><h3 class="panel-title">' + title + '</h3></div>');
-    s.push('<div class="panel-body">' + content + '</div>');
-    s.push('</div></div>');
-    return s.join('');
-  }
-
-  function sectionRow(xclass, title, content) {
-    var s = [];
-    s.push('<div class="row">');
-    s.push(section(xclass, title, content));
-    s.push('</div>');
-    return s.join('');
-  }
-});
index 55b4488..2ba8a0d 100644 (file)
@@ -1,5 +1,5 @@
 var mkws_config = {
-   service_proxy_auth: "http://mkws.indexdata.com/service-proxy/?command=auth&action=login&username=paratext&password=paratext_mkc"
+   service_proxy_auth: "http://sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=paratext&password=paratext_mkc"
 };
 
 mkws.registerWidgetType('ReferenceUniverse', function() {
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 174fc37..4917d87 100644 (file)
@@ -9,7 +9,7 @@
 
     <script type="text/javascript">
       var mkws_config = {
-         service_proxy_auth: "//mkws.indexdata.com/service-proxy-credoauth"
+         service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy-credoauth"
       };
     </script>
 
@@ -17,7 +17,7 @@
     <script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
 
     <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
-    <script type="text/javascript" src="tools/htdocs/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
 
     <script type="text/javascript" src="src/mkws-handlebars.js"></script>
index 9a1a35e..939be60 100644 (file)
@@ -9,7 +9,7 @@
 
     <script type="text/javascript">
       var mkws_config = {
-         service_proxy_auth: "//mkws.indexdata.com/service-proxy-credoauth"
+         service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy-credoauth"
       };
     </script>
 
@@ -22,7 +22,7 @@
     <script type="text/javascript" src="//jquery-json.googlecode.com/files/jquery.json-2.4.js"></script>
     <script type="text/javascript" src="//code.jquery.com/ui/1.10.3/jquery-ui.min.js"></script>
     <script type="text/javascript" src="//git.indexdata.com/?p=pazpar2.git;a=blob_plain;f=js/pz2.js;hb=HEAD"></script>
-    <script type="text/javascript" src="//builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="//builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="//mkws.indexdata.com/mkws.js"></script>
    
     <script type="text/javascript" src="//example.indexdata.com/mkws-widget-credo.js"></script>
diff --git a/examples/htdocs/ref-bootstrap.html b/examples/htdocs/ref-bootstrap.html
deleted file mode 100644 (file)
index 503a8fe..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-  <head>
-    <meta charset="utf-8">
-    <meta http-equiv="X-UA-Compatible" content="IE=edge">
-    <meta name="viewport" content="width=device-width, initial-scale=1">
-    <title>MKWS demo: Compound reference widget</title>
-    <!-- <link rel="stylesheet" type="text/css" href="mkws&#45;widget&#45;credo.css" /> -->
-    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
-    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
-    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
-    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
-    <script type="text/javascript">
-      var mkws_config = { service_proxy_auth: "//mkws.indexdata.com/service-proxy-credoauth" };
-    </script>
-    <script class="mkwsTemplate_FacetBootstrap" type="text/x-handlebars-template">
-      <h3>Results from Reference Universe</h3>
-      {{#each hits}}
-        <div class="refinement">
-          {{#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}}
-        </div>
-      {{/each}}
-    </script>
-    <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
-    <script type="text/javascript" src="mkws-widget-credo-bs.js"></script>
-    <style>
-      .mkwsCredo {
-        max-width: 1440px;
-      }
-      .mkwsGoogleImage img {
-        max-width: 95%;
-      }
-    </style>
-  </head>
-  <body>
-    <div class='mkwsCredo page-header container-fluid' autosearch='!param!q'></div>
-  </body>
-</html>
index 9ba47a1..38b29bc 100644 (file)
@@ -4,7 +4,7 @@
     <title>MKWS demo: Compound reference 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-credoauth" };
+      var mkws_config = { sp_auth_credentials: "credo/emu" };
     </script>
     <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
     <script type="text/javascript" src="mkws-widget-credo.js"></script>
index b4cb8ca..861b657 100644 (file)
@@ -4,7 +4,7 @@
     <title>MKWS demo: Reference Universe widget</title>
     <link rel="stylesheet" type="text/css" href="mkws-widget-reference.css" />
     <script type="text/javascript">
-      var mkws_config = { service_proxy_auth: "//mkws.indexdata.com/service-proxy-testauth" };
+      var mkws_config = { service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy/?command=auth&action=login&username=mkwstest&password=mkwstest" };
     </script>
     <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
   </head>
index ef9c436..7b0cd71 100644 (file)
@@ -4,7 +4,7 @@
     <title>MKWS demo: Multiple autosearching widgets get their own teams</title>
     <link rel="stylesheet" type="text/css" href="mkws-widget-reference.css" />
     <script type="text/javascript">
-      var mkws_config = { service_proxy_auth: "//mkws.indexdata.com/service-proxy-testauth" };
+      var mkws_config = { service_proxy_auth: "//sp-mkws.indexdata.com/service-proxy-testauth" };
     </script>
     <!-- <script type="text/javascript" src="//mkws.local/mkws&#45;complete.js"></script> -->
     <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
diff --git a/examples/htdocs/topic-bootstrap.css b/examples/htdocs/topic-bootstrap.css
new file mode 100644 (file)
index 0000000..303942a
--- /dev/null
@@ -0,0 +1,102 @@
+body {
+  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 
+  background: radial-gradient(ellipse at center,  #ffffff 0%,#f8f8f8 100%);
+  font-weight: 300;
+}
+b, strong {
+  font-weight: 400; 
+}
+.panel {
+  border: none;
+  background: white;
+  padding: 1em .75em;
+  border-radius: 3px;
+  -moz-border-radius: 3px;
+  -webkit-border-radius: 3px;
+  color: #76868A;
+  box-shadow: 0 0 2px rgba(0, 0, 0, 0.09);
+  margin-bottom: 2em;
+}
+
+.panel-default > .panel-heading {
+  background-image: none; 
+  border: none;
+  background-color: white;
+}
+
+.panel-heading {
+  padding: 0.5em 15px 0;
+}
+
+.panel-title {
+  font-size: 130%;
+  color: #4A5456;
+}
+
+.panel-body {
+  padding: 10px 15px; 
+}
+
+.mkwsFacetTitle {
+  font-style: italic;
+  font-weight: 400;
+}
+  .mkwsTerm {
+    padding: .1em 0;
+  }
+  .mkwsTerm a {
+    padding-right: .5em; 
+    font-weight: 400;
+  }
+
+.mkwsSummary {
+  padding: .5em 0;
+  line-height: 1.35;
+}
+.mkwsSummary:last-child {
+  padding-bottom: 0;
+}
+  
+.container .jumbotron {
+  background: none;
+  padding: 0 2em 0 0;
+  box-shadow: none;
+  color: black;
+}  
+  .jumbotron .mkwsSummary {
+    line-height: 1.5;  
+  }
+  .jumbotron p{
+    font-size: 150%; 
+  }
+  .mkwsCredit {
+    font-size: 125% !important;
+    font-style: italic;
+  }
+  
+.mkwsGoogleImage .mkwsSummary {
+  padding: 0;
+  font-weight: 400;
+}
+  .mkwsGoogleImage img {
+    max-width: 100%;
+    max-height: 200px;
+    padding: 1em 0 .5em;
+  }
+.list-group-item {
+  padding: 10px 15px !important;
+}
+.list-group {
+  box-shadow: none;
+  -webkit-box-shadow: none;
+}
+@media screen and (min-width:700px) {
+  .multicol {
+    column-count: 2;
+    column-gap: 20px;
+    -moz-column-count: 2;
+    -moz-column-gap: 20px;
+    -webkit-column-count: 2;
+    -webkit-column-gap: 20px;
+  }
+}
diff --git a/examples/htdocs/topic-bootstrap.html b/examples/htdocs/topic-bootstrap.html
new file mode 100644 (file)
index 0000000..4c5085d
--- /dev/null
@@ -0,0 +1,127 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="utf-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <title>MKWS demo: Compound reference widget, Bootstrap edition</title>
+  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
+  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
+  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css">
+  <!-- http://www.bootstrapcdn.com/#bootswatch_tab has some themes that look mediumly okay -->
+  <!-- <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.1.1/cyborg/bootstrap.min.css" rel="stylesheet"> -->
+  <!-- <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.1.1/amelia/bootstrap.min.css" rel="stylesheet"> -->
+  <!-- <link href="//maxcdn.bootstrapcdn.com/bootswatch/3.1.1/united/bootstrap.min.css" rel="stylesheet"> -->
+  <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
+  <script type="text/javascript">
+    var mkws_config = { sp_auth_credentials: "credo/emu" };
+  </script>
+  <script type="text/javascript" src="//mkws.indexdata.com/mkws-complete.js"></script>
+  <!-- <script type="text/javascript" src="//mkws.local/mkws&#45;complete.js"></script> -->
+  <link rel="stylesheet" type="text/css" href="topic-bootstrap.css">
+  <script>
+    // 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) {
+      if (!obj) {
+        return "obj undefined";
+      } else if (!obj[0]) {
+        return "obj[0] undefined, JSON=" + $.toJSON(obj);
+      } else {
+        return mkws.getParameterByName('q', obj[0]);
+      }
+    });
+  </script>
+  <script class="mkwsTemplate_TopicImage" type="text/x-handlebars-template">
+    {{#each hits}}
+      <div class="col-lg-3 col-md-4 col-sm-6 col-xs-12">
+       <a href="{{mkws-googleurl md-electronic-url}}" target="_blank">
+        {{#mkws-first md-thumburl}}
+          <img src="{{this}}" alt="{{../md-title}}"/>
+        {{/mkws-first}}
+        <br/>
+       </a>
+       <p>{{{md-title}}}</p>
+      </div>
+    {{/each}}
+  </script>
+  <script class="mkwsTemplate_TopicFacet" type="text/x-handlebars-template">
+    {{#each terms}}
+      <li class="list-group-item mkwsTerm">
+        <span class="badge">{{count}}</span>
+        <a href="#" {{linkdata}}>{{term}}</a>
+      </li>
+    {{/each}}
+  </script>
+</head>
+<body>
+  <div class='page-header container' autosearch='!param!q'>
+    <div class="row">
+      <!-- reference entry -->
+      <div class="jumbotron panel col-md-8">
+        <div class="panel-body mkwsReference mkwsTeam_ref" autosearch="!param!q"
+             data-mkws-config='{"paragraphs":1}'></div>
+      </div>
+      <!-- related topics -->
+      <div class="col-md-offset-1 col-md-3"><div class="panel panel-default">
+        <div class="panel-heading title">
+          <h3 class="panel-title">Related Topics</h3>
+        </div>
+        <ul class="panel-body list-group mkwsFacet mkwsTeam_main"
+            autosearch="!param!q"
+            data-mkws-facet="subject"
+            data-mkws-config='{ "template": "TopicFacet" }'></ul>
+      </div></div>
+    </div>
+    <!-- images -->
+    <div class="row">
+      <div class="col-md-12"><div class="panel panel-default">
+        <div class="panel-heading title">
+          <h3 class="panel-title">Images</h3>
+        </div>
+        <div class="panel-body mkwsGoogleImage" autosearch="!param!q"
+             data-mkws-config='{ "maxrecs": 4, "template": "TopicImage", "target": "google_images_js" }'></div>
+      </div></div>
+    </div>
+
+    <!-- sources -->
+    <div class="row">
+        <div class="col-md-4 col-sm-6"><div class="panel panel-default">
+          <div class="panel-heading title">
+            <h3 class="panel-title">News</h3>
+          </div>
+          <div class="panel-body mkwsRecords mkwsTeam_news" autosearch="!param!q"
+               data-mkws-config='{"targetfilter":"categories=news",
+                                  "perpage":7}'></div>
+        </div></div>
+        <div class="col-md-4 col-sm-6"><div class="panel panel-default">
+          <div class="panel-heading title">
+            <h3 class="panel-title">Articles</h3>
+          </div>
+          <div class="panel-body mkwsRecords mkwsTeam_articles" autosearch="!param!q"
+               data-mkws-config='{"targetfilter":"categories=articles",
+                                  "perpage":7}'></div>
+        </div></div>
+        <div class="col-md-4 col-sm-6"><div class="panel panel-default">
+          <div class="panel-heading title">
+            <h3 class="panel-title">Books</h3>
+          </div>
+          <div class="panel-body mkwsRecords mkwsTeam_books" autosearch="!param!q"
+               data-mkws-config='{"targetfilter":"categories=books",
+                                  "perpage":7}'></div>
+        </div></div>
+    </div>
+    <div class="row">
+        <div class="col-md-12"><div class="panel panel-default">
+          <div class="panel-heading title">
+            <h3 class="panel-title">Results from all targets</h3>
+          </div>
+          <div class="panel-body multicol mkwsRecords mkwsTeam_main"></div>
+        </div></div>
+    </div>
+  </div>
+</body>
+</html>
index 006f11b..2cc98b0 100644 (file)
@@ -7,9 +7,9 @@
     <link rel="stylesheet" type="text/css" href="http://mkws.indexdata.com/mkws.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/jquery.json-2.4.js"></script>
-    <script type="text/javascript" src="http://mkws.indexdata.com/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="http://mkws.indexdata.com/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="http://mkws.indexdata.com/pazpar2/js/pz2.js"></script>
-    <script type="text/javascript" src="http://mkws.indexdata.com/mkws.js"></script>
+    <script type="text/javascript" src="http://mkws.local/src/mkws.js"></script>
   </head>
   <body>
     <table width="100%" border="1">
index f2653aa..5dbaad7 100644 (file)
@@ -18,7 +18,7 @@
     </script>
     <script type="text/javascript" src="tools/htdocs/jquery-1.10.0.min.js"></script>
     <script type="text/javascript" src="tools/htdocs/pz2.js"></script>
-    <script type="text/javascript" src="tools/htdocs/handlebars-v1.1.2.js"></script>
+    <script type="text/javascript" src="tools/htdocs/handlebars-v1.3.0.js"></script>
     <script type="text/javascript" src="tools/htdocs/jquery.json-2.4.js"></script>
    
     <!-- <script type="text/javascript" src="tools/htdocs/mkws.js"></script> -->
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644 (file)
index 0000000..f2fc3f4
--- /dev/null
@@ -0,0 +1 @@
+mkws-templates.js
index 3632a64..718c350 100644 (file)
 window.mkws = {
   $: $, // Our own local copy of the jQuery object
   authenticated: false,
+  authenticating: false,
   active: false,
   log_level: 1, // Will be overridden from mkws.config, but
                 // initial value allows jQuery popup to use logging.
   teams: {},
   widgetType2function: {},
+  defaultTemplates: {},
 
   locale_lang: {
     "de": {
@@ -166,8 +168,13 @@ mkws.setMkwsConfig = function(overrides) {
 
   var config_default = {
     use_service_proxy: true,
-    pazpar2_url:        "//mkws.indexdata.com/service-proxy/",
-    service_proxy_auth: "//mkws.indexdata.com/service-proxy-auth",
+    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],
@@ -182,6 +189,7 @@ mkws.setMkwsConfig = function(overrides) {
     facets: ["xtargets", "subject", "author"], /* display facets, in this order, [] for none */
     responsive_design_width: undefined, /* a page with less pixel width considered as narrow */
     log_level: 1,     /* log level for development: 0..2 */
+    template_vars: {}, /* values that may be exposed to templates */
 
     dummy: "dummy"
   };
@@ -205,110 +213,6 @@ mkws.objectInheritingFrom = function(o) {
 }
 
 
-mkws.defaultTemplate = function(name) {
-  if (name === 'Record') {
-    return '\
-<table>\
-  <tr>\
-    <th>{{mkws-translate "Title"}}</th>\
-    <td>\
-      {{md-title}}\
-      {{#if md-title-remainder}}\
-        ({{md-title-remainder}})\
-      {{/if}}\
-      {{#if md-title-responsibility}}\
-        <i>{{md-title-responsibility}}</i>\
-      {{/if}}\
-    </td>\
-  </tr>\
-  {{#if md-date}}\
-  <tr>\
-    <th>{{mkws-translate "Date"}}</th>\
-    <td>{{md-date}}</td>\
-  </tr>\
-  {{/if}}\
-  {{#if md-author}}\
-  <tr>\
-    <th>{{mkws-translate "Author"}}</th>\
-    <td>{{md-author}}</td>\
-  </tr>\
-  {{/if}}\
-  {{#if md-electronic-url}}\
-  <tr>\
-    <th>{{mkws-translate "Links"}}</th>\
-    <td>\
-      {{#each md-electronic-url}}\
-        <a href="{{this}}">Link{{mkws-index1}}</a>\
-      {{/each}}\
-    </td>\
-  </tr>\
-  {{/if}}\
-  {{#mkws-if-any location having="md-subject"}}\
-  <tr>\
-    <th>{{mkws-translate "Subject"}}</th>\
-    <td>\
-      {{#mkws-first location having="md-subject"}}\
-        {{#if md-subject}}\
-          {{#mkws-commaList md-subject}}\
-            {{this}}{{/mkws-commaList}}\
-        {{/if}}\
-      {{/mkws-first}}\
-    </td>\
-  </tr>\
-  {{/mkws-if-any}}\
-  <tr>\
-    <th>{{mkws-translate "Locations"}}</th>\
-    <td>\
-      {{#mkws-commaList location}}\
-        {{mkws-attr "@name"}}{{/mkws-commaList}}\
-    </td>\
-  </tr>\
-</table>\
-';
-  } else if (name === "Summary") {
-    return '\
-<a href="#" id="{{_id}}" onclick="{{_onclick}}">\
-  <b>{{md-title}}</b>\
-</a>\
-{{#if md-title-remainder}}\
-  <span>{{md-title-remainder}}</span>\
-{{/if}}\
-{{#if md-title-responsibility}}\
-  <span><i>{{md-title-responsibility}}</i></span>\
-{{/if}}\
-{{#if md-date}}, {{md-date}}\
-{{#if location}}\
-, {{#mkws-first location}}{{mkws-attr "@name"}}{{/mkws-first}}\
-{{/if}}\
-{{#if md-medium}}\
-<span>, {{md-medium}}</span>\
-{{/if}}\
-{{/if}}\
-';
-  } else if (name === "Image") {
-    return '\
-      <a href="#" id="{{_id}}" onclick="{{_onclick}}">\
-        {{#mkws-first md-thumburl}}\
-          <img src="{{this}}" alt="{{../md-title}}"/>\
-        {{/mkws-first}}\
-        <br/>\
-      </a>\
-';
-  } else if (name === 'Facet') {
-    return '\
-<a href="#"\
-{{#if fn}}\
-onclick="mkws.{{fn}}(\'{{team}}\', \'{{field}}\', \'{{term}}\');return false;"\
-{{/if}}\
->{{term}}</a>\
-<span>{{count}}</span>\
-';
-  }
-
-  return null;
-};
-
-
 // The following functions are dispatchers for team methods that
 // are called from the UI using a team-name rather than implicit
 // context.
@@ -353,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;
@@ -445,6 +361,7 @@ mkws.pagerNext = function(tname) {
    * for the site.
    */
   function authenticateSession(auth_url, auth_domain, pp2_url) {
+    mkws.authenticating = true;
     log("service proxy authentication on URL: " + auth_url);
 
     if (!auth_domain) {
@@ -458,6 +375,7 @@ mkws.pagerNext = function(tname) {
     }, auth_domain);
 
     request.get(null, function(data) {
+      mkws.authenticating = false;
       if (!$.isXMLDoc(data)) {
         alert("Service Proxy authentication response is not a valid XML document");
         return;
@@ -547,14 +465,23 @@ mkws.pagerNext = function(tname) {
   }
 
 
-  // This function should have no side effects if run again on an operating session, even if 
-  // the element/selector passed causes existing widgets to be reparsed: 
+  // The second "rootsel" parameter is passed to jQuery and is a DOM node
+  // or a selector string you would like to constrain the search for widgets to.
+  //
+  // This function has no side effects if run again on an operating session,
+  // even if the element/selector passed causes existing widgets to be reparsed: 
+  //
+  // (TODO: that last bit isn't true and we currently have to avoid reinitialising
+  // widgets, MKWS-261)
   //
   // * configuration is not regenerated
   // * authentication is not performed again
   // * autosearches are not re-run
   mkws.init = function(message, rootsel) {
-    if (message) mkws.log(message);
+    var greet = "MKWS initialised";
+    if (rootsel) greet += " (limited to " + rootsel + ")"
+    if (message) greet += " :: " + message; 
+    mkws.log(greet);
 
     // TODO: Let's remove this soon
     // Backwards compatibility: set new magic class names on any
@@ -618,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) {
@@ -635,7 +562,9 @@ mkws.pagerNext = function(tname) {
     var then = $.now();
     // If we've made no widgets, return without starting an SP session
     // or marking MKWS active.
-    if (makeWidgetsWithin(1, rootsel) === false) return false;
+    if (makeWidgetsWithin(1, rootsel ? $(rootsel) : undefined) === false) {
+      return false;
+    }
     var now = $.now();
 
     log("walking MKWS nodes took " + (now-then) + " ms");
@@ -650,14 +579,34 @@ mkws.pagerNext = function(tname) {
       }
     */
 
-    if (mkws.config.use_service_proxy) {
-      if (!mkws.authenticated) {
-        authenticateSession(mkws.config.service_proxy_auth,
-                            mkws.config.service_proxy_auth_domain,
-                            mkws.config.pazpar2_url);
+    function sp_auth_url(config) {
+      if (config.service_proxy_auth) {
+       mkws.log("using pre-baked sp_auth_url '" + config.service_proxy_auth + "'");
+       return config.service_proxy_auth;
+      } else {
+       var s = '//';
+       s += config.auth_hostname ? config.auth_hostname : config.pp2_hostname;
+       s += '/' + config.sp_auth_path;
+        var q = config.sp_auth_query;
+        if (q) {
+          s += '?' + q;
+        }
+       var c = config.sp_auth_credentials;
+       if (c) {
+         s += ('&username=' + c.substr(0, c.indexOf('/')) +
+               '&password=' + c.substr(c.indexOf('/')+1));
+       }
+       mkws.log("generated sp_auth_url '" + s + "'");
+       return s;
       }
-    } else {
-      // raw pp2
+    }
+
+    if (mkws.config.use_service_proxy && !mkws.authenticated && !mkws.authenticating) {
+      authenticateSession(sp_auth_url(mkws.config),
+                          mkws.config.service_proxy_auth_domain,
+                          mkws.pazpar2_url());
+    } else if (!mkws.authenticating) {
+      // raw pp2 or we have a session already open
       runAutoSearches();
     }
     
@@ -666,7 +615,9 @@ mkws.pagerNext = function(tname) {
   };
 
   $(document).ready(function() {
-    mkws.init();
+    if (!window.mkws_noready && !mkws.authenticating && !mkws.active) {
+       mkws.init();
+    }
   });
 
 })(mkws.$);
index 866dc8a..bd9af8d 100644 (file)
@@ -96,3 +96,11 @@ Handlebars.registerHelper('mkws-commaList', function(items, options) {
 Handlebars.registerHelper('mkws-index1', function(obj) {
   return obj.data.index + 1;
 });
+
+Handlebars.registerHelper('mkws-repeat', function(count, options) {
+  var out = "";
+  for (var i = 0; i < count; i++) {
+    out += options.fn(this);
+  }
+  return out;
+});
index 9abed73..92536f1 100644 (file)
@@ -41,11 +41,13 @@ function team($, teamName) {
   that.submitted = function() { return m_submitted; };
   that.sortOrder = function() { return m_sortOrder; };
   that.perpage = function() { return m_perpage; };
+  that.query = function() { return m_query; };
   that.totalRecordCount = function() { return m_totalRecordCount; };
   that.currentPage = function() { return m_currentPage; };
   that.currentRecordId = function() { return m_currentRecordId; };
   that.currentRecordData = function() { return m_currentRecordData; };
   that.filters = function() { return m_filterSet; };
+  that.gotRecords = function() { return m_gotRecords; };
 
   // Accessor methods for individual widgets: writers
   that.set_sortOrder = function(val) { m_sortOrder = val };
@@ -94,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,
@@ -149,6 +151,7 @@ function team($, teamName) {
     log("record");
     // FIXME: record is async!!
     clearTimeout(m_paz.recordTimer);
+    queue("record").publish(data);
     var detRecordDiv = findnode(recordDetailsId(data.recid[0]));
     if (detRecordDiv.length) {
       // in case on_show was faster to redraw element
@@ -303,6 +306,12 @@ function team($, teamName) {
     m_paz.search(m_query, m_perpage, m_sortOrder, pp2filter, undefined, params);
   }
 
+  // fetch record details to be retrieved from the record queue
+  that.fetchDetails = function(recId) {
+    log("fetchDetails() requesting record '" + recId + "'");
+    m_paz.record(recId);
+  };
+
 
   // switching view between targets and records
   function switchView(view) {
@@ -389,38 +398,34 @@ function team($, teamName) {
 
   function loadTemplate(name, fallbackString) {
     var template = m_template[name];
-
-    if (template === undefined) {
-      // Fall back to generic template if there is no team-specific one
+    if (template === undefined && Handlebars.compile) {
       var source;
       var node = $(".mkwsTemplate_" + name + " .mkwsTeam_" + that.name());
       if (node && node.length < 1) {
         node = $(".mkwsTemplate_" + name);
       }
-      if (node) {
-        source = node.html();
-      }
-
-      // If the template is not defined in HTML, check the following
-      // in order: template registered in the team by a widget;
-      // fallback string provided on this invocation; global default.
-      if (!source) {
-        source = m_templateText[name];
-      }
-      if (!source) {
-        source = fallbackString;
+      if (node) source = node.html();
+      if (!source) source = m_templateText[name];
+      if (source) {
+        template = Handlebars.compile(source);
+        log("compiled template '" + name + "'");
       }
-      if (!source) {
-        source = mkws.defaultTemplate(name);
-      }
-
-      if (!source) return null;
-      template = Handlebars.compile(source);
-      log("compiled template '" + name + "'");
+    }
+    //if (template === undefined) template = mkws_templatesbyteam[m_teamName][name];
+    if (template === undefined && Handlebars.templates) {
+      template = Handlebars.templates[name];
+    }
+    if (template === undefined && mkws.defaultTemplates) {
+      template = mkws.defaultTemplates[name];
+    }
+    if (template) {
       m_template[name] = template;
+      return template;
     }
-
-    return template;
+    else {
+      mkws.log("No MKWS template for " + name);
+      return null;
+    }  
   }
   that.loadTemplate = loadTemplate;
 
index 60ee37b..6468e86 100644 (file)
@@ -2,12 +2,12 @@ mkws.registerWidgetType('Builder', function() {
   var that = this;
   var team = this.team;
 
-  this.button = mkws.$('<button/>', {
+  var button = mkws.$('<button/>', {
     type: 'button',
     text: this.config.text || "Build!"
   });
-  this.node.append(this.button);
-  this.button.click(function() {
+  this.node.append(button);
+  button.click(function() {
     var   query = team.widget('Query').value();
     var    sort = team.widget('Sort').value();
     var perpage = team.widget('Perpage').value();
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 fcffe5b..6731b1d 100644 (file)
@@ -1,3 +1,5 @@
+(function($) { // jQuery wrapper
+
 // Functions follow for promoting the regular widget object into
 // widgets of specific types. These could be moved into their own
 // source files.
@@ -6,43 +8,36 @@
 mkws.registerWidgetType('Targets', function() {
   if (!this.config.show_switch) return;
   var that = this;
-  var M = mkws.M;
 
   this.node.html('No information available yet.');
   this.node.css("display", "none");
 
   this.team.queue("targets").subscribe(function(data) {
-    var table ='<table><thead><tr>' +
-      '<td>' + M('Target ID') + '</td>' +
-      '<td>' + M('Hits') + '</td>' +
-      '<td>' + M('Diags') + '</td>' +
-      '<td>' + M('Records') + '</td>' +
-      '<td>' + M('State') + '</td>' +
-      '</tr></thead><tbody>';
-
+    // There is a bug in pz2.js wherein it makes each data object an array but
+    // simply assigns properties to it.
+    // TODO: remove this when PAZ-946 is addressed.
+    var cleandata = [];
     for (var i = 0; i < data.length; i++) {
-      table += "<tr><td>" + data[i].id +
-        "</td><td>" + data[i].hits +
-        "</td><td>" + data[i].diagnostic +
-        "</td><td>" + data[i].records +
-        "</td><td>" + data[i].state + "</td></tr>";
+      var cur = {};
+      cur.id = data[i].id;
+      cur.hits = data[i].hits;
+      cur.diagnostic = data[i].diagnostic;
+      cur.records = data[i].records;
+      cur.state = data[i].state;
+      cleandata.push(cur);
     }
 
-    table += '</tbody></table>';
-    that.node.html(table);
+    var template = that.team.loadTemplate(that.config.template || "Targets");
+    that.node.html(template({data: cleandata}));
   });
 });
 
 
 mkws.registerWidgetType('Stat', function() {
   var that = this;
-  var M = mkws.M;
-
   this.team.queue("stat").subscribe(function(data) {
-    that.node.html(' -- ' +
-                      '<span class="mkwsClientCount">' + M('Active clients') + ': ' + data.activeclients + '/' + data.clients + '</span>' +
-                      ' -- ' +
-                      M('Retrieved records') + ': ' + data.records + '/' + data.hits);
+    var template = that.team.loadTemplate(that.config.template || "Stat");
+    that.node.html(template(data));
   });
 });
 
@@ -52,92 +47,92 @@ mkws.registerWidgetType('Pager', function() {
   var M = mkws.M;
 
   this.team.queue("pager").subscribe(function(data) {
-    that.node.html(drawPager(data))
-
-    function drawPager(data) {
-      var teamName = that.team.name();
-      var s = '<div style="float: right">' + M('Displaying') + ': '
-        + (data.start + 1) + ' ' + M('to') + ' ' + (data.start + data.num) +
-        ' ' + M('of') + ' ' + data.merged + ' (' + M('found') + ': '
-        + data.total + ')</div>';
-
-      //client indexes pages from 1 but pz2 from 0
-      var onsides = 6;
-      var pages = Math.ceil(that.team.totalRecordCount() / that.team.perpage());
-      var currentPage = that.team.currentPage();
-
-      var firstClkbl = (currentPage - onsides > 0)
-        ? currentPage - onsides
-        : 1;
-
-      var lastClkbl = firstClkbl + 2*onsides < pages
-        ? firstClkbl + 2*onsides
-        : pages;
-
-      var prev = '<span class="mkwsPrev">&#60;&#60; ' + M('Prev') + '</span> | ';
-      if (currentPage > 1)
-        prev = '<a href="#" class="mkwsPrev" onclick="mkws.pagerPrev(\'' + teamName + '\');">'
-        +'&#60;&#60; ' + M('Prev') + '</a> | ';
-
-      var middle = '';
-      for(var i = firstClkbl; i <= lastClkbl; i++) {
-        var numLabel = i;
-        if(i == currentPage)
-          numLabel = '<span class="mkwsCurrentPage">' + i + '</span>';
-
-        middle += '<a href="#" onclick="mkws.showPage(\'' + teamName + '\', ' + i + ')"> '
-          + numLabel + ' </a>';
+    var teamName = that.team.name();
+    var output = {};
+    output.first = data.start + 1;
+    output.last = data.start + data.num;
+    output.count = data.merged;
+    output.found = data.total;
+
+    //client indexes pages from 1 but pz2 from 0
+    var onsides = 6;
+    var pages = Math.ceil(that.team.totalRecordCount() / that.team.perpage());
+    var currentPage = that.team.currentPage();
+
+    var firstClkbl = (currentPage - onsides > 0)
+      ? currentPage - onsides
+      : 1;
+    var lastClkbl = firstClkbl + 2*onsides < pages
+      ? firstClkbl + 2*onsides
+      : pages;
+
+    if (firstClkbl > 1) output.morePrev = true;
+    if (lastClkbl < pages) output.moreNext = true;
+
+    if (currentPage > 1) output.prevClick = "mkws.pagerPrev(\'" + teamName + "\');";
+
+    output.pages = [];
+    for(var i = firstClkbl; i <= lastClkbl; i++) {
+      var o = {};
+      o.number = i;
+      if (i !== currentPage) {
+        o.click = "mkws.showPage(\'" + teamName + "\', " + i + ");";
       }
+      output.pages.push(o);
+    }
 
-      var next = ' | <span class="mkwsNext">' + M('Next') + ' &#62;&#62;</span>';
-      if (pages - currentPage > 0)
-        next = ' | <a href="#" class="mkwsNext" onclick="mkws.pagerNext(\'' + teamName + '\')">'
-        + M('Next') + ' &#62;&#62;</a>';
-
-      var predots = '';
-      if (firstClkbl > 1)
-        predots = '...';
-
-      var postdots = '';
-      if (lastClkbl < pages)
-        postdots = '...';
+    if (pages - currentPage > 0) output.nextClick = "mkws.pagerNext(\'" + teamName + "\')";
 
-      s += '<div style="float: clear">'
-        + prev + predots + middle + postdots + next + '</div>';
+    var template = that.team.loadTemplate(that.config.template || "Pager");
+    that.node.html(template(output));
+  });
+});
 
-      return s;
+mkws.registerWidgetType('Details', function() {
+  var that = this;
+  var recid = that.node.attr("data-mkws-recid");
+  if (this.team.gotRecords()) { 
+    that.team.fetchDetails(recid);
+  } else {
+    this.team.queue("firstrecords").subscribe(function() {
+      that.team.fetchDetails(recid);
+    });
+  }
+  this.team.queue("record").subscribe(function(data) {
+    console.log(data);
+    if ($.inArray(recid, data.recid) > -1) {
+      var template = that.team.loadTemplate(that.config.template || "Record");
+      that.node.html(template(data));
     }
   });
+  that.autosearch();
 });
 
-
 mkws.registerWidgetType('Records', function() {
   var that = this;
   var team = this.team;
 
   this.team.queue("records").subscribe(function(data) {
-    var html = [];
     for (var i = 0; i < data.hits.length; i++) {
       var hit = data.hits[i];
       that.team.queue("record").publish(hit);
-      var divId = team.recordElementId(hit.recid[0]);
-      html.push('<div class="mkwsSummary mkwsTeam_' + team.name() + ' ' + divId + '">', renderSummary(hit), '</div>');
+      hit.detailLinkId = team.recordElementId(hit.recid[0]);
+      hit.detailClick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;";
+      hit.containerClass = "mkwsSummary mkwsTeam_" + team.name();
+      hit.containerClass += " " + hit.detailLinkId;
       // ### At some point, we may be able to move the
       // m_currentRecordId and m_currentRecordData members
       // from the team object into this widget.
       if (hit.recid == team.currentRecordId()) {
-        if (team.currentRecordData())
-          html.push(team.renderDetails(team.currentRecordData()));
+        if (team.currentRecordData()) {
+          hit.renderedDetails = team.renderDetails(team.currentRecordData());
+          console.log(hit.renderedDetails); 
+        } 
       }
     }
-    that.node.html(html.join(''));
-
-    function renderSummary(hit) {
-      var template = team.loadTemplate(that.config.template || "Summary");
-      hit._id = team.recordElementId(hit.recid[0]);
-      hit._onclick = "mkws.showDetails('" + team.name() + "', '" + hit.recid[0] + "');return false;"
-      return template(hit);
-    }
+    var template = team.loadTemplate(that.config.template || "Records");
+    var targs = $.extend({}, {"hits": data.hits}, that.config.template_vars);
+    that.node.html(template(targs));
   });
 
   that.autosearch();
@@ -147,26 +142,29 @@ mkws.registerWidgetType('Records', function() {
 mkws.registerWidgetType('Navi', function() {
   var that = this;
   var teamName = this.team.name();
-  var M = mkws.M;
 
   this.team.queue("navi").subscribe(function() {
     var filters = that.team.filters();
-    var text = "";
+    var output = {filters:[]};
 
     filters.visitTargets(function(id, name) {
-      if (text) text += " | ";
-      text += M('source') + ': <a class="mkwsRemovable" href="#" onclick="mkws.delimitTarget(\'' + teamName +
-        "', '" + id + "'" + ');return false;">' + name + '</a>';
+      var cur = {};
+      cur.facet = 'source';
+      cur.value = name;
+      cur.click = "mkws.delimitTarget('" + teamName + "', '" + id + "'); return false;";
+      output.filters.push(cur);
     });
 
     filters.visitFields(function(field, value) {
-      if (text) text += " | ";
-      text += M(field) + ': <a class="mkwsRemovable" href="#" onclick="mkws.delimitQuery(\'' + teamName +
-        "', '" + field + "', '" + value + "'" +
-        ');return false;">' + value + '</a>';
+      var cur = {};
+      cur.facet = field;
+      cur.value = value;
+      cur.click = "mkws.delimitQuery('" + teamName + "', '" + field + "', '" + value + "'" + ");return false;";
+      output.filters.push(cur);
     });
 
-    that.node.html(text);
+    var template = that.team.loadTemplate(that.config.template || "Navi");
+    that.node.html(template(output));
   });
 });
 
@@ -202,9 +200,9 @@ mkws.registerWidgetType('Perpage', function() {
 
 mkws.registerWidgetType('Done', function() {
   var that = this;
-
   this.team.queue("complete").subscribe(function(n) {
-    that.node.html("Search complete: found " + n + " records");
+    var template = that.team.loadTemplate(that.config.template || "Done");
+    that.node.html(template({count: n}));
   });
 });
 
@@ -212,23 +210,21 @@ mkws.registerWidgetType('Done', function() {
 mkws.registerWidgetType('Switch', function() {
   if (!this.config.show_switch) return;
   var tname = this.team.name();
-  this.node.html('\
-<a href="#" onclick="mkws.switchView(\'' + tname + '\', \'records\')">Records</a><span> \
-| \
-</span><a href="#" onclick="mkws.switchView(\'' + tname + '\', \'targets\')">Targets</a>');
+  var output = {};
+  output.recordClick = "mkws.switchView(\'" + tname + "\', \'records\')";
+  output.targetClick = "mkws.switchView(\'" + tname + "\', \'targets\')";
+  var template = this.team.loadTemplate(this.config.template || "Switch");
+  this.node.html(template(output));
   this.hideWhenNarrow();
 });
 
 
 mkws.registerWidgetType('Search', function() {
-  var tname = this.team.name();
-  var M = mkws.M;
-
-  this.node.html('\
-<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_' + tname + '" action="" >\
-  <input class="mkwsQuery mkwsTeam_' + tname + '" type="text" size="' + this.config.query_width + '" />\
-  <input class="mkwsButton mkwsTeam_' + tname + '" type="submit" value="' + M('Search') + '" />\
-</form>');
+  var output = {};
+  output.team = this.team.name();
+  output.queryWidth = this.config.query_width;
+  var template = this.team.loadTemplate(this.config.template || "Search");
+  this.node.html(template(output));
 });
 
 
@@ -243,90 +239,42 @@ mkws.registerWidgetType('SearchForm', function() {
 
 
 mkws.registerWidgetType('Results', function() {
-  var tname = this.team.name();
-
-  this.node.html('\
-<table width="100%" border="0" cellpadding="6" cellspacing="0">\
-  <tr>\
-    <td class="mkwsTermlists-Container-wide mkwsTeam_' + tname + '" width="250" valign="top">\
-      <div class="mkwsTermlists mkwsTeam_' + tname + '"></div>\
-    </td>\
-    <td class="mkwsMOTDContainer mkwsTeam_' + tname + '" valign="top">\
-      <div class="mkwsRanking mkwsTeam_' + tname + '"></div>\
-      <div class="mkwsPager mkwsTeam_' + tname + '"></div>\
-      <div class="mkwsNavi mkwsTeam_' + tname + '"></div>\
-      <div class="mkwsRecords mkwsTeam_' + tname + '"></div>\
-    </td>\
-  </tr>\
-  <tr>\
-    <td colspan="2">\
-      <div class="mkwsTermlists-Container-narrow mkwsTeam_' + tname + '"></div>\
-    </td>\
-  </tr>\
-</table>');
-
+  var template = this.team.loadTemplate(this.config.template || "Results");
+  this.node.html(template({team: this.team.name()}));
   this.autosearch();
 });
 
 
 mkws.registerWidgetType('Ranking', function() {
-  var tname = this.team.name();
-  var that = this;
-  var M = mkws.M;
-
-  var s = '<form>';
-  if (this.config.show_sort) {
-    s +=  M('Sort by') + ' ' + mkwsHtmlSort() + ' ';
+  var output = {};
+  output.perPage = [];
+  output.sort = [];
+  output.team = this.team.name();
+  output.showSort = this.config.show_sort;
+  output.showPerPage = this.config.show_perpage;
+
+  var order = this.team.sortOrder();
+  this.log("making sort, sortOrder = '" + order + "'");
+  for (var i = 0; i < this.config.sort_options.length; i++) {
+    var cur = {};
+    var opt = this.config.sort_options[i];
+    cur.key = opt[0];
+    cur.label = opt.length == 1 ? opt[0] : opt[1];
+    if (order == cur.key || order == cur.label) cur.selected = true;
+    output.sort.push(cur);
   }
-  if (this.config.show_perpage) {
-    s += M('and show') + ' ' + mkwsHtmlPerpage() + ' ' + M('per page') + '.';
-  }
-  s += '</form>';
-
-  this.node.html(s);
-
-
-  function mkwsHtmlSort() {
-    var order = that.team.sortOrder();
-
-    that.log("making sort HTML, sortOrder = '" + order + "'");
-    var sort_html = '<select class="mkwsSort mkwsTeam_' + tname + '">';
 
-    for(var i = 0; i < that.config.sort_options.length; i++) {
-      var opt = that.config.sort_options[i];
-      var key = opt[0];
-      var val = opt.length == 1 ? opt[0] : opt[1];
-
-      sort_html += '<option value="' + key + '"';
-      if (order == key || order == val) {
-        sort_html += ' selected="selected"';
-      }
-      sort_html += '>' + M(val) + '</option>';
-    }
-    sort_html += '</select>';
-
-    return sort_html;
+  var perpage = this.team.perpage();
+  this.log("making perpage, perpage = " + perpage);
+  for(var i = 0; i < this.config.perpage_options.length; i++) {
+    var cur = {};
+    cur.perPage = this.config.perpage_options[i];
+    if (cur.perPage == perpage) cur.selected = true;
+    output.perPage.push(cur);
   }
 
-  function mkwsHtmlPerpage() {
-    var perpage = that.team.perpage();
-
-    that.log("making perpage HTML, perpage = " + perpage);
-    var perpage_html = '<select class="mkwsPerpage mkwsTeam_' + tname + '">';
-
-    for(var i = 0; i < that.config.perpage_options.length; i++) {
-      var key = that.config.perpage_options[i];
-
-      perpage_html += '<option value="' + key + '"';
-      if (key == perpage) {
-        perpage_html += ' selected="selected"';
-      }
-      perpage_html += '>' + key + '</option>';
-    }
-    perpage_html += '</select>';
-
-    return perpage_html;
-  }
+  var template = this.team.loadTemplate(this.config.template || "Ranking");
+  this.node.html(template(output));
 });
 
 
@@ -347,34 +295,30 @@ mkws.registerWidgetType('Lang', function() {
   }
 
   for (var k in mkws.locale_lang) {
-    if (toBeIncluded[k] || lang_options.length == 0)
-      list.push(k);
+    if (toBeIncluded[k] || lang_options.length == 0) {
+      cur = {};
+      if (lang === k) cur.selected = true;
+      cur.code = k;
+      cur.url = lang_url(k);
+      list.push(cur);
+    }
   }
 
   // add english link
-  if (lang_options.length == 0 || toBeIncluded[lang_default])
-    list.push(lang_default);
+  if (lang_options.length == 0 || toBeIncluded[lang_default]) {
+      cur = {};
+      if (lang === lang_default) cur.selected = true;
+      cur.code = lang_default;
+      cur.url = lang_url(lang_default);
+      list.push(cur);
+  }
 
   this.log("language menu: " + list.join(", "));
 
-  /* the HTML part */
-  var data = "";
-  for (var i = 0; i < list.length; i++) {
-    var l = list[i];
-    if (data)
-      data += ' | ';
-
-    if (lang == l) {
-      data += ' <span>' + l + '</span> ';
-    } else {
-      data += ' <a href="' + lang_url(l) + '">' + l + '</a> '
-    }
-  }
-
-  this.node.html(data);
+  var template = this.team.loadTemplate(this.config.template || "Lang");
+  this.node.html(template({languages: list}));
   this.hideWhenNarrow();
 
-
   // set or re-set "lang" URL parameter
   function lang_url(lang) {
     var query = location.search;
@@ -422,19 +366,13 @@ mkws.registerWidgetType('Config', function() {
 
 mkws.registerWidgetType('Progress', function() {
   var that = this;
-
   this.node.hide();
   this.team.queue("stat").subscribe(function(data) {
-    var s = '<span class="mkwsDone">';
-    for (var i = 0; i < data.clients; i++) {
-      if (i == data.clients - data.activeclients) {
-        s += '</span>';
-        s += '<span class="mkwsWaiting">';
-      }
-      s += '&#x2588;';
-    }
-    s += '</span>';
-    that.node.html(s);
+    var template = that.team.loadTemplate(that.config.template || "Progress");
+    that.node.html(template({
+      done: data.clients - data.activeclients,
+      waiting: data.activeclients
+    }));
     that.node.show();
   });
 });
@@ -450,3 +388,4 @@ mkws.registerWidgetType('MOTDContainer', function() {});
 mkws.registerWidgetType('Button', function() {});
 
 
+})(mkws.$); // jQuery wrapper
diff --git a/src/mkws-widget-main.templates/Done.handlebars b/src/mkws-widget-main.templates/Done.handlebars
new file mode 100644 (file)
index 0000000..59a0b4f
--- /dev/null
@@ -0,0 +1,7 @@
+{{!
+Displayed on search completion
+
+count - number of results found
+}}
+{{{mkws-translate "Search complete: found"}}} {{count}} {{{mkws-translate "records"}}}
+
diff --git a/src/mkws-widget-main.templates/Image.handlebars b/src/mkws-widget-main.templates/Image.handlebars
new file mode 100644 (file)
index 0000000..abee587
--- /dev/null
@@ -0,0 +1,18 @@
+{{!
+Records presented as images.
+
+hits:
+  containerClass - class  attribute for same
+  detailLinkId - id for the element triggering detail display
+  detailClick - a click event handler for details
+  renderedDetails - active record details rendered from the Record template
+  md-* - metadata fields passed through from backend
+}}
+{{#each hits}}
+  <a href="#" id="{{detailLinkId}}" onclick="{{detailClick}}">
+    {{#mkws-first md-thumburl}}
+      <img src="{{this}}" alt="{{../md-title}}"/>
+    {{/mkws-first}}
+    <br/>
+  </a>
+{{/each}}
diff --git a/src/mkws-widget-main.templates/Lang.handlebars b/src/mkws-widget-main.templates/Lang.handlebars
new file mode 100644 (file)
index 0000000..26ee6da
--- /dev/null
@@ -0,0 +1,19 @@
+{{!
+Language selection widget
+
+languages
+  code - two character language identifier
+  selected - exists for the current language
+  url - url to switch to this language
+}}
+{{#each languages}}
+  {{~#if selected~}}
+    <span>{{code}}</span>
+  {{~else~}}
+    <a href="{{{url}}}">{{code}}</a>
+  {{~/if~}}
+  {{#unless last}}
+    |
+  {{/unless}}
+{{/each}}
+
diff --git a/src/mkws-widget-main.templates/Navi.handlebars b/src/mkws-widget-main.templates/Navi.handlebars
new file mode 100644 (file)
index 0000000..7f3c554
--- /dev/null
@@ -0,0 +1,13 @@
+{{!
+Facet breadcrumbs -- filters on the current search
+
+filters
+  facet - name of facet being limited
+  value - limit to this value
+  click - handler script to remove limit
+}}
+{{#each filters}}
+  {{{mkws-translate facet}}}: <a class="mkwsRemovable" href="#" onclick="{{{click}}}">{{value}}</a>
+  {{#unless @last}}|{{/unless}}
+{{/each}}
+
diff --git a/src/mkws-widget-main.templates/Pager.handlebars b/src/mkws-widget-main.templates/Pager.handlebars
new file mode 100644 (file)
index 0000000..3f098e6
--- /dev/null
@@ -0,0 +1,46 @@
+{{!
+Pager
+
+nextClick - handler script for "next" button, only available if there is a next page
+prevClick - handler script for "previous" button if there is a previous page
+moreNext - indicates there are more pages following those displayed
+morePrev - indicates there are more pages preceding
+first - first record displayed
+last - last record displayed
+count - number of records available
+found - number of records found
+pages:
+  number - page number
+  click - script to go to this page unless it is the current one
+}}
+<div style="float: right">
+  {{mkws-translate "Displaying"}}:
+  {{first}} {{mkws-translate "to"}} {{last}}
+  {{mkws-translate "of"}} {{count}} ({{{mkws-translate "found"}}}: {{found}})
+</div>
+
+<div style="float: clear">
+  {{#if prevClick}}
+    <a href="#" class="mkwsPrev" onclick="{{prevClick}}">&#60;&#60; {{{mkws-translate "Prev"}}}</a> |
+  {{else}}
+    <span class="mkwsPrev">&#60;&#60; {{{mkws-translate "Prev"}}}</span> |
+  {{/if}}
+
+  {{#if morePrev}}...{{/if}}
+
+  {{#each pages}}
+    {{#if click}}
+      <a href="#" onclick="{{click}}">{{number}}</a>
+    {{else}}
+      <span class="mkwsCurrentPage">{{number}}</span>
+    {{/if}}
+  {{/each}}
+
+  {{#if moreNext}}...{{/if}}
+
+  {{#if nextClick}}
+    | <a href="#" class="mkwsNext" onclick="{{nextClick}}">{{{mkws-translate "Next"}}} &#62;&#62;</a>
+  {{else}}
+    | <span class="mkwsNext">{{{mkws-translate "Next"}}} &#62;&#62;</span>
+  {{/if}}
+</div>
diff --git a/src/mkws-widget-main.templates/Progress.handlebars b/src/mkws-widget-main.templates/Progress.handlebars
new file mode 100644 (file)
index 0000000..1b08a2c
--- /dev/null
@@ -0,0 +1,11 @@
+{{!
+Progress
+
+done - number of targets complete
+waiting - number of targets waiting
+}}
+<span class="mkwsDone">{{#mkws-repeat done}}&#x2588;{{/mkws-repeat}}</span>
+{{~#if waiting~}}
+<span class="mkwsWaiting">{{#mkws-repeat waiting}}&#x2588;{{/mkws-repeat}}</span>
+{{~/if~}}
+
diff --git a/src/mkws-widget-main.templates/Ranking.handlebars b/src/mkws-widget-main.templates/Ranking.handlebars
new file mode 100644 (file)
index 0000000..0f2bc17
--- /dev/null
@@ -0,0 +1,42 @@
+{{!
+Ranking -- widget to select sort ordering and number of records to display
+
+team - team for this widget
+showSort
+showPerPage
+sort
+  key - machine readable value for this sort option
+  label - text to display for this sort option
+  selected - exists if this sort is selected
+perPage
+  perPage - a number of records per page that can be selected
+  selected - exists if this number is the current selection
+}}
+<form>
+  {{~#if showSort~}}
+    {{{mkws-translate "Sort by"}}}
+    <select class="mkwsSort mkwsTeam_{{team}}">
+      {{#each sort}}
+        {{#if selected}}
+          <option value="{{{key}}}" selected="selected">{{{mkws-translate label}}}</option>
+        {{else}}
+          <option value="{{key}}">{{{mkws-translate label}}}</option>
+        {{/if}}
+      {{/each}}  
+    </select>
+  {{~/if~}}
+  {{~#if showPerPage~}}
+    {{{mkws-translate "and show"}}}
+    <select class="mkwsPerpage mkwsTeam_{{team}}">
+      {{#each perPage}}
+        {{#if selected}}
+          <option value="{{perPage}}" selected="selected">{{perPage}}</option>
+        {{else}}
+          <option value="{{perPage}}">{{perPage}}</option>
+        {{/if}}
+      {{/each}}  
+    </select>
+    {{{mkws-translate "per page."}}}
+  {{~/if~}}
+</form>
+
diff --git a/src/mkws-widget-main.templates/Record.handlebars b/src/mkws-widget-main.templates/Record.handlebars
new file mode 100644 (file)
index 0000000..f8bf951
--- /dev/null
@@ -0,0 +1,59 @@
+{{!
+Full record display.
+}}
+<table>
+  <tr>
+    <th>{{mkws-translate "Title"}}</th>
+    <td>
+      {{md-title}}
+      {{#if md-title-remainder}}
+        ({{md-title-remainder}})
+      {{/if}}
+      {{#if md-title-responsibility}}
+        <i>{{md-title-responsibility}}</i>
+      {{/if}}
+    </td>
+  </tr>
+  {{#if md-date}}
+  <tr>
+    <th>{{mkws-translate "Date"}}</th>
+    <td>{{md-date}}</td>
+  </tr>
+  {{/if}}
+  {{#if md-author}}
+  <tr>
+    <th>{{mkws-translate "Author"}}</th>
+    <td>{{md-author}}</td>
+  </tr>
+  {{/if}}
+  {{#if md-electronic-url}}
+  <tr>
+    <th>{{mkws-translate "Links"}}</th>
+    <td>
+      {{#each md-electronic-url}}
+        <a href="{{this}}">Link{{mkws-index1}}</a>
+      {{/each}}
+    </td>
+  </tr>
+  {{/if}}
+  {{#mkws-if-any location having="md-subject"}}
+  <tr>
+    <th>{{mkws-translate "Subject"}}</th>
+    <td>
+      {{#mkws-first location having="md-subject"}}
+        {{#if md-subject}}
+          {{#mkws-commaList md-subject}}
+            {{this}}{{/mkws-commaList}}
+        {{/if}}
+      {{/mkws-first}}
+    </td>
+  </tr>
+  {{/mkws-if-any}}
+  <tr>
+    <th>{{mkws-translate "Locations"}}</th>
+    <td>
+      {{#mkws-commaList location}}
+        {{mkws-attr "@name"}}{{/mkws-commaList}}
+    </td>
+  </tr>
+</table>
diff --git a/src/mkws-widget-main.templates/Records.handlebars b/src/mkws-widget-main.templates/Records.handlebars
new file mode 100644 (file)
index 0000000..03ba9a2
--- /dev/null
@@ -0,0 +1,26 @@
+{{!
+Records from a search.
+
+hits:
+  containerClass - class  attribute for same
+  detailLinkId - id for the element triggering detail display
+  detailClick - a click event handler for details
+  renderedDetails - active record details rendered from the Record template
+  md-* - metadata fields passed through from backend
+}}
+{{#each hits}}
+  <div class="{{containerClass}}">
+    <a href="#" id="{{detailLinkId}}" onclick="{{detailClick}}">
+      <b>{{md-title}}</b>
+    </a>
+    {{#if md-title-remainder}}
+      <span>{{md-title-remainder}}</span>
+    {{/if}}
+    {{#if md-title-responsibility}}
+      <span><i>{{md-title-responsibility}}</i></span>
+    {{/if}}
+    {{#if renderedDetails}}
+      {{{renderedDetails}}}
+    {{/if}}
+  </div>
+{{/each}}
diff --git a/src/mkws-widget-main.templates/Results.handlebars b/src/mkws-widget-main.templates/Results.handlebars
new file mode 100644 (file)
index 0000000..f0d405c
--- /dev/null
@@ -0,0 +1,24 @@
+{{!
+Results -- compound widget to display search results
+
+team - team for this widget
+}}
+<table width="100%" border="0" cellpadding="6" cellspacing="0">
+  <tr>
+    <td class="mkwsTermlists-Container-wide mkwsTeam_{{team}}" width="250" valign="top">
+      <div class="mkwsTermlists mkwsTeam_{{team}}"></div>
+    </td>
+    <td class="mkwsMOTDContainer mkwsTeam_{{team}}" valign="top">
+      <div class="mkwsRanking mkwsTeam_{{team}}"></div>
+      <div class="mkwsPager mkwsTeam_{{team}}"></div>
+      <div class="mkwsNavi mkwsTeam_{{team}}"></div>
+      <div class="mkwsRecords mkwsTeam_{{team}}"></div>
+    </td>
+  </tr>
+  <tr>
+    <td colspan="2">
+      <div class="mkwsTermlists-Container-narrow mkwsTeam_{{team}}"></div>
+    </td>
+  </tr>
+</table>
+
diff --git a/src/mkws-widget-main.templates/Search.handlebars b/src/mkws-widget-main.templates/Search.handlebars
new file mode 100644 (file)
index 0000000..5530013
--- /dev/null
@@ -0,0 +1,11 @@
+{{!
+Search form
+
+team - MKWS team
+queryWidth - configured width for search box
+}}
+<form name="mkwsSearchForm" class="mkwsSearchForm mkwsTeam_{{team}}" action="">
+  <input class="mkwsQuery mkwsTeam_{{team}}" type="text" size="{{queryWidth}}">
+  <input class="mkwsButton mkwsTeam_{{team}}" type="submit" value="{{{mkws-translate "Search"}}}">
+</form>
+
diff --git a/src/mkws-widget-main.templates/Stat.handlebars b/src/mkws-widget-main.templates/Stat.handlebars
new file mode 100644 (file)
index 0000000..d8ae997
--- /dev/null
@@ -0,0 +1,9 @@
+{{!
+Search statistics
+
+activeclients - number of targets currently searching
+clients - total targets for this search
+records - number of records returned and available
+hits - number of hits across all targets
+}}
+ -- <span class="mkwsClientCount">{{{mkws-translate "Active clients"}}} : {{activeclients}}/{{clients}}</span> -- {{{mkws-translate "Retrieved records"}}} : {{records}}/{{hits}}
diff --git a/src/mkws-widget-main.templates/Switch.handlebars b/src/mkws-widget-main.templates/Switch.handlebars
new file mode 100644 (file)
index 0000000..2b8e29c
--- /dev/null
@@ -0,0 +1,9 @@
+{{!
+Switch between record and target view
+
+recordClick - handler to switch to record view
+targetClick - handler to switch to target view
+}}
+<a href="#" onclick="{{{recordClick}}}">{{{mkws-translate "Records"}}}</a>
+<span>|</span>
+<a href="#" onclick="{{{targetClick}}}">{{{mkws-translate "Targets"}}}</a>
diff --git a/src/mkws-widget-main.templates/Targets.handlebars b/src/mkws-widget-main.templates/Targets.handlebars
new file mode 100644 (file)
index 0000000..99ed801
--- /dev/null
@@ -0,0 +1,33 @@
+{{!
+Target detail
+
+data:
+  id - target id
+  hits - number of hits for this target
+  diagnostic - 
+  records - 
+  state - target state
+}}
+<table>
+  <thead>
+    <tr>
+      <td>{{{mkws-translate "Target ID"}}}</td>
+      <td>{{{mkws-translate "Hits"}}}</td>
+      <td>{{{mkws-translate "Diags"}}}</td>
+      <td>{{{mkws-translate "Records"}}}</td>
+      <td>{{{mkws-translate "State"}}}</td>
+      </td>
+    </tr>
+  </thead>
+  <tbody>
+  {{#each data}}
+    <tr>
+      <td>{{{id}}}</td>
+      <td>{{hits}}</td>
+      <td>{{diagnostic}}</td>
+      <td>{{records}}</td>
+      <td>{{hits}}</td>
+    </tr>
+  {{/each}}
+  </tbody>
+</table>
index 106c8a3..13d67c3 100644 (file)
@@ -1,10 +1,18 @@
+// A widget for one record
 mkws.registerWidgetType('Record', function() {
-  mkws.promotionFunction('Records').call(this);
   if (!this.config.maxrecs) this.config.maxrecs = 1;
+  var that = this;
+  var team = this.team;
+  team.queue("records").subscribe(function(data) {
+    var template = team.loadTemplate(that.config.template || "Record");
+    var targs = $.extend({}, data.hits[0], that.config.template_vars);
+    that.node.html(template(targs));
+  });
+  that.autosearch();
 });
 
 mkws.registerWidgetType('Image', function() {
-  mkws.promotionFunction('Record').call(this);
+  mkws.promotionFunction('Records').call(this);
   if (!this.config.template) this.config.template = 'Image';
 });
 
index b1044d2..c8d41be 100644 (file)
@@ -2,19 +2,6 @@ mkws.registerWidgetType('Reference', function() {
   mkws.promotionFunction('Record').call(this);
   if (!this.config.target) this.config.target = 'wikimedia_wikipedia_single_result';
   if (!this.config.template) this.config.template = 'Reference';
-  var nPara = this.config.paragraphs || 0;
-  var nSent = this.config.sentences || 0;
-
-  this.team.registerTemplate('Reference', '\
-  <img src="{{md-thumburl}}" alt="{{md-title}}">\
-  <h1><a href="{{md-electronic-url}}">{{md-title}}</a></h1>\
-{{#if md-title-remainder}}\
-  <b>{{md-title-remainder}}</b>\
-{{/if}}\
-{{#if md-title-responsibility}}\
-  <i>{{md-title-responsibility}}</i>\
-{{/if}}\
-  {{{mkws-paragraphs md-description ' + nPara + ' ' + nSent + '}}}\
-  <p class="mkwsCredit">Wikipedia</p>\
-');
+  this.config.template_vars.paragraphs = this.config.paragraphs || 0;
+  this.config.template_vars.sentences = this.config.sentences || 0;
 });
diff --git a/src/mkws-widget-reference.templates/Reference.handlebars b/src/mkws-widget-reference.templates/Reference.handlebars
new file mode 100644 (file)
index 0000000..62a9d2a
--- /dev/null
@@ -0,0 +1,17 @@
+{{!
+Paragraphs and images from a reference source.
+
+sentences - number of sentences to include
+paragraphs - number of paragraphs to include
+md-* - metadata fields passed through from backend
+}}
+<img src="{{md-thumburl}}" alt="{{md-title}}">
+<h1><a href="{{md-electronic-url}}">{{md-title}}</a></h1>
+{{#if md-title-remainder}}
+<b>{{md-title-remainder}}</b>
+{{/if}}
+{{#if md-title-responsibility}}
+<i>{{md-title-responsibility}}</i>
+{{/if}}
+{{{mkws-paragraphs md-description paragraphs sentences}}}
+<p class="mkwsCredit">Wikipedia</p>
index fef616f..8f6e467 100644 (file)
@@ -1,22 +1,19 @@
 mkws.registerWidgetType('Termlists', function() {
-  var that = this;
-
   // Initially hide the termlists; display when we get results
+  var that = this;
+  var team = this.team;
   mkws.$(document).ready(function() {
     that.node.hide();
   });
-  this.team.queue("termlists").subscribe(function(data) {
+  team.queue("termlists").subscribe(function(data) {
     that.node.show();
   });
 
-  var acc = [];
-  var facets = this.config.facets;
-  acc.push('<div class="mkwsTermlistsTitle">' + mkws.M('Termlists') + '</div>');
-  for (var i = 0; i < facets.length; i++) {
-    acc.push('<div class="mkwsFacet mkwsTeam_', this.team.name(), '" data-mkws-facet="', facets[i], '">', '</div>');
-  }
-  this.node.html(acc.join(''));
-
+  var template = team.loadTemplate(this.config.template || "Termlists");
+  this.node.html(template({
+    team: team.name(),
+    facets: this.config.facets
+  }));
   this.autosearch();
 });
 
@@ -27,8 +24,8 @@ mkws.registerWidgetType('Facet', function() {
     subject:  [ "Subjects", 10, true ],
     author:   [ "Authors",  10, true ]
   }
-
   var that = this;
+  var team = this.team;
   var name = that.config.facet;
   var ref = facetConfig[name] || [ "Unknown", 10, true ];
   var caption = this.config['facet_caption_' + name] || ref[0];
@@ -36,47 +33,50 @@ mkws.registerWidgetType('Facet', function() {
   var pzIndex = ref[2] ? name : null;
 
   that.toString = function() {
-    return '[Widget ' + that.team.name() + ':' + that.type + '(' + name + ')]';
+    return '[Widget ' + team.name() + ':' + that.type + '(' + name + ')]';
   };
 
-  var t2 = that.team.loadTemplate('Facet-' + caption);
-  that.log("template for Facet-" + caption + " is " + !!t2);
-  if (!t2) {
-    that.log("no " + caption + "-specific template, falling back");
-    t2 = that.team.loadTemplate('Facet');
-  }
-  that.log("template for Facet is " + !!t2);
-
-  that.team.queue("termlists").subscribe(function(data) {
+  team.queue("termlists").subscribe(function(data) {
     data = data[name];
-    var t1 = that.team.loadTemplate('facetTitle-' + caption, mkws.M(caption))
-    var title = t1({ query: that.config.query });
-    var acc = [];
-    acc.push('<div class="mkwsFacetTitle">', title, '</div>');
-
-    var teamName = that.team.name();
+    var terms = [];
+    var teamName = team.name();
     for (var i = 0; i < data.length && i < max; i++) {
-      var fn, field;
-      // General case modifies the query; special case selects a target
-      if (pzIndex) {
-        fn = 'limitQuery'; field = pzIndex;
-      } else if (!that.team.targetFiltered(data[i].id)) {
-        fn = 'limitTarget'; field = data[i].id;
+      var linkdata = "";
+      var action = "";
+      if (!pzIndex) {
+        // Special case: target selection
+        linkdata += ('target_id='+data[i].id+' ');
+        if (!team.targetFiltered(data[i].id)) {
+          action = 'mkws.limitTarget(\'' + teamName + '\', this.getAttribute(\'target_id\'),this.firstChild.nodeValue)';
+        }
+      } else {
+        action = 'mkws.limitQuery(\'' + teamName + '\', \'' + pzIndex + '\', this.firstChild.nodeValue)';
       }
-
-      var s = t2({ 
-        team: teamName,
-        fn: fn,
-        field: field,
+      linkdata += 'onclick="' + action + ';return false;"';
+      terms.push({
         term: data[i].name,
         count: data[i].freq,
-        query: that.config.query
-      });
-      acc.push('<div class="mkwsTerm">', s, '</div>');
+        linkdata: linkdata
+      }); 
     }
-
-    that.node.html(acc.join(''));
+    // configured template > facet specific template > default facet template
+    var template;
+    if (that.config.template) {
+      template = team.loadTemplate(that.config.template);
+    } else {
+      template = team.loadTemplate("Facet-" + caption);
+      if (template) {
+        that.log("Using Facet-" + caption + " template.")
+      } else {
+        that.log("No " + caption + " specific template, using default.")
+        template = team.loadTemplate("Facet");
+      }
+    }
+    that.node.html(template({
+      name: name,
+      caption: caption,
+      terms: terms
+    }));
   });
-
   this.autosearch();
 });
diff --git a/src/mkws-widget-termlists.templates/Facet.handlebars b/src/mkws-widget-termlists.templates/Facet.handlebars
new file mode 100644 (file)
index 0000000..621c9c1
--- /dev/null
@@ -0,0 +1,17 @@
+{{!
+A facet in the search.
+
+name - facet identifier, typically English and lowercase
+caption - caption for this facet
+terms:
+  term - term name
+  count - count of items matching in the current search for this team
+  linkdata - attributes to add to the term element including an onclick handler
+}}
+
+<div class="mkwsFacetTitle">{{caption}}</div>
+{{#each terms}}
+  <div class="mkwsTerm">
+    <a href="#" {{{linkdata}}}>{{term}}</a> <span>{{count}}</span>
+  </div>
+{{/each}}
diff --git a/src/mkws-widget-termlists.templates/Termlists.handlebars b/src/mkws-widget-termlists.templates/Termlists.handlebars
new file mode 100644 (file)
index 0000000..7c6f3b8
--- /dev/null
@@ -0,0 +1,11 @@
+{{!
+Termlists, a container of all configured facets.
+
+team - the current team
+facets - array of facet names
+}}
+
+<div class="mkwsTermlistsTitle">Termlists</div>
+{{#each facets}}
+  <div class="mkwsFacet mkwsTeam_{{../team}}" data-mkws-facet="{{this}}"></div>
+{{/each}}
index 722db5e..9a3a7f7 100644 (file)
@@ -66,6 +66,7 @@ function widget($, team, type, node) {
     return s.join('');
   };
 
+  // ### why is this a member function? It's never called from outside this file.
   that.expandValue = function(val) {
     if (val.match(/^!param!/)) {
       var param = val.replace(/^!param!/, '');
index dd1c75a..dc05163 100644 (file)
@@ -1,7 +1,8 @@
-node_modules
+libexec
 logs/error_log
 logs/jasmine-dev
 logs/mkws-jasmine-access.log
 logs/mkws-jasmine-error.log
 logs/mkws-jasmine-rewrite.log
 logs/mkws-jasmine.pid
+node_modules
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 a79be99..95e7dd5 100755 (executable)
@@ -45,7 +45,7 @@ eval {
     BSD::Resource::setrlimit("RLIMIT_CPU", $timeout, 2*$timeout) or die "Cannot set CPU limit: $!\n";
 };
 if ($@) {
-    warn "Please install the package BSD::Resource!\n\n$@\n";
+    warn "WARNING: things would go more nicely with the BSD::Resource package\n";
 }
 
 
diff --git a/test/bin/yui-compressor b/test/bin/yui-compressor
new file mode 100755 (executable)
index 0000000..c55de67
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+# 
+# yui-compressor - dummy wrapper for missing java tool yui-compressor
+
+cat <<EOF >&2
+==>  Warning: the real program yui-compressor does not exists <==
+     will use cat(1) instead! 
+EOF
+
+cat "$@"
+
index 1416efa..bd19642 100644 (file)
     "devDependencies": {
         "jQuery": "*",
         "xmlhttprequest": "*",
-        "jsdom": "*",
+        "jsdom": "<= 0.11.1",
         "request": "*",
         "jasmine-reporters": "<= 0.4.1",
         "jasmine-node": "*",
-        "phantomjs": "*"
+        "phantomjs": "*",
+        "handlebars": "= 1.3.0"
     },
     "repository": {
         "type": "git",
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 eb25086..2e49726 100644 (file)
@@ -728,6 +728,17 @@ describe("Check SortBy options", function () {
     });
 });
 
+describe("Check async widget discovery", function () {
+  var $ = mkws.$;
+  it("initialises a new widget", function() {
+    $("div.mkwsSearch").after('<div id="asyncSearch"><div id="asyncSearch" class="mkwsSearch mkwsTeam_async"></div></div>');
+    mkws.init("Another search box");
+    // mkws.init("Another search box", "#asyncSearch");
+    waitsFor(function () {
+      return $("#asyncSearch input").length >= 1 ? true : false;
+    }, "Call init() to build an .mkwsSearch", 750);
+  });
+});
 
 /* done */
 describe("All tests are done", function () {
index acf7cf4..92e22cb 100644 (file)
@@ -16,7 +16,9 @@ Listen ${APACHE_PORT}
 Include ${APACHE_MODULES}
 
 <IfModule log_config_module>
-   LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
+   # %O only works if mod_logio is enabled, which it isn't on Mike's MacBook
+   # LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
+   LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s \"%{Referer}i\" \"%{User-Agent}i\"" combined
 </IfModule>
 
 # pazpar2 / service proxy config
index 582af95..9b426fb 100644 (file)
@@ -35,8 +35,8 @@
     # mkws devel account (e.g. memached testing)
     RewriteRule /service-proxy-auth(/)?(;jsessionid=.+)?  /service-proxy/$2?command=auth&action=login&username=mkwsdev&password=mkwsdev [P] # [NE,P]
 
-    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-mkws.indexdata.com/service-proxy/
+    ProxyPassReverse /service-proxy/ http://sp-mkws.indexdata.com/service-proxy/
 
     ProxyPass        /pazpar2/         http://localhost:8004/pazpar2/
     ProxyPassReverse /pazpar2/         http://localhost:8004/pazpar2/
index e0cfd60..74c384f 100644 (file)
     RewriteRule /service-proxy-kohaauth(/)?(;jsessionid=.+)?   /service-proxy/$2?command=auth&action=check,login&username=kohademo&password=kohademo&identity=demo_koha_mkws [P]
     RewriteRule /service-proxy-orexauth(/)?(;jsessionid=.+)?   /service-proxy/$2?command=auth&action=check,login&username=orex&password=orexmkc&identity=orex_digital2 [P]
 
-    # The following rule allows the server to accept service-proxy
-    # requests that begin with an escaped "%3F" rather than a literal
-    # "?". This is useful, as requests generated by ProxyPass
-    # elsewhere always have the leading "?" escaped for some reason.
-    RewriteRule /service-proxy/\?(.*) /service-proxy/?$1 [P] # [NE,P]
-
-    Header set Access-Control-Allow-Credentials true
-
-    # 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/
-    # Or use: sp-mkc-sansa.indexdata.com:8080 or sp-mkc-arya.indexdata.com:8080
-
-    PerlOptions +Parent
-    PerlSwitches -I/home/indexdata/mkws/tools/mod_perl
-    <Location /service-proxy>
-        PerlOutputFilterHandler MyApache2::SetACAO
-    </Location>
+    RewriteRule /service-proxy/        /no-service-proxy.html
 </VirtualHost>
index bcd9e81..f335d96 100644 (file)
     Header set Access-Control-Allow-Credentials true
 
     ProxyPreserveHost On
-    # We could use any of the following:
-    #  sp-mkc.indexdata.com/service-proxy/ -- multiplexer
-    #  sp-mkc-sansa.indexdata.com:8080/service-proxy/ -- 1st back-end server
-    #  sp-mkc-arya.indexdata.com:8080/service-proxy/ -- 2nd back-end server
-    ProxyPass        /service-proxy/ http://sp-mkc-sansa.indexdata.com:8080/service-proxy/
-    ProxyPassReverse /service-proxy/ http://sp-mkc-sansa.indexdata.com:8080/service-proxy/
+    ProxyPass        /service-proxy/ http://sp-mkws-backend.indexdata.com:8080/service-proxy/
+    ProxyPassReverse /service-proxy/ http://sp-mkws-backend.indexdata.com:8080/service-proxy/
 
     PerlOptions +Parent
     PerlSwitches -I/home/indexdata/mkws/tools/mod_perl
diff --git a/tools/apache2/sp-mkws-mike b/tools/apache2/sp-mkws-mike
new file mode 100644 (file)
index 0000000..297f24b
--- /dev/null
@@ -0,0 +1,21 @@
+<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 /usr/local/src/git/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/
+
+#    PerlOptions +Parent
+#    PerlSwitches -I/home/indexdata/mkws/tools/mod_perl
+#    <Location /service-proxy>
+#        PerlOutputFilterHandler MyApache2::SetACAO
+#    </Location>
+</VirtualHost>
index 2904e85..0de766d 100755 (executable)
@@ -4,7 +4,7 @@
 # nagios test if the the service proxy is up and running
 
 set -e
-: ${mkws_host="http://mkws.indexdata.com/service-proxy/"}
+: ${mkws_host="http://sp-mkws.indexdata.com/service-proxy/"}
 : ${mkws_username="mkws"}
 : ${mkws_password="mkws"}
 : ${user_agent="nagios service-proxy v0.9"}
index 9c724ae..69d2713 100644 (file)
@@ -1,7 +1,7 @@
 NEWS
 README.html
 VERSION
-handlebars-v1.1.2.js
+handlebars-v1.3.0.js
 jquery-1.10.0.min.js
 jquery.json-2.4.js
 mkws-complete.js
@@ -12,3 +12,4 @@ mkws.js
 mkws.min.js
 pz2.js
 mkws-manual.html
+mkws-developer.html
index 420bb49..b561e92 100644 (file)
@@ -2,7 +2,7 @@
 
 SRC=   ../../src
 
-HANDLEBARS_FILE = handlebars-v1.1.2.js
+HANDLEBARS_FILE = handlebars-v1.3.0.js
 JQUERY_FILE = jquery-1.10.0.min.js
 JQUERY_JSON_FILE = jquery.json-2.4.js
 PP2_FILE = pz2.js
@@ -14,11 +14,15 @@ PP2_URL = http://git.indexdata.com/?p=pazpar2.git;a=blob_plain;f=js/${PP2_FILE};
 
 JQUERY_UI_URL =        http://code.jquery.com/ui/1.10.3/jquery-ui.js
 VERSION = $(shell tr -d '\012' < ${SRC}/VERSION)
+#HANDLEBARS=handlebars 
+HANDLEBARS=../../test/node_modules/.bin/handlebars 
+YUI_COMPRESSOR= $(shell which yui-compressor ../../test/bin/yui-compressor | head -1)
 
 COMPONENTS = ${SRC}/mkws-handlebars.js \
        ${SRC}/mkws-core.js \
        ${SRC}/mkws-team.js \
        ${SRC}/mkws-filter.js \
+       ${SRC}/mkws-templates.js \
        ${SRC}/mkws-popup.js \
        ${SRC}/mkws-widget.js \
        ${SRC}/mkws-widget-main.js \
@@ -31,7 +35,7 @@ COMPONENTS = ${SRC}/mkws-handlebars.js \
        ${SRC}/mkws-widget-builder.js
 
 GENERATED = ${HANDLEBARS_FILE} ${JQUERY_FILE} ${JQUERY_JSON_FILE} ${PP2_FILE} \
-       mkws.js mkws.min.js mkws-complete.js mkws-complete.min.js
+       mkws.js mkws.min.js mkws-complete.js mkws-complete.min.js mkws-templates.js
 
 **make-default**: all
 
@@ -55,11 +59,11 @@ mkws-js mkws-complete.js: Makefile mkws.js ${HANDLEBARS_FILE} ${JQUERY_FILE} ${J
        mv -f mkws-complete.js.tmp mkws-complete.js
 
 %.min.js: %.js
-       yui-compressor $? > $@.tmp
+       ${YUI_COMPRESSOR} $? > $@.tmp
        mv -f $@.tmp $@
 
 mkws-syntax-check:
-       yui-compressor mkws.js >/dev/null
+       ${YUI_COMPRESSOR} mkws.js >/dev/null
 
 ${HANDLEBARS_FILE}:
        curl -sSf ${HANDLEBARS_URL} -o $@.tmp
@@ -89,12 +93,15 @@ release: mkws.js mkws-complete.js mkws.min.js mkws-complete.min.js
                echo "Made release $(VERSION)"; \
        fi
 
-mkws.js: $(COMPONENTS) Makefile
+mkws.js: mkws-templates.js $(COMPONENTS) Makefile
        rm -f $@
        cat ${COMPONENTS} > $@.tmp
        mv -f $@.tmp $@
        chmod 444 $@
 
+mkws-templates.js:
+       ${HANDLEBARS} -n mkws.defaultTemplates ${SRC}/*.templates/*.handlebars -f ${SRC}/mkws-templates.js
+
 mkws-html-includes: 
        echo $(COMPONENTS) | perl -npe "s,${SRC},,g; s/\s+/\0/g" | \
          perl -n0e 'chomp(); print qq{    <script type="text/javascript" src="src$$_"></script>\n}'
diff --git a/tools/htdocs/no-service-proxy.html b/tools/htdocs/no-service-proxy.html
new file mode 100644 (file)
index 0000000..b1a5f15
--- /dev/null
@@ -0,0 +1,3 @@
+There is no /service-proxy/ on mkws.indexdata.com.
+<p>
+You probably want to use http://sp-mkws.indexdata.com/service-proxy/
diff --git a/tools/service-proxy/.gitignore b/tools/service-proxy/.gitignore
new file mode 100644 (file)
index 0000000..ab91c1c
--- /dev/null
@@ -0,0 +1 @@
+service-proxy-mike-mac.properties
diff --git a/tools/service-proxy/Makefile b/tools/service-proxy/Makefile
new file mode 100644 (file)
index 0000000..7fb4847
--- /dev/null
@@ -0,0 +1,10 @@
+MIKE = service-proxy-mike-mac.properties
+
+$(MIKE): service-proxy.properties Makefile
+       rm -f $@
+       sed 's/mkc-admin.indexdata.com/x.&:8181/g' $< > $@
+       chmod 444 $@
+
+clean:
+       rm -f $(MIKE)
+
diff --git a/tools/service-proxy/pazpar2/README b/tools/service-proxy/pazpar2/README
new file mode 100644 (file)
index 0000000..87877fa
--- /dev/null
@@ -0,0 +1,14 @@
+This contains an ICU-stripped version of the coniguration used by the
+live MKC service, since I (Mike) need to run it on a Mac where YAZ is
+installed (using "brew install yaz") compiled without ICU.
+
+NOTE TO SELF:
+shell1$ cd /usr/local/src/git/service-proxy/sp-runtime; mvn jetty:run-war
+shell2$ cd /usr/local/src/git/torus; mvn jetty:run-war
+shell3$ cd /usr/local/src/git/mkws/tools/service-proxy/pazpar2 && /usr/local/sbin/pazpar2 -f server.no-icu.xml
+shell4$ cd /usr/local/src/git/idzebra/examples/gils && zebrasrv tcp:@:9998
+shell5$ yaz-ztest
+
+THEN USE:
+http://x.mkc-admin.indexdata.com/console/
+http://x.example.indexdata.com/mike.html
diff --git a/tools/service-proxy/pazpar2/server.no-icu.xml b/tools/service-proxy/pazpar2/server.no-icu.xml
new file mode 100644 (file)
index 0000000..8074d3c
--- /dev/null
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<pazpar2 xmlns="http://www.indexdata.com/pazpar2/1.0">
+  <threads number="0"/> <!-- non-zero to enable threaded operation -->
+  <file path=".:/usr/share/pazpar2/xsl"/> 
+  <server>
+    <listen port="8004"/>
+    <include src="service.no-icu.xml"/>
+  </server>
+</pazpar2>
diff --git a/tools/service-proxy/pazpar2/service.no-icu.xml b/tools/service-proxy/pazpar2/service.no-icu.xml
new file mode 100644 (file)
index 0000000..b7e65ba
--- /dev/null
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- This is NOT used by the live system, which shares MKC's Pazpar2 config.
+     It's only for Mike to run on his development system, which lacks ICU -->
+<service id="mkc" xmlns="http://www.indexdata.com/pazpar2/1.0">
+  <timeout session="60" z3950_operation="30" z3950_session="180"/>
+
+  <rank cluster="yes"
+       follow="0.0"
+       lead="1.0"
+       length="linear"
+       debug="no" />
+
+  <settings src="settings-testserver.xml"/>
+  
+  <!-- we try to keep same order as in marc21.xsl -->
+  <metadata name="id" brief="yes"/>
+  <metadata name="lccn" merge="unique"/>
+  <metadata name="isbn" brief="yes" merge="unique"/>
+  <metadata name="issn" brief="yes" merge="unique"/>
+  <metadata name="tech-rep-nr"/>
+  <metadata name="author" brief="yes" termlist="yes" merge="unique" 
+           rank="2" mergekey="optional" limitmap="ccl: au" />
+  <metadata name="author-title"/>
+  <metadata name="author-date"/>
+  <metadata name="corporate-name"/>
+  <metadata name="corporate-location"/>
+  <metadata name="corporate-date"/>
+  <metadata name="meeting-name"/>
+  <metadata name="meeting-location"/>
+  <metadata name="meeting-date"/>
+  <metadata name="date" brief="yes" sortkey="numeric" type="year"
+           merge="range" termlist="yes" limitmap="ccl: date"/>
+  <metadata name="title" brief="yes" sortkey="skiparticle"
+           merge="longest" rank="6" mergekey="required"/>
+  <metadata name="title-remainder" brief="yes" merge="longest" rank="5"/>
+  <metadata name="title-responsibility" brief="yes" merge="longest"/>
+  <metadata name="title-dates" brief="yes" merge="longest"/>
+  <metadata name="title-medium" brief="yes" merge="unique" 
+               termlist="yes" sortkey="skiparticle" limitmap="local:"/>
+  <metadata name="title-number-section" brief="yes" merge="longest"/>
+  <metadata name="title-complete"/>
+  <metadata name="title-uniform"/>
+  <metadata name="medium" brief="yes" merge="unique" limitmap="local:" />
+  <metadata name="iii-id" brief="yes" merge="no"/>
+  <metadata name="edition"/>
+  <metadata name="publication-place"/>
+  <metadata name="publication-name"/>
+  <metadata name="publication-date"/>
+  <metadata name="physical-extent"/>
+  <metadata name="physical-format"/>
+  <metadata name="physical-dimensions"/>
+  <metadata name="physical-accomp"/>
+  <metadata name="physical-unittype"/>
+  <metadata name="physical-unitsize"/>
+  <metadata name="physical-specified"/>
+  
+  <metadata name="series-title" brief="yes" merge="unique"/>
+  
+  <metadata name="description" brief="yes" merge="unique" rank="3"/>
+  <metadata name="subject-long" rank="3"/>
+  <metadata name="subject" termlist="yes" rank="0" limitmap="ccl: su" 
+       brief="yes" merge="unique"/>
+  <metadata name="snippet" brief="yes" merge="unique"/>
+  <metadata name="electronic-url" brief="yes" merge="unique"/>
+  <metadata name="electronic-format-type" />
+  <metadata name="electronic-format-instruction" />
+  <metadata name="electronic-text" brief="yes" merge="no"/>
+  <metadata name="electronic-note"/>
+  <metadata name="citation"/>
+  <metadata name="holding"/>
+  <metadata name="fulltext"/>
+  <metadata name="has-fulltext"/>
+  <metadata name="oclc-number"/>
+  <metadata name="system-control-nr"/>
+  <metadata name="locallocation" brief="yes"/>
+  <metadata name="callnumber" brief="yes"/>
+  <metadata name="publicnote" brief="yes"/>
+  
+  <!-- journals -->
+  <metadata name="journal-title"/>
+  <metadata name="journal-subpart"/>
+  <metadata name="volume-number"/>
+  <metadata name="issue-date"/>
+  <metadata name="issue-number"/>
+  <metadata name="pages-number"/>
+  
+  <metadata name="url_recipe" setting="postproc" brief="yes" merge="no"/>
+  <metadata name="open_url_resolver" setting="parameter" merge="no"/>
+  <metadata name="open-url" merge="longest"/>
+  <metadata name="use_url_proxy" setting="postproc" brief="yes" merge="no"/>
+  
+  <metadata name="publisher"/>
+  <metadata name="available" brief="yes" merge="no" limitmap="local:"/>
+  <metadata name="due"/>
+  <metadata name="thumburl" brief="yes" merge="unique"/>
+  <metadata name="score"/>
+
+  <!-- normarc fields -->
+
+  <metadata name="price" merge="no"/>
+  <metadata name="locallocation-section" brief="yes" merge="no"
+       termlist="yes" limitmap="local:"/>
+  <metadata name="circulation-status" brief="yes" merge="no" 
+       termlist="yes" limitmap="local:"/>
+  <metadata name="circulation-restriction" brief="yes" merge="no"/>
+  <metadata name="bibliofil-id" brief="yes" merge="no"/>
+  <metadata name="bibliofil-url" brief="yes" merge="no"/>
+  <metadata name="audience" brief="yes" merge="unique" termlist="yes"
+       limitmap="local:"/>
+
+</service>
+<!-- Keep this comment at the end of the file
+     Local variables:
+     mode: nxml
+     End:
+oooo
+-->
+
diff --git a/tools/service-proxy/pazpar2/settings-testserver.xml b/tools/service-proxy/pazpar2/settings-testserver.xml
new file mode 100644 (file)
index 0000000..69a8c36
--- /dev/null
@@ -0,0 +1,28 @@
+<settings target="localhost:9999/Default">
+
+  <!-- Simple test against a local test server (could be yaz-ztest) -->
+
+  <set name="pz:name" value="Local Test"/>
+  <set name="pz:apdulog" value="1"/>
+
+  <!-- mapping for unqualified search -->
+  <set name="pz:cclmap:term" value="u=1016 t=l,r s=al"/>
+
+  <!-- field-specific mappings -->
+  <set name="pz:cclmap:ti" value="u=4 s=al"/>
+  <set name="pz:cclmap:su" value="u=21 s=al"/>
+  <set name="pz:cclmap:isbn" value="u=7"/>
+  <set name="pz:cclmap:issn" value="u=8"/>
+  <set name="pz:cclmap:date" value="u=30 r=r"/>
+
+  <!-- Retrieval settings -->
+
+  <set name="pz:requestsyntax" value="marc21"/>
+  <set name="pz:elements" value="F"/>
+
+  <!-- Result normalization settings -->
+
+  <set name="pz:nativesyntax" value="iso2709"/>
+  <set name="pz:xslt" value="marc21.xsl"/>
+
+</settings>
diff --git a/tools/service-proxy/pazpar2/tmarc.xsl b/tools/service-proxy/pazpar2/tmarc.xsl
new file mode 120000 (symlink)
index 0000000..e1dcb37
--- /dev/null
@@ -0,0 +1 @@
+../../../../pazpar2/etc/xsl/tmarc.xsl
\ No newline at end of file
index 1c67a04..a3b92e4 100644 (file)
@@ -6,6 +6,7 @@ plugins.relay      = com.indexdata.serviceproxy.plugins.Pazpar2RelayPlugin
 plugins.authn      = com.indexdata.serviceproxy.plugins.AuthNTorusPlugin
 plugins.categories = com.indexdata.serviceproxy.plugins.TargetCategoriesPlugin
 plugins.ils        = com.indexdata.serviceproxy.plugins.ILSPlugin
+plugins.statistics = com.indexdata.serviceproxy.plugins.StatisticsPlugin
 
 
 # Configuration properties for individual plug-ins 
@@ -41,7 +42,7 @@ chains.auth = authn
 chains.categories = categories
 chains.ils = ils
 # Map all other commands to the Pazpar2 relayer
-chains.* = relay
+chains.* = relay,statistics
 
 
 # Just so I can check that this particular SP config is in use