patch against Evergreen to grab data from bucket to feed a carousel
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 6 Oct 2017 19:14:20 +0000 (15:14 -0400)
committerEquinox Support <equinox@eg-opac-skin.equinoxinitiative.org>
Fri, 6 Oct 2017 19:14:20 +0000 (15:14 -0400)
carousel/custom_carousel.patch [new file with mode: 0644]

diff --git a/carousel/custom_carousel.patch b/carousel/custom_carousel.patch
new file mode 100644 (file)
index 0000000..b1a4e94
--- /dev/null
@@ -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!(<record xmlns.*?</record>)!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
+ # -----------------------------------------------------------------------------