/[meteor]/trunk/Meteor/Koha.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/Meteor/Koha.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 70 by dpavlin, Sat Mar 28 03:45:31 2009 UTC revision 71 by dpavlin, Sat Mar 28 14:20:59 2009 UTC
# Line 7  use LWP::UserAgent; Line 7  use LWP::UserAgent;
7    
8  my $ua = LWP::UserAgent->new;  my $ua = LWP::UserAgent->new;
9    
10    our $cache;
11    
12  sub item {  sub item {
13          my ( $class, $client, $item ) = @_;          my ( $class, $client, $item ) = @_;
14    
15          my $url = 'http://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=' . $item;          my $html;
16    
17            if ( $html = $cache->{$item} ) {
18    
19                    warn "# koha item $item from cache\n";
20    
21            } else {
22    
23                    my $url = 'http://koha.ffzg.hr/cgi-bin/koha/opac-detail.pl?biblionumber=' . $item;
24    
25                    my $response = $ua->get( $url );
26    
27          my $response = $ua->get( $url );                  $html = $response->content;
28                    $html =~ s{<head>.+?<h1>}{<h1>}s;
29                    $html =~ s{<div class="content_set">.+$}{}s;
30                    $html =~ s{</?img[^>]+>}{}g;
31    
32          my $html = $response->content;                  $cache->{$item} = $html;
33          $html =~ s{<head>.+?<h1>}{<h1>}s;          }
         $html =~ s{<div class="content_set">.+$}{}s;  
34    
35          my $len = length($html);          my $len = length($html);
36    
37          warn "# koha item $item [$len]\n";          warn "# koha item $item [$len]\n";
38    
39          $client->write(          $client->write(
40                  'HTTP/1.1 ' . $response->status_line . "\r\n" .                  "HTTP/1.1 200 OK\r\n" .
41                  "Content-Type: text/html\r\n" .                  "Content-Type: text/html\r\n" .
42                  "Content-length: $len\r\n" .                  "Content-length: $len\r\n" .
43                  "Connection: close\r\n" .                  "Connection: close\r\n" .

Legend:
Removed from v.70  
changed lines
  Added in v.71

  ViewVC Help
Powered by ViewVC 1.1.26