From a81bd1437b278fe6d71bf5b0eacef1df32a0ab4f Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Fri, 6 Oct 2017 15:14:20 -0400 Subject: [PATCH] patch against Evergreen to grab data from bucket to feed a carousel --- carousel/custom_carousel.patch | 64 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 64 insertions(+), 0 deletions(-) create mode 100644 carousel/custom_carousel.patch diff --git a/carousel/custom_carousel.patch b/carousel/custom_carousel.patch new file mode 100644 index 0000000..b1a4e94 --- /dev/null +++ b/carousel/custom_carousel.patch @@ -0,0 +1,64 @@ +diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +index 6aa1f58..08074e1 100644 +--- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm ++++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +@@ -15,6 +15,7 @@ use OpenILS::Utils::Fieldmapper; + use DateTime::Format::ISO8601; + use CGI qw(:all -utf8); + use Time::HiRes; ++use Net::HTTP::NB; + + # EGCatLoader sub-modules + use OpenILS::WWW::EGCatLoader::Util; +@@ -128,7 +129,7 @@ sub load { + (undef, $self->ctx->{mylist}) = $self->fetch_mylist unless + $path =~ /opac\/my(opac\/lists|list)/; + +- return $self->load_simple("home") if $path =~ m|opac/home|; ++ return $self->load_home("home") if $path =~ m|opac/home|; + return $self->load_simple("css") if $path =~ m|opac/css|; + return $self->load_simple("advanced") if + $path =~ m:opac/(advanced|numeric|expert):; +@@ -250,6 +251,42 @@ sub load_simple { + return Apache2::Const::OK; + } + ++sub load_home { ++ my ($self, $page) = @_; ++ $self->ctx->{page} = $page; ++ $self->ctx->{search_ou} = $self->_get_search_lib(); ++ ++ my $req = Net::HTTP::NB->new( ++ Host => '127.0.0.1', Timeout => 1, PeerPort => 80); ++ if (!$req) { ++ $logger->warn("Unable to connect look up bookbag"); ++ } else { ++ $req->host($self->apache->hostname); ++ $req->write_request(GET => "/opac/extras/feed/bookbag/marcxml/12"); ++ my $sel = IO::Select->new($req); ++ if ($sel->can_read(3)) { ++ my ($code) = $req->read_response_headers; ++ ++ my $content = ''; ++ if ($code eq '200') { ++ while (1) { ++ my $buf; ++ my $n = $req->read_entity_body($buf, 1024); ++ last unless $n; ++ $content .= $buf; ++ } ++ $self->ctx->{carousel} = []; ++ while ($content =~ m!()!gs) { ++ push @{ $self->ctx->{carousel} }, (new XML::LibXML)->parse_string($1); ++ } ++ } ++ } ++ $req->shutdown(2); ++ } ++ ++ return Apache2::Const::OK; ++} ++ + # ----------------------------------------------------------------------------- + # Tests to see if the user is authenticated and sets some common context values + # ----------------------------------------------------------------------------- -- 1.7.2.5