From c63f5793bbdb614c8bdb162c72246a53935d6397 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 29 Dec 2005 19:42:33 +0000 Subject: [PATCH] OpenILS::Application::Search::AddedContent is now just a dummy file that returns empty sets for all methods. The real added content code now lives in the Evergreen tree in vendor-specific modules (only ContentCafe for now) The added content handler is defined in the config file. If not defined the default is used git-svn-id: svn://svn.open-ils.org/ILS/trunk@2551 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Evergreen/Makefile | 5 + Open-ILS/examples/openils.xml.example | 13 ++ .../perlmods/OpenILS/Application/Search.pm | 21 ++- .../Application/Search/AddedContent.pm | 163 ++---------------- Open-ILS/web/opac/common/js/added_content.js | 9 +- 5 files changed, 59 insertions(+), 152 deletions(-) diff --git a/Evergreen/Makefile b/Evergreen/Makefile index cfe31c1622..97124b13e6 100644 --- a/Evergreen/Makefile +++ b/Evergreen/Makefile @@ -26,6 +26,11 @@ xul: find local_staff_client/ -type f -exec sed -i s/gapines.org/${NEW_OPAC_URL}/g {} \; make -C local_staff_client package +perl-install: + @echo $@ + mkdir -p $(PERLDIR) + cp -r src/perlmods/* $(PERLDIR) + circ-install: @echo $@ mkdir -p $(CIRCRULESDIR) diff --git a/Open-ILS/examples/openils.xml.example b/Open-ILS/examples/openils.xml.example index 56c1f25d97..15631c7ee5 100644 --- a/Open-ILS/examples/openils.xml.example +++ b/Open-ILS/examples/openils.xml.example @@ -147,6 +147,19 @@ For non-core config info, see the inline documentation within this file 127.0.0.1:10101 3600 oilsMARC21slim2HTML.xsl + + + + + diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search.pm index 1d2dc506fe..87652f9169 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search.pm @@ -2,6 +2,7 @@ package OpenILS::Application::Search; use base qw/OpenSRF::Application/; use strict; use warnings; use JSON; +use OpenSRF::Utils::Logger qw(:logger); use OpenILS::Utils::Fieldmapper; use OpenILS::Utils::ModsParser; @@ -14,7 +15,7 @@ use OpenILS::Application::Search::Biblio; use OpenILS::Application::Search::Authority; use OpenILS::Application::Search::Actor; use OpenILS::Application::Search::Z3950; -use OpenILS::Application::Search::AddedContent; + use OpenILS::Application::AppUtils; @@ -28,7 +29,23 @@ use Text::Aspell; # spell checking... sub initialize { OpenILS::Application::Search::Z3950->initialize(); - OpenILS::Application::Search::AddedContent->initialize(); + + # try to load the added content handler + my $conf = OpenSRF::Utils::SettingsClient->new; + my $implementation = $conf->config_value( + "apps", "open-ils.search","app_settings", "added_content", "implementation" ); + + if($implementation) { + eval "use $implementation"; + if($@) { + $logger->error("Unable to load Added Content handler: $@"); + return; + } + $implementation->initialize(); + + } else { #if none is defined, use the default which returns empty sets + eval "use OpenILS::Application::Search::AddedContent"; + } } sub filter_search { diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm b/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm index 75981a3420..6c5ec17eb3 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Search/AddedContent.pm @@ -1,117 +1,37 @@ package OpenILS::Application::Search::AddedContent; use base qw/OpenSRF::Application/; use strict; use warnings; -use OpenILS::Application::AppUtils; -use OpenSRF::Utils::SettingsClient; -my $apputils = "OpenILS::Application::AppUtils"; -use XML::LibXML; -use LWP::UserAgent; -use OpenSRF::EX qw(:try); - -my $host; -my $username; -my $password; -my $enabled = 0; -my $urlbase = "ContentCafe"; -my $types = { - toc => "TOC.asmx", - review => "Review.asmx", - annotation => "Annotation.asmx", - member => "Member.asmx", - }; - -sub initialize { - my $conf = OpenSRF::Utils::SettingsClient->new; - $host = $conf->config_value( - "apps", "open-ils.search","app_settings", "added_content", "host"); - $username = $conf->config_value( - "apps", "open-ils.search","app_settings", "added_content", "username"); - $password = $conf->config_value( - "apps", "open-ils.search","app_settings", "added_content", "password"); - - $enabled = 1 if ($host and $username and $password); -} - - - -# Fetches the added content and returns the data as a string. -# If not data is retrieved (or timeout occurs), undef is returned -sub retrieve_added_content { - my( $type, $isbn, $summary ) = @_; - return undef unless ( $isbn && $isbn ne "" ); - - my $func = "fnDetailByItemKey"; - if($summary) { $func = "fnContentByItemKey"; } - - my $url = "$host/$urlbase/" . $types->{$type} . - "/$func?UserId=$username&Password=$password&ItemKey=$isbn"; - warn "Added Content URL: $url\n"; - - my $data = undef; - try { - alarm(15); - $data = LWP::UserAgent->new->get($url)->content; - alarm(0); - } catch Error with { - alarm(0); - }; - alarm(0); - -# warn "received content data:\n$data\n"; - return $data; -} - __PACKAGE__->register_method( method => "summary", api_name => "open-ils.search.added_content.summary.retrieve", notes => <<" NOTE"); Returns an object like so: { - Review : true/false, - Inventory : true/false, - Annotation : true/false, - Jacket : true/false - TOC : true/false - Product : true/false + Review : true/false + Inventory : true/false + Annotation : true/false + Jacket : true/false + TOC : true/false + Product : true/false } This object indicates the existance of each type of added content for the given ISBN PARAMS( ISBN ), NOTE sub summary { - my( $self, $client, $isbn ) = @_; - - if(!$enabled) { - return { - Review => "false", - Inventory => "false", - Annotation => "false", - Jacket => "false", - TOC => "false", - Product => "false", - }; - } - - my $data = retrieve_added_content( "member", $isbn, 1 ); - return {} unless $data; - my $doc = XML::LibXML->new->parse_string($data); - my $summary = {}; - return $summary unless $doc; - - for my $node ( $doc->getDocumentElement->childNodes ) { - if( $node->localName ) { - $summary->{$node->localName} = $node->textContent; - } - } - return $summary; + return { + Review => "false", + Inventory => "false", + Annotation => "false", + Jacket => "false", + TOC => "false", + Product => "false", + }; } - - - __PACKAGE__->register_method( method => "reviews", api_name => "open-ils.search.added_content.review.retrieve.random", @@ -128,44 +48,7 @@ __PACKAGE__->register_method( PARAMS( ISBN ), NOTE -sub reviews { - my( $self, $client, $isbn ) = @_; - - my $ret = []; - return $ret unless $enabled; - my $data = retrieve_added_content( "review", $isbn ); - return $ret unless $data; - my $doc = XML::LibXML->new->parse_string($data); - - - if(!$doc) { - if( $self->api_name =~ /random/ ) { return undef; } - return $ret; - } - - my $reviews = $doc->findnodes("//*[local-name()='Review']"); - - for my $rev ( $reviews->get_nodelist() ) { - my $revobj = {}; - for my $node ($rev->childNodes) { - - if( $node->localName ) { - if( $node->localName eq "ReviewText" ) { - $revobj ->{'text'} = $node->textContent; - } - if( $node->localName eq "ReviewLiteral" ) { - $revobj->{'info'} = $node->textContent; - } - - } - } - - if( $self->api_name =~ /random/ ) { return $revobj; } - push( @$ret, $revobj ); - } - - return $ret; -} +sub reviews { return []; } __PACKAGE__->register_method( @@ -176,21 +59,7 @@ __PACKAGE__->register_method( PARAMS( ISBN ), NOTE -sub toc { - my( $self, $client, $isbn ) = @_; - - my $data = retrieve_added_content( "toc", $isbn ); - return undef unless $data; - my $doc = XML::LibXML->new->parse_string($data); - - my @nodes = $doc->findnodes("//*[local-name()='TOCText']")->get_nodelist(); - - if($nodes[0]) { - return $nodes[0]->textContent; - } - - return ""; -} +sub toc { return ""; } 1; diff --git a/Open-ILS/web/opac/common/js/added_content.js b/Open-ILS/web/opac/common/js/added_content.js index 5ec7d1e61e..5bc352ed2e 100644 --- a/Open-ILS/web/opac/common/js/added_content.js +++ b/Open-ILS/web/opac/common/js/added_content.js @@ -1,5 +1,8 @@ -// This example function uses amazon to get cover art +/** +* 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) { return "http://images.amazon.com/images/P/" + isbn + ".01._SCMZZZZZZZ_.jpg"; -} - +} -- 2.43.2