This means introducing Dojo, optionally, into the TPAC.
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
$ctx->{search_ou} = $self->_get_search_lib();
$self->staff_saved_searches_set_expansion_state if $ctx->{is_staff};
+ $self->load_eg_cache_hash;
return Apache2::Const::OK;
}
package OpenILS::WWW::EGCatLoader;
use strict; use warnings;
use Apache2::Const -compile => qw(OK DECLINED FORBIDDEN HTTP_INTERNAL_SERVER_ERROR REDIRECT HTTP_BAD_REQUEST);
+use File::Spec;
use OpenSRF::Utils::Logger qw/$logger/;
use OpenILS::Utils::CStoreEditor qw/:funcs/;
use OpenILS::Utils::Fieldmapper;
map => {aou => {}}, # others added dynamically as needed
list => {},
search => {},
- org_settings => {}
+ org_settings => {},
+ eg_cache_hash => undef
);
sub init_ro_object_cache {
return $self->ctx->{aou_tree}->()->id;
}
+# This is defensively coded since we don't do much manual reading from the
+# file system in this module.
+sub load_eg_cache_hash {
+ my ($self) = @_;
+
+ # just a context helper
+ $self->ctx->{eg_cache_hash} = sub { return $cache{eg_cache_hash}; };
+
+ # Need to actually load the value? If already done, move on.
+ return if defined $cache{eg_cache_hash};
+
+ # In this way even if we fail, we won't slow things down by ever trying
+ # again within this Apache process' lifetime.
+ $cache{eg_cache_hash} = 0;
+
+ my $path = File::Spec->catfile(
+ $self->apache->document_root, "eg_cache_hash"
+ );
+
+ if (not open FH, "<$path") {
+ $self->apache->log->warn("error opening $path : $!");
+ return;
+ } else {
+ my $buf;
+ my $rv = read FH, $buf, 64; # defensive
+ close FH;
+
+ if (not defined $rv) { # error
+ $self->apache->log->warn("error reading $path : $!");
+ } elsif ($rv > 0) { # no error, something read
+ chomp $buf;
+ $cache{eg_cache_hash} = $buf;
+ }
+ }
+}
+
1;
<link rel="stylesheet" type="text/css" href="[% ctx.media_prefix %]/css/skin/default/opac/style.css" />
<title>[% l('Catalog - [_1]', ctx.page_title) %]</title>
<link rel="unapi-server" type="application/xml" title="unAPI" href="/opac/extras/unapi" />
+ [% IF want_dojo %]
+ <style type="text/css">
+ @import "[% ctx.media_prefix %]/js/dojo/dojo/resources/dojo.css";
+ @import "[% ctx.media_prefix %]/js/dojo/dijit/themes/tundra/tundra.css";
+ </style>
+ [% END %]
[% INCLUDE 'opac/parts/goog_analytics.tt2' %]
</head>
- <body>
+ <body[% IF want_dojo; ' class="tundra"'; END %]>
[% content %]
[% INCLUDE 'opac/parts/footer.tt2' %]
[% INCLUDE 'opac/parts/js.tt2' %]
cgi.url("-path" => 1, "-query" => 1);
END;
END;
+
+ # Whether we want Dojo or not may one day be a wholly distinct
+ # concern from whether we want autosuggest, so let's get used to
+ # defining that separately.
+ want_dojo = 0;
+
+ use_autosuggest = ctx.get_cgf("opac.use_autosuggest");
+
+ IF use_autosuggest.enabled == "t";
+ want_dojo = 1;
+ END;
%]
IF CGI.https; url = url.replace('^http:', 'https:'); END; %]
<script type='text/javascript' id='EIT' src='[% url %]'></script>
[%- END %]
+[%- IF want_dojo; -%]
+<script type="text/javascript">
+ var locale = "[% ctx.locale %]";
+ var djConfig = {
+ locale: locale.toLowerCase().replace("_", "-"), /* XXX ? */
+ parseOnLoad: true,
+ isDebug: false
+ }, lang, bidi;
+</script>
+<script type="text/javascript" src="[% ctx.media_prefix %]/js/dojo/dojo/dojo.js?[% ctx.eg_cache_hash %]"></script>
+<script type="text/javascript" src="[% ctx.media_prefix %]/js/dojo/opensrf/opensrf.js?[% ctx.eg_cache_hash %]"></script>
+<script type="text/javascript" src="[% ctx.media_prefix %]/js/dojo/dojo/openils_dojo.js?[% ctx.eg_cache_hash %]"></script>
+
+[% IF use_autosuggest.enabled == "t"; %]
+<script type="text/javascript">
+dojo.require("fieldmapper.dojoData");
+dojo.require("openils.widget.AutoSuggest");
+</script>
+[% END; # use_autosuggest %]
+
+[%- END; # want_dojo -%]
{value => "series", label => l("Series")},
{value => "id|bibcn", label => l("Bib Call Number")}
] %]
-<select name="qtype">
+<select name="qtype"[% IF id; ' id="'; id ; '"' ; END %]>
[% query_type = query_type || CGI.param('qtype');
FOR qt IN query_types -%]
<option value='[% qt.value | html %]'[%
l(' for ');
%]
<span class='search_box_wrapper'>
- <input type="text" id="search_box" name="query" value="[% is_advanced ? ctx.processed_search_query : CGI.param('query') || l("Search Keyword") | html %]"
- onfocus="if (this.value=='[% l("Search Keyword") %]'){this.value='';this.style.color='#000';}"
- onblur="if (this.value==''){this.value='[% l("Search Keyword") %]';this.style.color='#999';}"
+ <input
+ [%- IF use_autosuggest.enabled == "t" %]
+ dojoType="openils.widget.AutoSuggest" type_selector="qtype"
+ submitter="this.textbox.form.submit();"
+ [%- IF use_autosuggest.value.search('opac_visible') %]
+ store_args='{"org_unit_getter": function() { return [% ctx.search_ou %]; }}'
+ [%- END -%]
+ [%- END -%] type="text" id="search_box" name="query"
+ value="[% is_advanced ? ctx.processed_search_query : CGI.param('query') | html %]"
x-webkit-speech />
</span>
- [%- INCLUDE "opac/parts/qtype_selector.tt2";
+ [%- INCLUDE "opac/parts/qtype_selector.tt2" id="qtype";
l(' in '); PROCESS build_org_selector name='loc' value=ctx.search_ou;
%]
<span>
.result-bookbag-description { font-size: 120%; font-style: italic; }
.result-bookbag-item-note { font-style: italic; }
.lowhits-bookbag-name { font-weight: bold; }
+.oils_AS { font-weight: bold; color: #c00; }
+.oils_AS_match_term { text-align: left; color: #000; }
+.oils_AS_match_field {
+ font-size: 75%; padding: 0.65em 0;
+ text-align: right; color: #666;
+}
"postMixInProperties": function() {
this.inherited(arguments);
+ if (typeof this.submitter == "string")
+ this.submitter = dojo.hitch(this, this.submitter);
+
/* Save the instantiator from needing to specify same thing
* twice, even though we need it and the store needs it too.
*/