From: erickson Date: Thu, 30 Aug 2007 12:56:54 +0000 (+0000) Subject: added a basic Amazon plugin so that new installs can use this module by default for... X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=006fad133f3a5af4aa7d9cae1eab38720554b1a5;p=Evergreen.git 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 git-svn-id: svn://svn.open-ils.org/ILS/trunk@7750 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/examples/opensrf.xml.example b/Open-ILS/examples/opensrf.xml.example index 30ec0edb68..cbfe6a231c 100644 --- a/Open-ILS/examples/opensrf.xml.example +++ b/Open-ILS/examples/opensrf.xml.example @@ -135,15 +135,38 @@ Example opensrf config file for OpenILS - - + + + OpenILS::WWW::AddedContent::Amazon + + http://images.amazon.com/images/P/ + + + 4 + + 600 - 5 + + + 4 + + + MY_USER_ID + + + diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm new file mode 100644 index 0000000000..86c19c65f5 --- /dev/null +++ b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Amazon.pm @@ -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;