Merge branch 'master' of ssh://git.indexdata.com:222/home/git/private/mkws
authorHeikki Levanto <heikki@indexdata.dk>
Thu, 27 Feb 2014 15:27:29 +0000 (16:27 +0100)
committerHeikki Levanto <heikki@indexdata.dk>
Thu, 27 Feb 2014 15:27:29 +0000 (16:27 +0100)
Makefile
TODO [deleted file]
tools/htdocs/Makefile
tools/htdocs/mkws.js

index 3c1dfa6..f58f93f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,9 +3,6 @@
 all:
        ${MAKE} -C./tools/htdocs $@
 
-pz2api-git-checkout:
-       ${MAKE} -C./tools/htdocs $@
-
 clean distclean:
        ${MAKE} -C./tools/htdocs $@
        ${MAKE} -C./examples/htdocs $@
@@ -17,7 +14,7 @@ phantomjs:
        ${MAKE} -C./test $@
 
 # must be called once after GIT checkout
-setup: pz2api-git-checkout
+setup: 
        ${MAKE} -C./tools/htdocs mkws-js-min
        ${MAKE} -C./examples/htdocs jasmine-links
        ${MAKE} -C./test node-modules
@@ -26,5 +23,5 @@ check: setup check-js
 
 help:
        @echo "make [ all | setup | clean | distclean ]"
-       @echo "     [ pz2api-git-checkout | check-js ]"
+       @echo "     [ check | check-js | phantomjs ]"
 
diff --git a/TODO b/TODO
deleted file mode 100644 (file)
index 377df00..0000000
--- a/TODO
+++ /dev/null
@@ -1,181 +0,0 @@
-*** MKWS ***
-
-       Make a demo widget that displays an image, like the "From the
-       Digital Archive" panel of our Toronto Digital Library demo.
-
-       Make a widget demo that displays the top-hit full record
-       rather than a list of summary records. This can be used to
-       pull in Wikipedia text to make the bulk of a topic page.
-
-       Make an Amazon cover-art widget.
-
-       Do target selection by UDB rather than ZURL. Needs SP changes.
-
-       We will want a facets-only widget, e.g. to list top authors
-
-       Visualisation widgets e.g. pie-chart of authors, bar-graph of
-       records Generate embedded SVG? Does that even work?
-
-       Make am MKWS/Fresco demo by embedding widgets in our Koha
-       installation. Get Wolfram to do this, and find out which parts
-       of the process are cumbersome for him.
-
-       Write about interesting new widgets on the Index Data blog.
-
-       Widget gallery
-         * Mainly a marketing thing on mkws.indexdata.com
-         * May also have a role in widget creation in MKAdmin
-
-       Architecture:
-         * Separate objects for each widget
-         * Translucent configuration
-         * Decouple using publish/subscribe
-         * Managed widgets held in the Torus
-         * 3rd party widget platforms
-
-       Write integration guides for various third-party CMSs.
-
-       In the widget builder, we want to expose capability
-       information (from ZeeRex or a Torus record) in a
-       human-consumable form: "this target can sort by recency", that
-       kind of thing.
-
-       Auto-widgets should be able to include limits (as a full set
-       of MK2-like widgets does in order to implement facets).
-
-       Auto-widgets should be able to include filters (as a full set
-       of MK2-like widgets does in order to implement the Target
-       facet). This can be used to implement target categories as
-       well as the current cruder target-selection-by-ID facility.
-
-       In the widget builder, we should be able to filter the targets
-       available to the widget on the basis of what requirements the
-       widget has, e.g. ability to sort by recency. The capability
-       facet in MKAdmin may suffice for this.
-
-       Check library selection by hostname works for MKWS.
-
-       The widget-builder widget (WBW) should have a Save button that
-       is customised by a callback, so that the widget in question
-       can (for example) be copied into the clipboard, pasted into a
-       nominated div, saved to a database or whatever.
-
-       Allow debug() to be customised by setting a callback function
-       that is passed the string rather than just giving it to
-       console.log().
-
-       Create a logging widget which displays the output of debug().
-
-       Add library selection by secret key as an alternative to
-       selection by user/pw. This is appropriate for
-       security-conscious customers to embed in their own CORS-aware
-       Apache2 configuration.
-
-
-*** MKAdmin ***
-
-       Superuser field should not be mandatory.
-
-       In end-user record, username and password should not be
-       mandatory any more. (Perhaps it should be mandatory to have at
-       least one of u/p, IP range, hostname, etc.)
-
-       Add an "Act As" link on the Edit Library page.
-
-       When making a new user-access record, default the displayName
-       to that of the ibrary that owns it.
-
-       Add a capability facet to MKAdmin. The right way to do this is
-       to refactor the current hardwiry facet code to be more
-       data-driven, then add a configuration element to include
-       capabilities as a facet.
-
-       Make MKAdmin able to filter target list on whether we have
-       access: that is, to targets that either are open-access or we
-       have credentials or an IP proxy for.
-
-       Provide "select all targets" to they can be added.
-
-       Add batch edit on all targets found by the current search.
-
-       We want a way to let customers change the Index Data branding
-       of the MKX front page, as well as the logo at top left of the
-       MasterKey UI itself. Along with that, we could let them change
-       CSS.
-
-       Indent second and subsequent lines of long facet names
-
-       Keep selected facets when narrowing by search, etc. NOT URGENT
-
-       Lose the search function and the A-Z list from the Categories
-       and User Access tabs.
-
-       Lose ALL the left panel options for the categories tab.
-
-       In the library list, rename "Act as this user" to "Act as".
-
-       We need only one add-new-field name/value pair at the bottom
-       of the screen, not three.
-
-
-*** MKAdmin-- ***
-
-       Lose Target Origin and Type columns from target list.
-
-       Lose the A-Z list from all tabs.
-
-       Remove "changed in last NUMBER days" from search form
-
-       In the target list, get rid of "Show record", make the target
-       title a link to the edit page, and discard the edit column
-       completely.
-
-       Lose the Create Target facility (from left panel and bottom
-       row).
-
-       Remove the the Edit facility and the New button from the
-       categories tab. Keep the category_id column, for some
-       reason. (Although I bet if I removed it neither Seb nor D
-       would notice.)
-
-       Make the User Access tab display the single end-user record
-       for editing immediately. Remove everything that doesn't need
-       to be there.
-
-       D will get back to me with a detailed specification of which
-       reports to include in the Reports tab.
-
-       In the edit page, lose all the top icons.
-
-       D will give me a list of target fields to retain in the
-       MKAdmin-- edit page. It may be just target name, categories
-       and credentials.
-
-       Remove all help from MKAdmin until Seb sends help texts that
-       he is happy with.
-
-       BIG CHANGE: lose the edit-form distinction between inherited
-       and local values. Have a single column of editable values and
-       override only those that are actually changed.
-
-
-*** Other ***
-
-       Get Charles to remove the testing proxy-IPs from open-access
-       databases.
-
-       We need additional image-URL fields in our records -- in the
-       connector framework, in the Torus record's capabilities and
-       elsewhere. Figure out what's needed, and who needs to do it.
-
-       Fix the Torus's timed refresh to run on its own in the
-       background, rather than waiting until the next time a request
-       is made after the refresh-time has expired.
-
-       Can the IRSpy toroid be made to return a meaningful capability
-       field?
-
-       Metasearch all targets and see what happens. Figure out why it
-       goes wrong.
-
-
index 68278ad..81b8af3 100644 (file)
@@ -17,16 +17,15 @@ JQUERY_UI_URL=      http://code.jquery.com/ui/1.10.3/jquery-ui.js
 #JQUERY_UI_URL=        http://code.jquery.com/ui/1.8.0/jquery-ui.min.js
 JQUERY_JSON_URL= https://jquery-json.googlecode.com/files/jquery.json-2.4.js
 HANDLEBARS_URL=        http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.1.2.js -o $@
+PP2_URL=       http://git.indexdata.com/?p=pazpar2.git;a=blob_plain;f=js/pz2.js;hb=HEAD
 VERSION = $(shell tr -d '\012' < VERSION)
 
 MKWS_JS=       mkws-complete.js
-PZ2API_JS=     ../../../pazpar2/js/pz2.js
-PZ2API_GIT=    ssh://git.indexdata.com:222/home/git/pub/pazpar2
 
 JQUERY_FILE := $(shell basename ${JQUERY_URL})
 JQUERY_JSON_FILE := $(shell basename ${JQUERY_JSON_URL})
 HANDLEBARS_FILE := $(shell basename ${HANDLEBARS_URL})
-PP2_FILE := $(shell basename ${PZ2API_JS})
+PP2_FILE = pz2.js
 ##############################
 
 DOCS = README.html README.odt README.pdf \
@@ -39,27 +38,13 @@ all: ${MKWS_JS} mkws-js-min $(DOCS)
 
 docs: $(DOCS)
 
-pz2api-git-checkout:
-       @if ! test -e ${PZ2API_JS}; then \
-           ( cd ../../.. && git clone ${PZ2API_GIT} ); \
-       fi
-
 mkws-js ${MKWS_JS}: Makefile mkws.js ${JQUERY_FILE} ${JQUERY_JSON_FILE} ${HANDLEBARS_FILE} ${PP2_FILE}
-       @if ! test -e ${PZ2API_JS}; then \
-           echo "The pazpar2 JS file ${PZ2API_JS} does not exists."; \
-           echo "Did you checked out the source from the git repo?"; \
-           echo ""; \
-           echo "Please run:"; \
-           echo "$$ make pz2api-git-checkout"; \
-           echo ""; \
-           exit 1; \
-       fi
        ( set -e; \
          echo "/*! Copyright (c) 2013-2014 IndexData ApS. http://indexdata.com"; \
          echo "   Licence: GPL, http://www.indexdata.com/licences/gpl"; \
          echo "   created at: $$(date)"; \
          echo "   mkws.js GIT id: $$(git log mkws.js | head -n 1 | perl -npe 's,\S+\s+,,')"; \
-         echo "   $$(basename ${PZ2API_JS}) GIT id: $$(cd $$(dirname ${PZ2API_JS}) && git log $$(basename ${PZ2API_JS}) | head -n 1 | perl -npe 's,\S+\s+,,')"; \
+         echo "   pz2.js GIT id: $$(curl -sSf 'http://git.indexdata.com/?p=pazpar2.git;a=rss' | egrep '<guid' | head -1 | perl -ne 'print "$$1\n" if m,.*=([0-9a-f]+)</guid>,')"; \
          echo "*/"; \
          cat ${JQUERY_FILE}; \
          cat ${JQUERY_JSON_FILE}; \
@@ -91,8 +76,9 @@ ${JQUERY_JSON_FILE}:
 ${HANDLEBARS_FILE}:
        curl -sSf ${HANDLEBARS_URL} -o $@
 
-${PP2_FILE}: ${PZ2API_JS}
-       cp -pf ${PZ2API_JS} $@  
+${PP2_FILE}:
+       curl -sSf "${PP2_URL}" -o $@.tmp
+       mv -f $@.tmp $@
 
 release: mkws.js mkws-complete.js mkws.min.js mkws-complete.min.js
        @if [ -f releases/mkws-$(VERSION).js ]; then \
index c739684..72ca3f3 100644 (file)
@@ -142,12 +142,48 @@ var mkws = {
 };
 
 
+// The following PubSub code is modified from the jQuery manual:
+// https://api.jquery.com/jQuery.Callbacks/
+//
+// Use as:
+//     mkws.queue("eventName").subscribe(function(param1, param2 ...) { ... });
+//     mkws.queue("eventName").publish(arg1, arg2, ...);
+
+(function() {
+  var queues = {};
+  mkws.queue = function(id) {
+    if (!queues[id]) {
+      var callbacks = $.Callbacks();
+      queues[id] = {
+       publish: callbacks.fire,
+       subscribe: callbacks.add,
+       unsubscribe: callbacks.remove
+      };
+    }
+    return queues[id];
+  }
+}());
+
+
 // Define empty mkws_config for simple applications that don't define it.
 if (mkws_config == null || typeof mkws_config != 'object') {
     var mkws_config = {};
 }
 
 
+// Factory function for widget objects.
+function widget($, team, node) {
+    var that = {
+       team: team,
+       node: node
+    };
+
+    // ### More to do here, surely
+
+    return that;
+}
+
+
 // Factory function for team objects. As much as possible, this uses
 // only member variables (prefixed "m_") and inner functions with
 // private scope. Some functions are visibl as member-functions to be
@@ -1405,12 +1441,13 @@ function team($, teamName) {
        // the mkwsTeam_* class. Make all team objects.
        var then = $.now();
        $('[class^="mkws"],[class*=" mkws"]').each(function () {
-           var node = this;
-           mkws.handle_node_with_team(node, function(tname) {
+           mkws.handle_node_with_team(this, function(tname) {
                if (!mkws.teams[tname]) {
                    mkws.teams[tname] = team(j, tname);
                    debug("Made MKWS team '" + tname + "'");
                }
+               var myTeam = mkws.teams[tname]
+               var myWidget = widget(j, myTeam, this)
            });
        });
        var now = $.now();