From: Lebbeous Fogle-Weekley Date: Mon, 12 Dec 2011 17:03:27 +0000 (-0500) Subject: mockup showing how to accomplish some of the ui/feedtemplate bits X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=b14b396fdf551fb1f02177218394a3610062948a;p=evergreen%2Fequinox.git mockup showing how to accomplish some of the ui/feedtemplate bits Signed-off-by: Lebbeous Fogle-Weekley --- diff --git a/Open-ILS/examples/apache/eg_vhost.conf b/Open-ILS/examples/apache/eg_vhost.conf index 82872dacba..a2ba0b2cf4 100644 --- a/Open-ILS/examples/apache/eg_vhost.conf +++ b/Open-ILS/examples/apache/eg_vhost.conf @@ -51,6 +51,14 @@ OSRFGatewayConfig /openils/conf/opensrf_core.xml allow from all +# Autosuggest for searches + + SetHandler perl-script + PerlHandler OpenILS::WWW::AutoSuggest + PerlSendHeader On + Allow from All + + # ---------------------------------------------------------------------------------- # Replace broken cover images with a transparent GIF by default # ---------------------------------------------------------------------------------- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm new file mode 100644 index 0000000000..d1021acfe2 --- /dev/null +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/AutoSuggest.pm @@ -0,0 +1,67 @@ +package OpenILS::WWW::AutoSuggest; + +use strict; +use warnings; + +use Apache2::Log; +use Apache2::Const -compile => qw(OK REDIRECT DECLINED NOT_FOUND :log); +use APR::Const -compile => qw(:error SUCCESS); +use Apache2::RequestRec (); +use Apache2::RequestIO (); +use Apache2::RequestUtil; +use CGI; + +my @dict = qw/ + alpha + allstate + apple + appropriate + application + arizona + bears + beta + beets + gamma + gone + out + tool + toad + tap + sock + socket + sicken + sickening + rage + right + road + /; + +sub search_dict { + my $term = shift; + (my $re = $term) =~ s/[^a-z0-9]/\./gi; + + return ($term, grep(/^$re/, @dict)); +} + +sub handler { + my $r = shift; + my $cgi = new CGI; + + my ($term, @matches) = search_dict($cgi->param("query")); + my $xml_terms = join("\n", map { + qq{$_} + } @matches); + print "Content-type: application/xml; charset=utf-8\n\n"; + + print qq{ + +$xml_terms + + }; + + return Apache2::Const::OK; +} + +1; + +# vim: et:ts=4:sw=4 diff --git a/Open-ILS/web/js/dojo/openils/BibTemplate.js b/Open-ILS/web/js/dojo/openils/BibTemplate.js index 8c81447c0a..c130dd19fc 100644 --- a/Open-ILS/web/js/dojo/openils/BibTemplate.js +++ b/Open-ILS/web/js/dojo/openils/BibTemplate.js @@ -267,16 +267,21 @@ if(!dojo._hasResource["openils.BibTemplate"]) { var me = this; var process_feed = function (xmldoc) { - if (parseInt(me.horizon) >= parseInt(me.root.getAttribute('horizon'))) { + console.log("in process_feed()"); + if (parseInt(me.horizon) >= parseInt(me.root.getAttribute('horizon'))) { if (me.empty == true) dojo.empty(me.place); me.root.setAttribute('horizon', this.horizon); + console.log("about to do bibtemplate loop, item_query is " + me.item_query); dojo.query( me.item_query, xmldoc ).forEach( function (item) { var template = me.root.cloneNode(true); dojo.place( template, me.place, me.relativePosition ); + console.log("instantiating a bibtemplate"); new openils.BibTemplate({ delay : false, xml : item, root : template }); } ); + } else { + console.log("horizon test failed"); } }; diff --git a/Open-ILS/web/opac/skin/default/js/search_bar.js b/Open-ILS/web/opac/skin/default/js/search_bar.js index 76d123db90..c77caa8351 100644 --- a/Open-ILS/web/opac/skin/default/js/search_bar.js +++ b/Open-ILS/web/opac/skin/default/js/search_bar.js @@ -13,6 +13,28 @@ G.evt.common.init.push(searchBarInit); var newSearchLocation; var newSearchDepth = null; +dojo.require("openils.BibTemplate"); + + +var autosuggest_ft; + +function autosuggestTest() { + if (!autosuggest_ft) { + autosuggest_ft = new openils.FeedTemplate({ + "place": dojo.byId("test1"), + "root": dojo.byId("template_root"), + "empty": true, + "query": "as", + "preventCache": true /* XXX do we want this permanently? */ + }); + } + + autosuggest_ft.feed_uri = "http://dev-vm1/opac/extras/autosuggest?query=" + + dojo.byId("search_box").value; + console.log(autosuggest_ft.feed_uri); + + autosuggest_ft.render(); +} function searchBarInit() { diff --git a/Open-ILS/web/opac/skin/default/xml/home/homesearch.xml b/Open-ILS/web/opac/skin/default/xml/home/homesearch.xml index 30ca9a3481..1db0f336a7 100644 --- a/Open-ILS/web/opac/skin/default/xml/home/homesearch.xml +++ b/Open-ILS/web/opac/skin/default/xml/home/homesearch.xml @@ -55,10 +55,14 @@ - - - - +
+ + + unhidesearch + +
+ +
@@ -128,8 +132,16 @@ - - - - +
+
+ + + +
+