[open-ils-commits] r8076 - in branches/rel_1_2/Open-ILS: examples
examples/apache src/perlmods/OpenILS/WWW
src/perlmods/OpenILS/WWW/AddedContent web/opac/common/js
svn at svn.open-ils.org
svn at svn.open-ils.org
Fri Nov 16 16:33:12 EST 2007
Author: erickson
Date: 2007-11-16 16:16:10 -0500 (Fri, 16 Nov 2007)
New Revision: 8076
Modified:
branches/rel_1_2/Open-ILS/examples/apache/eg_vhost.conf
branches/rel_1_2/Open-ILS/examples/opensrf.xml.example
branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm
branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm
branches/rel_1_2/Open-ILS/web/opac/common/js/added_content.js
Log:
Back-porting:
added content caching layer
added content error handling logic (X errors disables added content lookups for Y seconds)
added image fetching logic to Syndetic plugin
pulling images from added content url
updated exmaple configs
Modified: branches/rel_1_2/Open-ILS/examples/apache/eg_vhost.conf
===================================================================
--- branches/rel_1_2/Open-ILS/examples/apache/eg_vhost.conf 2007-11-16 16:44:59 UTC (rev 8075)
+++ branches/rel_1_2/Open-ILS/examples/apache/eg_vhost.conf 2007-11-16 21:16:10 UTC (rev 8076)
@@ -15,20 +15,20 @@
# ----------------------------------------------------------------------------------
OSRFGatewayConfig /openils/conf/opensrf_core.xml
-
# ----------------------------------------------------------------------------------
# Set up the book jackets URL
-# XXX This pulls images from Amazon, don't use this in a production environment
+# This is an example of how you can have bookjacket images via Apache redirect,
+# if there is no full-fledged added content plugin for the site you want to
+# fetch images from.
# ----------------------------------------------------------------------------------
-RewriteEngine on
-ProxyTimeout 2
-RewriteRule /opac/extras/jacket/small/(.*) \
- http://images.amazon.com/images/P/$1.01._SCMZZZZZZZ_.jpg [P,L]
-RewriteRule /opac/extras/jacket/large/(.*) \
- http://images.amazon.com/images/P/$1.01._SCLZZZZZZZ_.jpg [P,L]
+#RewriteEngine on
+#ProxyTimeout 2
+#RewriteRule /opac/extras/ac/jacket/small/(.*) \
+# http://images.amazon.com/images/P/$1.01._SCMZZZZZZZ_.jpg [P,L]
+#RewriteRule /opac/extras/ac/jacket/large/(.*) \
+# http://images.amazon.com/images/P/$1.01._SCLZZZZZZZ_.jpg [P,L]
-
# ----------------------------------------------------------------------------------
# Added content plugin
# ----------------------------------------------------------------------------------
Modified: branches/rel_1_2/Open-ILS/examples/opensrf.xml.example
===================================================================
--- branches/rel_1_2/Open-ILS/examples/opensrf.xml.example 2007-11-16 16:44:59 UTC (rev 8075)
+++ branches/rel_1_2/Open-ILS/examples/opensrf.xml.example 2007-11-16 21:16:10 UTC (rev 8076)
@@ -133,19 +133,40 @@
</services>
</z3950>
+ <added_content>
- <added_content>
- <!-- configure an added content plugin -->
+ <!-- load the Amazon added content module -->
+ <module>OpenILS::WWW::AddedContent::Amazon</module>
+ <!-- Base URL for Amazon added content fetching. This URL may
+ need to be shortened when new (read: non-image) content
+ fetching capabilities are added -->
+ <base_url>http://images.amazon.com/images/P/</base_url>
+
+ <!-- Max number of seconds to wait for an added content request to
+ return data. Data not returned within the timeout is considered
+ a failure -->
+ <timeout>4</timeout>
+
+ <!-- After added content lookups have been disabled due to too many
+ lookup failures, this is the amount of time to wait before
+ we try again -->
+ <retry_timeout>600</retry_timeout>
+
+ <!-- maximum number of consecutive lookup errors a given process can
+ have before added content lookups are disabled for everyone -->
+ <max_errors>4</max_errors>
+
+ <!-- If a userid is required to access the added content.. -->
+ <userid>MY_USER_ID</userid>
+
<!--
- <module>OpenILS::WWW::AddedContent::MY_MODULE</module>
- <userid>MY_USER_ID</userid>
- <base_url>MY_BASE_URL</base_url>
- <timeout>2</timeout>
+ You can add free-form settings here and they will be accessible
+ within the added content module
-->
+
</added_content>
-
<!-- no apps are enabled globally by default -->
<activeapps/>
Modified: branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm
===================================================================
--- branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm 2007-11-16 16:44:59 UTC (rev 8075)
+++ branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm 2007-11-16 21:16:10 UTC (rev 8076)
@@ -1,232 +1,262 @@
package OpenILS::WWW::AddedContent::Syndetic;
use strict; use warnings;
-use LWP::UserAgent;
use OpenSRF::Utils::Logger qw/$logger/;
use OpenSRF::Utils::SettingsParser;
use OpenSRF::Utils::JSON;
use OpenSRF::EX qw/:try/;
use OpenILS::WWW::AddedContent;
+use XML::LibXML;
+use MIME::Base64;
+my $AC = 'OpenILS::WWW::AddedContent';
sub new {
- my( $class, $args ) = @_;
- $class = ref $class || $class;
- return bless($args, $class);
+ my( $class, $args ) = @_;
+ $class = ref $class || $class;
+ return bless($args, $class);
}
sub base_url {
- my $self = shift;
- return $self->{base_url};
+ my $self = shift;
+ return $self->{base_url};
}
sub userid {
- my $self = shift;
- return $self->{userid};
+ my $self = shift;
+ return $self->{userid};
}
# --------------------------------------------------------------------------
+sub jacket_small {
+ my( $self, $key ) = @_;
+ return $self->send_img(
+ $self->fetch_response('sc.gif', $key, 1));
+}
+sub jacket_medium {
+ my( $self, $key ) = @_;
+ return $self->send_img(
+ $self->fetch_response('mc.gif', $key, 1));
+
+}
+sub jacket_large {
+ my( $self, $key ) = @_;
+ return $self->send_img(
+ $self->fetch_response('lc.gif', $key, 1));
+}
+
+# --------------------------------------------------------------------------
+
sub toc_html {
- my( $self, $key ) = @_;
- return $self->send_html(
- $self->fetch_content('toc.html', $key));
+ my( $self, $key ) = @_;
+ return $self->send_html(
+ $self->fetch_content('toc.html', $key));
}
sub toc_xml {
- my( $self, $key ) = @_;
- return $self->send_xml(
- $self->fetch_content('toc.xml', $key));
+ my( $self, $key ) = @_;
+ return $self->send_xml(
+ $self->fetch_content('toc.xml', $key));
}
sub toc_json {
- my( $self, $key ) = @_;
- return $self->send_json(
- $self->fetch_content('toc.xml', $key));
+ my( $self, $key ) = @_;
+ return $self->send_json(
+ $self->fetch_content('toc.xml', $key));
}
# --------------------------------------------------------------------------
sub anotes_html {
- my( $self, $key ) = @_;
- return $self->send_html(
- $self->fetch_content('anotes.html', $key));
+ my( $self, $key ) = @_;
+ return $self->send_html(
+ $self->fetch_content('anotes.html', $key));
}
sub anotes_xml {
- my( $self, $key ) = @_;
- return $self->send_xml(
- $self->fetch_content('anotes.xml', $key));
+ my( $self, $key ) = @_;
+ return $self->send_xml(
+ $self->fetch_content('anotes.xml', $key));
}
sub anotes_json {
- my( $self, $key ) = @_;
- return $self->send_json(
- $self->fetch_content('anotes.xml', $key));
+ my( $self, $key ) = @_;
+ return $self->send_json(
+ $self->fetch_content('anotes.xml', $key));
}
# --------------------------------------------------------------------------
sub excerpt_html {
- my( $self, $key ) = @_;
- return $self->send_html(
- $self->fetch_content('dbchapter.html', $key));
+ my( $self, $key ) = @_;
+ return $self->send_html(
+ $self->fetch_content('dbchapter.html', $key));
}
sub excerpt_xml {
- my( $self, $key ) = @_;
- return $self->send_xml(
- $self->fetch_content('dbchapter.xml', $key));
+ my( $self, $key ) = @_;
+ return $self->send_xml(
+ $self->fetch_content('dbchapter.xml', $key));
}
sub excerpt_json {
- my( $self, $key ) = @_;
- return $self->send_json(
- $self->fetch_content('dbchapter.xml', $key));
+ my( $self, $key ) = @_;
+ return $self->send_json(
+ $self->fetch_content('dbchapter.xml', $key));
}
# --------------------------------------------------------------------------
sub reviews_html {
- my( $self, $key ) = @_;
+ my( $self, $key ) = @_;
- my %reviews;
+ my %reviews;
- $reviews{ljreview} = $self->fetch_content('ljreview.html', $key);
- $reviews{pwreview} = $self->fetch_content('pwreview.html', $key);
- $reviews{slreview} = $self->fetch_content('slreview.html', $key);
- $reviews{chreview} = $self->fetch_content('chreview.html', $key);
- $reviews{blreview} = $self->fetch_content('blreview.html', $key);
- $reviews{hbreview} = $self->fetch_content('hbreview.html', $key);
- $reviews{kirkreview} = $self->fetch_content('kirkreview.html', $key);
+ $reviews{ljreview} = $self->fetch_content('ljreview.html', $key);
+ $reviews{pwreview} = $self->fetch_content('pwreview.html', $key);
+ $reviews{slreview} = $self->fetch_content('slreview.html', $key);
+ $reviews{chreview} = $self->fetch_content('chreview.html', $key);
+ $reviews{blreview} = $self->fetch_content('blreview.html', $key);
+ $reviews{hbreview} = $self->fetch_content('hbreview.html', $key);
+ $reviews{kirkreview} = $self->fetch_content('kirkreview.html', $key);
- for(keys %reviews) {
- if( ! $self->data_exists($reviews{$_}) ) {
- delete $reviews{$_};
- next;
- }
- $reviews{$_} =~ s/<!.*?>//og; # Strip any doctype declarations
- }
+ for(keys %reviews) {
+ if( ! $self->data_exists($reviews{$_}) ) {
+ delete $reviews{$_};
+ next;
+ }
+ $reviews{$_} =~ s/<!.*?>//og; # Strip any doctype declarations
+ }
- return 0 if scalar(keys %reviews) == 0;
-
- #my $html = "<div>";
- my $html;
- $html .= $reviews{$_} for keys %reviews;
- #$html .= "</div>";
+ return 0 if scalar(keys %reviews) == 0;
+
+ #my $html = "<div>";
+ my $html;
+ $html .= $reviews{$_} for keys %reviews;
+ #$html .= "</div>";
- return $self->send_html($html);
+ return $self->send_html($html);
}
# we have to aggregate the reviews
sub reviews_xml {
- my( $self, $key ) = @_;
- my %reviews;
+ my( $self, $key ) = @_;
+ my %reviews;
- $reviews{ljreview} = $self->fetch_content('ljreview.xml', $key);
- $reviews{pwreview} = $self->fetch_content('pwreview.xml', $key);
- $reviews{slreview} = $self->fetch_content('slreview.xml', $key);
- $reviews{chreview} = $self->fetch_content('chreview.xml', $key);
- $reviews{blreview} = $self->fetch_content('blreview.xml', $key);
- $reviews{hbreview} = $self->fetch_content('hbreview.xml', $key);
- $reviews{kirkreview} = $self->fetch_content('kirkreview.xml', $key);
+ $reviews{ljreview} = $self->fetch_content('ljreview.xml', $key);
+ $reviews{pwreview} = $self->fetch_content('pwreview.xml', $key);
+ $reviews{slreview} = $self->fetch_content('slreview.xml', $key);
+ $reviews{chreview} = $self->fetch_content('chreview.xml', $key);
+ $reviews{blreview} = $self->fetch_content('blreview.xml', $key);
+ $reviews{hbreview} = $self->fetch_content('hbreview.xml', $key);
+ $reviews{kirkreview} = $self->fetch_content('kirkreview.xml', $key);
- for(keys %reviews) {
- if( ! $self->data_exists($reviews{$_}) ) {
- delete $reviews{$_};
- next;
- }
- # Strip the xml and doctype declarations
- $reviews{$_} =~ s/<\?xml.*?>//og;
- $reviews{$_} =~ s/<!.*?>//og;
- }
+ for(keys %reviews) {
+ if( ! $self->data_exists($reviews{$_}) ) {
+ delete $reviews{$_};
+ next;
+ }
+ # Strip the xml and doctype declarations
+ $reviews{$_} =~ s/<\?xml.*?>//og;
+ $reviews{$_} =~ s/<!.*?>//og;
+ }
- return 0 if scalar(keys %reviews) == 0;
-
- my $xml = "<reviews>";
- $xml .= $reviews{$_} for keys %reviews;
- $xml .= "</reviews>";
+ return 0 if scalar(keys %reviews) == 0;
+
+ my $xml = "<reviews>";
+ $xml .= $reviews{$_} for keys %reviews;
+ $xml .= "</reviews>";
- return $self->send_xml($xml);
+ return $self->send_xml($xml);
}
sub reviews_json {
- my( $self, $key ) = @_;
- return $self->send_json(
- $self->fetch_content('dbchapter.xml', $key));
+ my( $self, $key ) = @_;
+ return $self->send_json(
+ $self->fetch_content('dbchapter.xml', $key));
}
# --------------------------------------------------------------------------
sub data_exists {
- my( $self, $data ) = @_;
- return 0 if $data =~ m/<title>error<\/title>/iog;
- return 1;
+ my( $self, $data ) = @_;
+ return 0 if $data =~ m/<title>error<\/title>/iog;
+ return 1;
}
sub send_json {
- my( $self, $xml ) = @_;
- return 0 unless $self->data_exists($xml);
- my $doc;
+ my( $self, $xml ) = @_;
+ return 0 unless $self->data_exists($xml);
+ my $doc;
- try {
- $doc = XML::LibXML->new->parse_string($xml);
- } catch Error with {
- my $err = shift;
- $logger->error("added content XML parser error: $err\n\n$xml");
- $doc = undef;
- };
+ try {
+ $doc = XML::LibXML->new->parse_string($xml);
+ } catch Error with {
+ my $err = shift;
+ $logger->error("added content XML parser error: $err\n\n$xml");
+ $doc = undef;
+ };
- return 0 unless $doc;
- my $perl = OpenSRF::Utils::SettingsParser::XML2perl($doc->documentElement);
- my $json = OpenSRF::Utils::JSON->perl2JSON($perl);
- print "Content-type: text/plain\n\n";
- print $json;
- return 1;
+ return 0 unless $doc;
+ my $perl = OpenSRF::Utils::SettingsParser::XML2perl($doc->documentElement);
+ my $json = OpenSRF::Utils::JSON->perl2JSON($perl);
+ return { content_type => 'text/plain', content => $json };
}
sub send_xml {
- my( $self, $xml ) = @_;
- return 0 unless $self->data_exists($xml);
- print "Content-Type: application/xml\n\n";
- print $xml;
- return 1;
+ my( $self, $xml ) = @_;
+ return 0 unless $self->data_exists($xml);
+ return { content_type => 'application/xml', content => $xml };
}
sub send_html {
- my( $self, $content ) = @_;
- return 0 unless $self->data_exists($content);
+ my( $self, $content ) = @_;
+ return 0 unless $self->data_exists($content);
- # Hide anything that might contain a link since it will be broken
- my $HTML = <<" HTML";
- <div>
- <style type='text/css'>
- div.ac input, div.ac a[href],div.ac img, div.ac button { display: none; visibility: hidden }
- </style>
- <div class='ac'>
- $content
- </div>
- </div>
- HTML
+ # Hide anything that might contain a link since it will be broken
+ my $HTML = <<" HTML";
+ <div>
+ <style type='text/css'>
+ div.ac input, div.ac a[href],div.ac img, div.ac button { display: none; visibility: hidden }
+ </style>
+ <div class='ac'>
+ $content
+ </div>
+ </div>
+ HTML
- print "Content-type: text/html\n\n";
- print $HTML;
+ return { content_type => 'text/html', content => $HTML };
+}
- return 1;
+sub send_img {
+ my($self, $response) = @_;
+ return {
+ content_type => $response->header('Content-type'),
+ content => $response->content,
+ binary => 1
+ };
}
+# returns the raw content returned from the URL fetch
sub fetch_content {
- my( $self, $page, $key ) = @_;
- my $uname = $self->userid;
- my $url = $self->base_url . "?isbn=$key/$page&client=$uname&type=rw12";
- return OpenILS::WWW::AddedContent->get_url($url);
+ my( $self, $page, $key ) = @_;
+ return $self->fetch_response($page, $key)->content;
}
+# returns the HTTP response object from the URL fetch
+sub fetch_response {
+ my( $self, $page, $key, $notype ) = @_;
+ my $uname = $self->userid;
+ my $url = $self->base_url . "?isbn=$key/$page&client=$uname" . (($notype) ? '' : "&type=rw12");
+ return $AC->get_url($url);
+}
+
1;
Modified: branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm
===================================================================
--- branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm 2007-11-16 16:44:59 UTC (rev 8075)
+++ branches/rel_1_2/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm 2007-11-16 21:16:10 UTC (rev 8076)
@@ -16,100 +16,184 @@
use OpenSRF::Utils::Cache;
use OpenSRF::System;
use OpenSRF::Utils::Logger qw/$logger/;
-use XML::LibXML;
+use LWP::UserAgent;
+use MIME::Base64;
+my $AC = __PACKAGE__;
+
+
# set the bootstrap config when this module is loaded
my $bs_config;
-my $handler;
sub import {
- my $self = shift;
- $bs_config = shift;
+ my $self = shift;
+ $bs_config = shift;
}
-my $net_timeout;
-my $cache;
+my $handler; # added content handler class handle
+my $cache; # memcache handle
+my $net_timeout; # max seconds to wait for a response from the added content vendor
+my $max_errors; # max consecutive lookup failures before added content is temporarily disabled
+my $error_countdown; # current consecutive errors countdown
+
+# number of seconds to wait before next lookup
+# is attempted after lookups have been disabled
+my $error_retry_timeout;
+
+
sub child_init {
- OpenSRF::System->bootstrap_client( config_file => $bs_config );
+ OpenSRF::System->bootstrap_client( config_file => $bs_config );
+ $cache = OpenSRF::Utils::Cache->new;
- my $sclient = OpenSRF::Utils::SettingsClient->new();
- my $ac_data = $sclient->config_value("added_content");
+ my $sclient = OpenSRF::Utils::SettingsClient->new();
+ my $ac_data = $sclient->config_value("added_content");
return unless $ac_data;
+ my $ac_handler = $ac_data->{module};
+ return unless $ac_handler;
- $cache = OpenSRF::Utils::Cache->new;
+ $net_timeout = $ac_data->{timeout} || 1;
+ $error_countdown = $max_errors = $ac_data->{max_errors} || 10;
+ $error_retry_timeout = $ac_data->{retry_timeout} || 600;
- my $ac_handler = $ac_data->{module};
- $net_timeout = $ac_data->{timeout} || 3;
-
- return unless $ac_handler;
+ $logger->debug("Attempting to load Added Content handler: $ac_handler");
- $logger->debug("Attempting to load Added Content handler: $ac_handler");
+ eval "use $ac_handler";
- eval "use $ac_handler";
+ if($@) {
+ $logger->error("Unable to load Added Content handler [$ac_handler]: $@");
+ return;
+ }
- if($@) {
- $logger->error("Unable to load Added Content handler [$ac_handler]: $@");
- return;
- }
-
- $handler = $ac_handler->new($ac_data);
- $logger->debug("added content loaded handler: $handler");
+ $handler = $ac_handler->new($ac_data);
+ $logger->debug("added content loaded handler: $handler");
}
sub handler {
- my $r = shift;
- my $cgi = CGI->new;
- my $path = $r->path_info;
+ my $r = shift;
+ my $cgi = CGI->new;
+ my $path = $r->path_info;
+ my $res;
- child_init() unless $handler; # why isn't apache doing this for us?
- return Apache2::Const::NOT_FOUND unless $handler;
+ my( undef, $type, $format, $key ) = split(/\//, $r->path_info);
- # if this memcache key is set, added content lookups are disabled
- if( $cache->get_cache('ac.no_lookup') ) {
- $logger->info("added content lookup disabled");
- return Apache2::Const::NOT_FOUND;
+ child_init() unless $handler;
+
+ return Apache2::Const::NOT_FOUND unless $handler and $type and $format and $key;
+ return $res if defined($res = $AC->serve_from_cache($type, $format, $key));
+ return Apache2::Const::NOT_FOUND unless $AC->lookups_enabled;
+
+ my $err;
+ my $data;
+ my $method = "${type}_${format}";
+
+ return Apache2::Const::NOT_FOUND unless $handler->can($method);
+
+ try {
+ $data = $handler->$method($key);
+ } catch Error with {
+ $err = shift;
+ decr_error_countdown();
+ $logger->error("added content handler failed: $method($key) => $err");
+ };
+
+ return Apache2::Const::NOT_FOUND if $err;
+
+ if(!$data) {
+ # if the AC lookup found no corresponding data, cache that information
+ $logger->debug("added content handler returned no results $method($key)") unless $data;
+ $AC->cache_result($type, $format, $key, {nocontent=>1});
+ return Apache2::Const::NOT_FOUND;
}
+
+ $AC->print_content($data);
+ $AC->cache_result($type, $format, $key, $data);
+ reset_error_countdown();
+ return Apache2::Const::OK;
+}
- my( undef, $data, $format, $key ) = split(/\//, $r->path_info);
+sub print_content {
+ my($class, $data, $from_cache) = @_;
+ return Apache2::Const::NOT_FOUND if $data->{nocontent};
- my $err;
- my $success;
- my $method = "${data}_${format}";
+ my $ct = $data->{content_type};
+ my $content = $data->{content};
+ print "Content-type: $ct\n\n";
- try {
- $success = $handler->$method($key);
- } catch Error with {
- my $err = shift;
- $logger->error("added content handler failed: $method($key) => $err");
- };
+ if($data->{binary}) {
+ binmode STDOUT;
+ # if it hasn't been cached yet, it's still in binary form
+ print( ($from_cache) ? decode_base64($content) : $content );
+ } else {
+ print $content;
+ }
- return Apache2::Const::NOT_FOUND if $err or !$success;
- return Apache2::Const::OK;
+
+ return Apache2::Const::OK;
}
-# generic GET call
+
+# returns an HTPP::Response object
sub get_url {
- my( $self, $url ) = @_;
- $logger->info("added content getting [timeout=$net_timeout] URL = $url");
- my $agent = LWP::UserAgent->new(timeout => $net_timeout);
- my $res = $agent->get($url);
- die "added content request failed: " . $res->status_line ."\n" unless $res->is_success;
- return $res->content;
+ my( $self, $url ) = @_;
+
+ $logger->info("added content getting [timeout=$net_timeout, errors_remaining=$error_countdown] URL = $url");
+ my $agent = LWP::UserAgent->new(timeout => $net_timeout);
+
+ my $res = $agent->get($url);
+ $logger->info("added content request returned with code " . $res->code);
+ die "added content request failed: " . $res->status_line ."\n" unless $res->is_success;
+
+ return $res;
}
+sub lookups_enabled {
+ if( $cache->get_cache('ac.no_lookup') ) {
+ $logger->info("added content lookup disabled");
+ return undef;
+ }
+ return 1;
+}
+sub disable_lookups {
+ $cache->put_cache('ac.no_lookup', 1, $error_retry_timeout);
+}
+sub decr_error_countdown {
+ $error_countdown--;
+ if($error_countdown < 1) {
+ $logger->warn("added content error count exhausted. Disabling lookups for $error_retry_timeout seconds");
+ $AC->disable_lookups;
+ }
+}
+sub reset_error_countdown {
+ $error_countdown = $max_errors;
+}
+sub cache_result {
+ my($class, $type, $format, $key, $data) = @_;
+ $logger->debug("caching $type/$format/$key");
+ $data->{content} = encode_base64($data->{content}) if $data->{binary};
+ return $cache->put_cache("ac.$type.$format.$key", $data);
+}
+sub serve_from_cache {
+ my($class, $type, $format, $key) = @_;
+ my $data = $cache->get_cache("ac.$type.$format.$key");
+ return undef unless $data;
+ $logger->debug("serving $type/$format/$key from cache");
+ return $class->print_content($data, 1);
+}
+
+
+
1;
-
Modified: branches/rel_1_2/Open-ILS/web/opac/common/js/added_content.js
===================================================================
--- branches/rel_1_2/Open-ILS/web/opac/common/js/added_content.js 2007-11-16 16:44:59 UTC (rev 8075)
+++ branches/rel_1_2/Open-ILS/web/opac/common/js/added_content.js 2007-11-16 21:16:10 UTC (rev 8076)
@@ -1,18 +1,16 @@
/**
* This function should return a URL which points to the book cover image based on ISBN.
-* Ideally, this should point to some type of added content service.
-* The example below uses Amazon... *use at own risk*
*/
+
function buildISBNSrc(isbn, size) {
size = (size) ? size : 'small';
if(OILS_OPAC_IMAGES_HOST)
return location.protocol + '//' + OILS_OPAC_IMAGES_HOST + size + '/' + isbn;
- return '../../../../extras/jacket/'+size+'/'+isbn;
+ return '../../../../extras/ac/jacket/'+size+'/'+isbn;
}
-
function acMakeURL(type, key) {
return '../../../../extras/ac/' + type + '/html/' + key;
}
More information about the open-ils-commits
mailing list