[open-ils-commits] r7750 - in trunk/Open-ILS: examples
src/perlmods/OpenILS/WWW/AddedContent
svn at svn.open-ils.org
svn at svn.open-ils.org
Thu Aug 30 09:02:58 EDT 2007
Author: erickson
Date: 2007-08-30 08:56:54 -0400 (Thu, 30 Aug 2007)
New Revision: 7750
Added:
trunk/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm
Modified:
trunk/Open-ILS/examples/opensrf.xml.example
Log:
added a basic Amazon plugin so that new installs can use this module by default for fetching images. updated default config with amazon plus docs
Modified: trunk/Open-ILS/examples/opensrf.xml.example
===================================================================
--- trunk/Open-ILS/examples/opensrf.xml.example 2007-08-29 21:54:43 UTC (rev 7749)
+++ trunk/Open-ILS/examples/opensrf.xml.example 2007-08-30 12:56:54 UTC (rev 7750)
@@ -135,15 +135,38 @@
<added_content>
- <!-- configure an added content plugin -->
+
+ <!-- XXX If you use the Amazon plugin, you must link back to Amazon in the OPAC -->
+
+ <!-- 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>
- <retry_timeout>600</retry_timeout>
- <max_errors>5</max_errors>
+ You can add free-form settings here and they will be accessible
+ within the added content module
-->
+
</added_content>
Added: trunk/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm (rev 0)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm 2007-08-30 12:56:54 UTC (rev 7750)
@@ -0,0 +1,134 @@
+package OpenILS::WWW::AddedContent::Amazon;
+use strict; use warnings;
+use OpenSRF::Utils::Logger qw/$logger/;
+use OpenSRF::Utils::SettingsParser;
+use OpenILS::WWW::AddedContent;
+use OpenSRF::Utils::JSON;
+use OpenSRF::EX qw/:try/;
+use XML::LibXML;
+
+my $AC = 'OpenILS::WWW::AddedContent';
+
+sub new {
+ my( $class, $args ) = @_;
+ $class = ref $class || $class;
+ return bless($args, $class);
+}
+
+sub base_url {
+ my $self = shift;
+ return $self->{base_url};
+}
+
+sub userid {
+ my $self = shift;
+ return $self->{userid};
+}
+
+
+# --------------------------------------------------------------------------
+sub jacket_small {
+ my( $self, $key ) = @_;
+ return $self->send_img(
+ $self->fetch_response('_SCMZZZZZZZ_.jpg', $key));
+}
+
+sub jacket_medium {
+ my( $self, $key ) = @_;
+ return $self->send_img(
+ $self->fetch_response('_SCMZZZZZZZ_.jpg', $key));
+
+}
+sub jacket_large {
+ my( $self, $key ) = @_;
+ return $self->send_img(
+ $self->fetch_response('_SCZZZZZZZ_.jpg', $key));
+}
+
+# --------------------------------------------------------------------------
+
+sub toc_html {
+ my( $self, $key ) = @_;
+}
+
+sub toc_xml {
+ my( $self, $key ) = @_;
+}
+
+sub toc_json {
+ my( $self, $key ) = @_;
+}
+
+# --------------------------------------------------------------------------
+
+sub anotes_html {
+ my( $self, $key ) = @_;
+}
+
+sub anotes_xml {
+ my( $self, $key ) = @_;
+}
+
+sub anotes_json {
+ my( $self, $key ) = @_;
+}
+
+
+# --------------------------------------------------------------------------
+
+sub excerpt_html {
+ my( $self, $key ) = @_;
+}
+
+sub excerpt_xml {
+ my( $self, $key ) = @_;
+}
+
+sub excerpt_json {
+ my( $self, $key ) = @_;
+}
+
+# --------------------------------------------------------------------------
+
+sub reviews_html {
+ my( $self, $key ) = @_;
+}
+
+# we have to aggregate the reviews
+sub reviews_xml {
+ my( $self, $key ) = @_;
+}
+
+
+sub reviews_json {
+ my( $self, $key ) = @_;
+}
+
+# --------------------------------------------------------------------------
+
+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 ) = @_;
+ return $self->fetch_response($page, $key)->content;
+}
+
+# returns the HTTP response object from the URL fetch
+sub fetch_response {
+ my( $self, $page, $key ) = @_;
+ my $uname = $self->userid;
+ my $url = $self->base_url . "$key.01.$page";
+ return $AC->get_url($url);
+}
+
+
+
+1;
More information about the open-ils-commits
mailing list