1 package OpenILS::WWW::SuperCat;
2 use strict; use warnings;
6 use Apache2::Const -compile => qw(OK REDIRECT DECLINED NOT_FOUND :log);
7 use APR::Const -compile => qw(:error SUCCESS);
8 use Apache2::RequestRec ();
9 use Apache2::RequestIO ();
10 use Apache2::RequestUtil;
14 use OpenSRF::EX qw(:try);
15 use OpenSRF::Utils qw/:datetime/;
16 use OpenSRF::Utils::Cache;
18 use OpenSRF::AppSession;
22 use Unicode::Normalize;
23 use OpenILS::Utils::Fieldmapper;
24 use OpenILS::WWW::SuperCat::Feed;
27 # set the bootstrap config when this module is loaded
28 my ($bootstrap, $cstore, $supercat, $actor, $parser, $search);
37 OpenSRF::System->bootstrap_client( config_file => $bootstrap );
38 $supercat = OpenSRF::AppSession->create('open-ils.supercat');
39 $cstore = OpenSRF::AppSession->create('open-ils.cstore');
40 $actor = OpenSRF::AppSession->create('open-ils.actor');
41 $search = OpenSRF::AppSession->create('open-ils.search');
42 $parser = new XML::LibXML;
48 return Apache2::Const::DECLINED if (-e $apache->filename);
50 (my $isbn = $apache->path_info) =~ s{^.*?([^/]+)$}{$1}o;
53 ->request("open-ils.supercat.oisbn", $isbn)
56 print "Content-type: application/xml; charset=utf-8\n\n";
57 print "<?xml version='1.0' encoding='UTF-8' ?>\n";
59 unless (exists $$list{metarecord}) {
61 return Apache2::Const::OK;
64 print "<idlist metarecord='$$list{metarecord}'>\n";
66 for ( keys %{ $$list{record_list} } ) {
67 (my $o = $$list{record_list}{$_}) =~s/^(\S+).*?$/$1/o;
68 print " <isbn record='$_'>$o</isbn>\n"
73 return Apache2::Const::OK;
79 return Apache2::Const::DECLINED if (-e $apache->filename);
84 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
85 my $rel_name = $cgi->url(-relative=>1);
86 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
89 my $url = $cgi->url(-path_info=>$add_path);
90 my $root = (split 'unapi', $url)[0];
91 my $base = (split 'unapi', $url)[0] . 'unapi';
94 my $uri = $cgi->param('id') || '';
95 my $host = $cgi->virtual_host || $cgi->server_name;
97 my $format = $cgi->param('format');
98 my ($id,$type,$command,$lib) = ('','','');
101 print "Content-type: application/xml; charset=utf-8\n";
103 if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)}o) {
107 $type = 'metarecord' if ($1 =~ /^m/o);
110 ->request("open-ils.supercat.$type.formats")
115 my $body = "<formats id='$uri'><format name='opac' type='text/html'/>";
118 my ($type) = keys %$h;
119 $body .= "<format name='$type' type='application/xml'";
121 for my $part ( qw/namespace_uri docs schema_location/ ) {
122 $body .= " $part='$$h{$type}{$part}'"
123 if ($$h{$type}{$part});
129 $body .= "</formats>\n";
131 $apache->custom_response( 300, $body);
135 ->request("open-ils.supercat.record.formats")
140 ->request("open-ils.supercat.metarecord.formats")
144 my %hash = map { ( (keys %$_)[0] => (values %$_)[0] ) } @$list;
145 $list = [ map { { $_ => $hash{$_} } } sort keys %hash ];
147 print "<formats><format name='opac' type='text/html'/>";
150 my ($type) = keys %$h;
151 print "<format name='$type' type='application/xml'";
153 for my $part ( qw/namespace_uri docs schema_location/ ) {
154 print " $part='$$h{$type}{$part}'"
155 if ($$h{$type}{$part});
161 print "</formats>\n";
164 return Apache2::Const::OK;
169 if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)(?:/(.+))?}o) {
173 $type = 'metarecord' if ($1 =~ /^m/o);
174 $command = 'retrieve';
177 if ($format eq 'opac') {
178 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
179 if ($type eq 'metarecord');
180 print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
181 if ($type eq 'record');
184 my $feed = create_record_feed(
191 $feed->creator($host);
192 $feed->update_ts(gmtime_ISO8601());
194 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
195 print entityize($feed->toString) . "\n";
197 return Apache2::Const::OK;
200 my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
204 print "Content-type: text/html; charset=utf-8\n\n";
205 $apache->custom_response( 404, <<" HTML");
208 <title>$type $id not found!</title>
212 <center>Sorry, we couldn't $command a $type with the id of $id in format $format.</center>
219 print "Content-type: application/xml; charset=utf-8\n\n";
220 print $req->gather(1);
222 return Apache2::Const::OK;
228 return Apache2::Const::DECLINED if (-e $apache->filename);
233 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
234 my $rel_name = $cgi->url(-relative=>1);
235 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
238 my $url = $cgi->url(-path_info=>$add_path);
239 my $root = (split 'supercat', $url)[0];
240 my $base = (split 'supercat', $url)[0] . 'supercat';
241 my $path = (split 'supercat', $url)[1];
242 my $unapi = (split 'supercat', $url)[0] . 'unapi';
244 my $host = $cgi->virtual_host || $cgi->server_name;
246 my ($id,$type,$format,$command) = reverse split '/', $path;
249 if ( $path =~ m{^/formats(?:/([^\/]+))?$}o ) {
250 print "Content-type: application/xml; charset=utf-8\n";
253 ->request("open-ils.supercat.$1.formats")
261 <type>text/html</type>
265 my ($type) = keys %$h;
266 print "<format><name>$type</name><type>application/xml</type>";
268 for my $part ( qw/namespace_uri docs schema_location/ ) {
269 print "<$part>$$h{$type}{$part}</$part>"
270 if ($$h{$type}{$part});
276 print "</formats>\n";
278 return Apache2::Const::OK;
282 ->request("open-ils.supercat.record.formats")
287 ->request("open-ils.supercat.metarecord.formats")
291 my %hash = map { ( (keys %$_)[0] => (values %$_)[0] ) } @$list;
292 $list = [ map { { $_ => $hash{$_} } } sort keys %hash ];
297 <type>text/html</type>
301 my ($type) = keys %$h;
302 print "<format><name>$type</name><type>application/xml</type>";
304 for my $part ( qw/namespace_uri docs schema_location/ ) {
305 print "<$part>$$h{$type}{$part}</$part>"
306 if ($$h{$type}{$part});
312 print "</formats>\n";
315 return Apache2::Const::OK;
318 if ($format eq 'opac') {
319 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
320 if ($type eq 'metarecord');
321 print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
322 if ($type eq 'record');
324 } elsif ($format =~ /^html/o) {
325 my $feed = create_record_feed( $format => [ $id ], $unapi,);
328 $feed->creator($host);
329 $feed->update_ts(gmtime_ISO8601());
331 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
332 print entityize($feed->toString) . "\n";
334 return Apache2::Const::OK;
337 my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
341 print "Content-type: text/html; charset=utf-8\n\n";
342 $apache->custom_response( 404, <<" HTML");
345 <title>$type $id not found!</title>
349 <center>Sorry, we couldn't $command a $type with the id of $id.</center>
356 print "Content-type: application/xml; charset=utf-8\n\n";
357 print entityize( $parser->parse_string( $req->gather(1) )->documentElement->toString );
359 return Apache2::Const::OK;
365 return Apache2::Const::DECLINED if (-e $apache->filename);
369 my $year = (gmtime())[5] + 1900;
370 my $host = $cgi->virtual_host || $cgi->server_name;
373 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
374 my $rel_name = $cgi->url(-relative=>1);
375 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
378 my $url = $cgi->url(-path_info=>$add_path);
379 my $root = (split 'feed', $url)[0];
380 my $base = (split 'bookbag', $url)[0] . 'bookbag';
381 my $path = (split 'bookbag', $url)[1];
382 my $unapi = (split 'feed', $url)[0] . 'unapi';
385 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
387 my ($id,$type) = reverse split '/', $path;
389 my $bucket = $actor->request("open-ils.actor.container.public.flesh", 'biblio', $id)->gather(1);
390 return Apache2::Const::NOT_FOUND unless($bucket);
392 my $bucket_tag = "tag:$host,$year:record_bucket/$id";
393 if ($type eq 'opac') {
394 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
395 join('&', map { "rl=" . $_->target_biblio_record_entry } @{ $bucket->items }) .
400 my $feed = create_record_feed(
402 [ map { $_->target_biblio_record_entry } @{ $bucket->items } ],
407 $feed->title("Items in Book Bag [".$bucket->name."]");
408 $feed->creator($host);
409 $feed->update_ts(gmtime_ISO8601());
411 $feed->link(rss => $base . "/rss2/$id" => 'application/rss+xml');
412 $feed->link(alternate => $base . "/atom/$id" => 'application/atom+xml');
413 $feed->link(html => $base . "/html/$id" => 'text/html');
414 $feed->link(unapi => $unapi);
418 '/opac/en-US/skin/default/xml/rresult.xml?rt=list&' .
419 join('&', map { 'rl=' . $_->target_biblio_record_entry } @{$bucket->items} ),
424 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
425 print entityize($feed->toString) . "\n";
427 return Apache2::Const::OK;
432 return Apache2::Const::DECLINED if (-e $apache->filename);
436 my $year = (gmtime())[5] + 1900;
437 my $host = $cgi->virtual_host || $cgi->server_name;
440 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
441 my $rel_name = $cgi->url(-relative=>1);
442 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
445 my $url = $cgi->url(-path_info=>$add_path);
446 my $root = (split 'feed', $url)[0];
447 my $base = (split 'freshmeat', $url)[0] . 'freshmeat';
448 my $path = (split 'freshmeat', $url)[1];
449 my $unapi = (split 'feed', $url)[0] . 'unapi';
452 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
456 my ($type,$rtype,$axis,$limit,$date) = split '/', $path;
459 my $list = $supercat->request("open-ils.supercat.$rtype.record.$axis.recent", $date, $limit)->gather(1);
461 if ($type eq 'opac') {
462 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
463 join('&', map { "rl=" . $_ } @$list) .
468 my $feed = create_record_feed( $type, $list, $unapi);
472 $feed->title("Up to $limit recent $rtype ${axis}s from $date forward");
474 $feed->title("$limit most recent $rtype ${axis}s");
477 $feed->creator($host);
478 $feed->update_ts(gmtime_ISO8601());
480 $feed->link(rss => $base . "/rss2/$rtype/$axis/$limit/$date" => 'application/rss+xml');
481 $feed->link(alternate => $base . "/atom/$rtype/$axis/$limit/$date" => 'application/atom+xml');
482 $feed->link(html => $base . "/html/$rtype/$axis/$limit/$date" => 'text/html');
483 $feed->link(unapi => $unapi);
487 '/opac/en-US/skin/default/xml/rresult.xml?rt=list&' .
488 join('&', map { 'rl=' . $_} @$list ),
493 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
494 print entityize($feed->toString) . "\n";
496 return Apache2::Const::OK;
505 if ($version eq '1.0') {
507 Content-type: application/opensearchdescription+xml; charset=utf-8
509 <?xml version="1.0" encoding="UTF-8"?>
510 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">
511 <Url>$base/1.0/$lib/-/$class/{searchTerms}?startPage={startPage}&startIndex={startIndex}&count={count}</Url>
512 <Format>http://a9.com/-/spec/opensearchrss/1.0/</Format>
513 <ShortName>$lib</ShortName>
514 <LongName>Search $lib</LongName>
515 <Description>Search the $lib OPAC by $class.</Description>
516 <Tags>$lib book library</Tags>
517 <SampleSearch>harry+potter</SampleSearch>
518 <Developer>Mike Rylander for GPLS/PINES</Developer>
519 <Contact>feedback\@open-ils.org</Contact>
520 <SyndicationRight>open</SyndicationRight>
521 <AdultContent>false</AdultContent>
522 </OpenSearchDescription>
526 Content-type: application/opensearchdescription+xml; charset=utf-8
528 <?xml version="1.0" encoding="UTF-8"?>
529 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
530 <ShortName>$lib</ShortName>
531 <Description>Search the $lib OPAC by $class.</Description>
532 <Tags>$lib book library</Tags>
533 <Url type="application/rss+xml"
534 template="$base/1.1/$lib/rss2/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
535 <Url type="application/atom+xml"
536 template="$base/1.1/$lib/atom/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
537 <Url type="application/x-mods3+xml"
538 template="$base/1.1/$lib/mods3/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
539 <Url type="application/x-mods+xml"
540 template="$base/1.1/$lib/mods/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
541 <Url type="application/x-marcxml+xml"
542 template="$base/1.1/$lib/marcxml/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
543 <LongName>Search $lib</LongName>
544 <Query role="example" searchTerms="harry+potter" />
545 <Developer>Mike Rylander for GPLS/PINES</Developer>
546 <Contact>feedback\@open-ils.org</Contact>
547 <SyndicationRight>open</SyndicationRight>
548 <AdultContent>false</AdultContent>
549 <Language>en-US</Language>
550 <OutputEncoding>UTF-8</OutputEncoding>
551 <InputEncoding>UTF-8</InputEncoding>
552 </OpenSearchDescription>
556 return Apache2::Const::OK;
559 sub opensearch_feed {
561 return Apache2::Const::DECLINED if (-e $apache->filename);
564 my $year = (gmtime())[5] + 1900;
566 my $host = $cgi->virtual_host || $cgi->server_name;
569 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
570 my $rel_name = $cgi->url(-relative=>1);
571 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
574 my $url = $cgi->url(-path_info=>$add_path);
575 my $root = (split 'opensearch', $url)[0];
576 my $base = (split 'opensearch', $url)[0] . 'opensearch';
577 my $unapi = (split 'opensearch', $url)[0] . 'unapi';
580 my $path = $cgi->path_info;
582 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
584 if ($path =~ m{^/?(1\.\d{1})/(?:([^/]+)/)?([^/]+)/osd.xml}o) {
591 $lib = $actor->request(
592 'open-ils.actor.org_unit_list.search' => parent_ou => undef
593 )->gather(1)->[0]->shortname;
600 return opensearch_osd($version, $lib, $class, $base);
604 my $page = $cgi->param('startPage') || 1;
605 my $offset = $cgi->param('startIndex') || 1;
606 my $limit = $cgi->param('count') || 10;
607 my $lang = $cgi->param('language') || 'en-US';
609 $page = 1 if ($page !~ /^\d+$/);
610 $offset = 1 if ($offset !~ /^\d+$/);
611 $limit = 10 if ($limit !~ /^\d+$/); $limit = 25 if ($limit > 25);
612 $lang = 'en-US' if ($lang =~ /^{/ or $lang eq '*');
615 $offset = ($page - 1) * $limit;
620 my ($version,$org,$type,$class,$terms,$sort,$sortdir);
621 (undef,$version,$org,$type,$class,$terms,$sort,$sortdir,$lang) = split '/', $path;
623 $lang ||= $cgi->param('searchLang');
624 $sort ||= $cgi->param('searchSort');
625 $sortdir ||= $cgi->param('searchSortDir');
626 $terms ||= $cgi->param('searchTerms');
627 $class ||= $cgi->param('searchClass') || '-';
628 $type ||= $cgi->param('responseType') || '-';
629 $org ||= $cgi->param('searchOrg') || '-';
631 if ($version eq '1.0') {
633 } elsif ($type eq '-') {
638 $terms = decode_utf8($terms);
641 my $term_copy = $terms;
643 my $complex_terms = 0;
644 if ($terms eq 'help') {
645 print $cgi->header(-type => 'text/html');
649 <title>just type something!</title>
652 <p>You are in a maze of dark, twisty stacks, all alike.</p>
656 return Apache2::Const::OK;
661 while ($term_copy =~ s/((?:keyword|title|author|subject|series|site|dir|sort|lang):[^:]+)$//so) {
662 my ($c,$t) = split ':' => $1;
667 } elsif ($c eq 'sort') {
668 ($sort = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
669 } elsif ($c eq 'dir') {
670 ($sortdir = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
671 } elsif ($c eq 'lang') {
672 ($lang = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
674 $$searches{$c}{term} .= ' '.$t;
675 $cache_key .= $c . $t;
682 $class = 'keyword' if ($class eq '-');
683 $$searches{$class}{term} .= " $term_copy";
684 $cache_key .= $class . $term_copy;
689 $org_unit = $actor->request(
690 'open-ils.actor.org_unit_list.search' => parent_ou => undef
693 $org_unit = $actor->request(
694 'open-ils.actor.org_unit_list.search' => shortname => uc($org)
698 $cache_key .= $org.$sort.$sortdir.$lang;
700 my $rs_name = $cgi->cookie('os_session');
701 my $cached_res = OpenSRF::Utils::Cache->new->get_cache( "os_session:$rs_name" ) if ($rs_name);
704 if (!($recs = $$cached_res{os_results}{$cache_key})) {
705 $rs_name = $cgi->remote_host . '::' . rand(time);
706 $recs = $search->request(
707 'open-ils.search.biblio.multiclass' => {
708 searches => $searches,
709 org_unit => $org_unit->[0]->id,
712 ($sort ? ( 'sort' => $sort ) : ()),
713 ($sortdir ? ( 'sort_dir' => $sortdir ) : ($sort ? (sort_dir => 'asc') : (sort_dir => 'desc') )),
714 ($lang ? ( 'language' => $lang ) : ()),
718 $$cached_res{os_results}{$cache_key} = $recs;
719 OpenSRF::Utils::Cache->new->put_cache( "os_session:$rs_name", $cached_res, 1800 );
725 my $feed = create_record_feed(
727 [ map { $_->[0] } @{$recs->{ids}}[$offset .. $offset + $limit - 1] ],
733 $feed->search($terms);
734 $feed->class($class);
736 if ($complex_terms) {
737 $feed->title("Search results for [$terms] at ".$org_unit->[0]->name);
739 $feed->title("Search results for [$class => $terms] at ".$org_unit->[0]->name);
742 $feed->creator($host);
743 $feed->update_ts(gmtime_ISO8601());
747 'http://a9.com/-/spec/opensearch/1.1/',
754 'http://a9.com/-/spec/opensearch/1.1/',
761 'http://a9.com/-/spec/opensearch/1.1/',
768 $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int($offset + $limit + 1) . "&count=" . $limit =>
769 'application/opensearch+xml'
770 ) if ($offset + $limit < $recs->{count});
774 $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int(($offset - $limit) + 1) . "&count=" . $limit =>
775 'application/opensearch+xml'
780 $base . "/$version/$org/$type/$class?searchTerms=$terms" =>
781 'application/opensearch+xml'
786 $base . "/$version/$org/rss2/$class?searchTerms=$terms" =>
787 'application/rss+xml'
792 $base . "/$version/$org/atom/$class?searchTerms=$terms" =>
793 'application/atom+xml'
798 $base . "/$version/$org/html/$class?searchTerms=$terms" =>
802 $feed->link( unapi => $unapi);
806 $root . "../$lang/skin/default/xml/rresult.xml?rt=list&" .
807 join('&', map { 'rl=' . $_->[0] } grep { ref $_ && defined $_->[0] } @{$recs->{ids}} ),
812 -type => $feed->type,
814 -cookie => $cgi->cookie( -name => 'os_session', -value => $rs_name, -expires => '+30m' ),
817 print entityize($feed->toString) . "\n";
819 return Apache2::Const::OK;
822 sub create_record_feed {
827 my $lib = shift || '-';
830 my $base = $cgi->url;
831 my $host = $cgi->virtual_host || $cgi->server_name;
833 my $year = (gmtime())[5] + 1900;
835 my $feed = new OpenILS::WWW::SuperCat::Feed ($type);
837 $feed->unapi($unapi);
839 $type = 'atom' if ($type eq 'html');
840 $type = 'marcxml' if ($type eq 'htmlcard' or $type eq 'htmlholdings');
842 #$records = $supercat->request( "open-ils.supercat.record.object.retrieve", $records )->gather(1);
844 for my $record (@$records) {
845 next unless($record);
847 #my $rec = $record->id;
850 my $item_tag = "tag:$host,$year:biblio-record_entry/$rec/$lib";
852 my $xml = $supercat->request(
853 "open-ils.supercat.record.$type.retrieve",
858 my $node = $feed->add_item($xml);
861 if ($lib && $type eq 'marcxml') {
862 $xml = $supercat->request( "open-ils.supercat.record.holdings_xml.retrieve", $rec, $lib )->gather(1);
863 $node->add_holdings($xml);
866 $node->id($item_tag);
867 #$node->update_ts(clense_ISO8601($record->edit_date));
868 $node->link(alternate => $feed->unapi . "?id=$item_tag&format=htmlholdings" => 'text/html');
869 $node->link(opac => $feed->unapi . "?id=$item_tag&format=opac");
870 $node->link(unapi => $feed->unapi . "?id=$item_tag");
871 $node->link('unapi-id' => $item_tag);
878 my $stuff = NFC(shift());
879 $stuff =~ s/&(?!\S+;)/&/gso;
880 $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
889 my $year = (gmtime())[5] + 1900;
892 $content .= "Content-type: application/xml\n\n";
893 $content .= "<hold:volumes xmlns:hold='http://open-ils.org/spec/holdings/v1'>";
895 for my $cn (@$tree) {
896 (my $cn_class = $cn->class_name) =~ s/::/-/gso;
897 $cn_class =~ s/Fieldmapper-//gso;
899 my $cn_tag = "tag:open-ils.org,$year:$cn_class/".$cn->id;
900 my $cn_lib = $cn->owning_lib->shortname;
901 my $cn_label = $cn->label;
903 (my $ou_class = $cn->owning_lib->class_name) =~ s/::/-/gso;
904 $ou_class =~ s/Fieldmapper-//gso;
906 my $ou_tag = "tag:open-ils.org,$year:$ou_class/".$cn->owning_lib->id;
907 my $ou_name = $cn->owning_lib->name;
909 $content .= "<hold:volume id='$cn_tag' lib='$cn_lib' label='$cn_label'>";
910 $content .= "<act:owning_lib xmlns:act='http://open-ils.org/spec/actors/v1' id='$ou_tag' name='$ou_name'/>";
911 $content .= $cn->record->marc;
912 $content .= "</hold:volume>";
915 $content .= '</hold:volumes>';
923 return Apache2::Const::DECLINED if (-e $apache->filename);
926 my $year = (gmtime())[5] + 1900;
928 my $host = $cgi->virtual_host || $cgi->server_name;
931 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
932 my $rel_name = $cgi->url(-relative=>1);
933 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
936 my $url = $cgi->url(-path_info=>$add_path);
937 my $root = (split 'browse', $url)[0];
938 my $base = (split 'browse', $url)[0] . 'browse';
939 my $unapi = (split 'browse', $url)[0] . 'unapi';
942 my $path = (split 'browse', $url)[1];
944 my (undef,$format,$axis,$site,$string,$page,$page_size) = split '/', $path;
947 $site ||= $cgi->param('searchOrg');
948 $page ||= $cgi->param('startPage') || 0;
949 $page_size ||= $cgi->param('count') || 9;
951 $page = 0 if ($page !~ /^\d+$/);
953 unless ($string and $axis and grep { $axis eq $_ } keys %browse_types) {
954 warn "something's wrong...";
958 $string = decode_utf8($string);
959 $string =~ s/\+/ /go;
962 my $tree = $supercat->request(
963 "open-ils.supercat.$axis.browse",
970 my $content = $browse_types{$axis}{$format}->($tree);
972 return Apache2::Const::OK;