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);
82 my $rel_name = quotemeta($cgi->url(-relative=>1));
85 $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
88 my $url = $cgi->url(-path_info=>$add_path);
89 my $root = (split 'unapi', $url)[0];
90 my $base = (split 'unapi', $url)[0] . 'unapi';
93 my $uri = $cgi->param('id') || '';
94 my $host = $cgi->virtual_host || $cgi->server_name;
96 my $format = $cgi->param('format');
97 my ($id,$type,$command,$lib) = ('','','');
100 print "Content-type: application/xml; charset=utf-8\n";
102 if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)}o) {
106 $type = 'metarecord' if ($1 =~ /^m/o);
109 ->request("open-ils.supercat.$type.formats")
114 my $body = "<formats id='$uri'><format name='opac' type='text/html'/>";
117 my ($type) = keys %$h;
118 $body .= "<format name='$type' type='application/xml'";
120 for my $part ( qw/namespace_uri docs schema_location/ ) {
121 $body .= " $part='$$h{$type}{$part}'"
122 if ($$h{$type}{$part});
128 $body .= "</formats>\n";
130 $apache->custom_response( 300, $body);
134 ->request("open-ils.supercat.record.formats")
139 ->request("open-ils.supercat.metarecord.formats")
143 my %hash = map { ( (keys %$_)[0] => (values %$_)[0] ) } @$list;
144 $list = [ map { { $_ => $hash{$_} } } sort keys %hash ];
146 print "<formats><format name='opac' type='text/html'/>";
149 my ($type) = keys %$h;
150 print "<format name='$type' type='application/xml'";
152 for my $part ( qw/namespace_uri docs schema_location/ ) {
153 print " $part='$$h{$type}{$part}'"
154 if ($$h{$type}{$part});
160 print "</formats>\n";
163 return Apache2::Const::OK;
168 if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)(?:/(.+))?}o) {
172 $type = 'metarecord' if ($1 =~ /^m/o);
173 $command = 'retrieve';
176 if ($format eq 'opac') {
177 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
178 if ($type eq 'metarecord');
179 print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
180 if ($type eq 'record');
183 my $feed = create_record_feed(
190 $feed->creator($host);
191 $feed->update_ts(gmtime_ISO8601());
193 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
194 print entityize($feed->toString) . "\n";
196 return Apache2::Const::OK;
199 my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
203 print "Content-type: text/html; charset=utf-8\n\n";
204 $apache->custom_response( 404, <<" HTML");
207 <title>$type $id not found!</title>
211 <center>Sorry, we couldn't $command a $type with the id of $id in format $format.</center>
218 print "Content-type: application/xml; charset=utf-8\n\n";
219 print $req->gather(1);
221 return Apache2::Const::OK;
227 return Apache2::Const::DECLINED if (-e $apache->filename);
231 my $rel_name = quotemeta($cgi->url(-relative=>1));
234 $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
237 my $url = $cgi->url(-path_info=>$add_path);
238 my $root = (split 'supercat', $url)[0];
239 my $base = (split 'supercat', $url)[0] . 'supercat';
240 my $path = (split 'supercat', $url)[1];
241 my $unapi = (split 'supercat', $url)[0] . 'unapi';
243 my $host = $cgi->virtual_host || $cgi->server_name;
245 my ($id,$type,$format,$command) = reverse split '/', $path;
248 if ( $path =~ m{^/formats(?:/([^\/]+))?$}o ) {
249 print "Content-type: application/xml; charset=utf-8\n";
252 ->request("open-ils.supercat.$1.formats")
260 <type>text/html</type>
264 my ($type) = keys %$h;
265 print "<format><name>$type</name><type>application/xml</type>";
267 for my $part ( qw/namespace_uri docs schema_location/ ) {
268 print "<$part>$$h{$type}{$part}</$part>"
269 if ($$h{$type}{$part});
275 print "</formats>\n";
277 return Apache2::Const::OK;
281 ->request("open-ils.supercat.record.formats")
286 ->request("open-ils.supercat.metarecord.formats")
290 my %hash = map { ( (keys %$_)[0] => (values %$_)[0] ) } @$list;
291 $list = [ map { { $_ => $hash{$_} } } sort keys %hash ];
296 <type>text/html</type>
300 my ($type) = keys %$h;
301 print "<format><name>$type</name><type>application/xml</type>";
303 for my $part ( qw/namespace_uri docs schema_location/ ) {
304 print "<$part>$$h{$type}{$part}</$part>"
305 if ($$h{$type}{$part});
311 print "</formats>\n";
314 return Apache2::Const::OK;
317 if ($format eq 'opac') {
318 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
319 if ($type eq 'metarecord');
320 print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
321 if ($type eq 'record');
323 } elsif ($format =~ /^html/o) {
324 my $feed = create_record_feed( $format => [ $id ], $unapi,);
327 $feed->creator($host);
328 $feed->update_ts(gmtime_ISO8601());
330 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
331 print entityize($feed->toString) . "\n";
333 return Apache2::Const::OK;
336 my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
340 print "Content-type: text/html; charset=utf-8\n\n";
341 $apache->custom_response( 404, <<" HTML");
344 <title>$type $id not found!</title>
348 <center>Sorry, we couldn't $command a $type with the id of $id.</center>
355 print "Content-type: application/xml; charset=utf-8\n\n";
356 print entityize( $parser->parse_string( $req->gather(1) )->documentElement->toString );
358 return Apache2::Const::OK;
364 return Apache2::Const::DECLINED if (-e $apache->filename);
368 my $year = (gmtime())[5] + 1900;
369 my $host = $cgi->virtual_host || $cgi->server_name;
371 my $rel_name = quotemeta($cgi->url(-relative=>1));
374 $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
376 my $url = $cgi->url(-path_info=>$add_path);
377 my $root = (split 'feed', $url)[0];
378 my $base = (split 'bookbag', $url)[0] . 'bookbag';
379 my $path = (split 'bookbag', $url)[1];
380 my $unapi = (split 'feed', $url)[0] . 'unapi';
383 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
385 my ($id,$type) = reverse split '/', $path;
387 my $bucket = $actor->request("open-ils.actor.container.public.flesh", 'biblio', $id)->gather(1);
388 return Apache2::Const::NOT_FOUND unless($bucket);
390 my $bucket_tag = "tag:$host,$year:record_bucket/$id";
391 if ($type eq 'opac') {
392 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
393 join('&', map { "rl=" . $_->target_biblio_record_entry } @{ $bucket->items }) .
398 my $feed = create_record_feed(
400 [ map { $_->target_biblio_record_entry } @{ $bucket->items } ],
405 $feed->title("Items in Book Bag [".$bucket->name."]");
406 $feed->creator($host);
407 $feed->update_ts(gmtime_ISO8601());
409 $feed->link(rss => $base . "/rss2/$id" => 'application/rss+xml');
410 $feed->link(alternate => $base . "/atom/$id" => 'application/atom+xml');
411 $feed->link(html => $base . "/html/$id" => 'text/html');
412 $feed->link(unapi => $unapi);
416 '/opac/en-US/skin/default/xml/rresult.xml?rt=list&' .
417 join('&', map { 'rl=' . $_->target_biblio_record_entry } @{$bucket->items} ),
422 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
423 print entityize($feed->toString) . "\n";
425 return Apache2::Const::OK;
430 return Apache2::Const::DECLINED if (-e $apache->filename);
434 my $year = (gmtime())[5] + 1900;
435 my $host = $cgi->virtual_host || $cgi->server_name;
437 my $rel_name = quotemeta($cgi->url(-relative=>1));
440 $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
442 my $url = $cgi->url(-path_info=>$add_path);
443 my $root = (split 'feed', $url)[0];
444 my $base = (split 'freshmeat', $url)[0] . 'freshmeat';
445 my $path = (split 'freshmeat', $url)[1];
446 my $unapi = (split 'feed', $url)[0] . 'unapi';
449 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
453 my ($type,$rtype,$axis,$limit,$date) = split '/', $path;
456 my $list = $supercat->request("open-ils.supercat.$rtype.record.$axis.recent", $date, $limit)->gather(1);
458 if ($type eq 'opac') {
459 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
460 join('&', map { "rl=" . $_ } @$list) .
465 my $feed = create_record_feed( $type, $list, $unapi);
469 $feed->title("Up to $limit recent $rtype ${axis}s from $date forward");
471 $feed->title("$limit most recent $rtype ${axis}s");
474 $feed->creator($host);
475 $feed->update_ts(gmtime_ISO8601());
477 $feed->link(rss => $base . "/rss2/$rtype/$axis/$limit/$date" => 'application/rss+xml');
478 $feed->link(alternate => $base . "/atom/$rtype/$axis/$limit/$date" => 'application/atom+xml');
479 $feed->link(html => $base . "/html/$rtype/$axis/$limit/$date" => 'text/html');
480 $feed->link(unapi => $unapi);
484 '/opac/en-US/skin/default/xml/rresult.xml?rt=list&' .
485 join('&', map { 'rl=' . $_} @$list ),
490 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
491 print entityize($feed->toString) . "\n";
493 return Apache2::Const::OK;
502 if ($version eq '1.0') {
504 Content-type: application/opensearchdescription+xml; charset=utf-8
506 <?xml version="1.0" encoding="UTF-8"?>
507 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">
508 <Url>$base/1.0/$lib/-/$class/{searchTerms}?startPage={startPage}&startIndex={startIndex}&count={count}</Url>
509 <Format>http://a9.com/-/spec/opensearchrss/1.0/</Format>
510 <ShortName>$lib</ShortName>
511 <LongName>Search $lib</LongName>
512 <Description>Search the $lib OPAC by $class.</Description>
513 <Tags>$lib book library</Tags>
514 <SampleSearch>harry+potter</SampleSearch>
515 <Developer>Mike Rylander for GPLS/PINES</Developer>
516 <Contact>feedback\@open-ils.org</Contact>
517 <SyndicationRight>open</SyndicationRight>
518 <AdultContent>false</AdultContent>
519 </OpenSearchDescription>
523 Content-type: application/opensearchdescription+xml; charset=utf-8
525 <?xml version="1.0" encoding="UTF-8"?>
526 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
527 <ShortName>$lib</ShortName>
528 <Description>Search the $lib OPAC by $class.</Description>
529 <Tags>$lib book library</Tags>
530 <Url type="application/rss+xml"
531 template="$base/1.1/$lib/rss2/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
532 <Url type="application/atom+xml"
533 template="$base/1.1/$lib/atom/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
534 <Url type="application/x-mods3+xml"
535 template="$base/1.1/$lib/mods3/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
536 <Url type="application/x-mods+xml"
537 template="$base/1.1/$lib/mods/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
538 <Url type="application/x-marcxml+xml"
539 template="$base/1.1/$lib/marcxml/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
540 <LongName>Search $lib</LongName>
541 <Query role="example" searchTerms="harry+potter" />
542 <Developer>Mike Rylander for GPLS/PINES</Developer>
543 <Contact>feedback\@open-ils.org</Contact>
544 <SyndicationRight>open</SyndicationRight>
545 <AdultContent>false</AdultContent>
546 <Language>en-US</Language>
547 <OutputEncoding>UTF-8</OutputEncoding>
548 <InputEncoding>UTF-8</InputEncoding>
549 </OpenSearchDescription>
553 return Apache2::Const::OK;
556 sub opensearch_feed {
558 return Apache2::Const::DECLINED if (-e $apache->filename);
561 my $year = (gmtime())[5] + 1900;
563 my $host = $cgi->virtual_host || $cgi->server_name;
565 my $rel_name = quotemeta($cgi->url(-relative=>1));
568 $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
570 my $url = $cgi->url(-path_info=>$add_path);
571 my $root = (split 'opensearch', $url)[0];
572 my $base = (split 'opensearch', $url)[0] . 'opensearch';
573 my $unapi = (split 'opensearch', $url)[0] . 'unapi';
576 my $path = (split 'opensearch', $url)[1];
578 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
580 if ($path =~ m{^/?(1\.\d{1})/(?:([^/]+)/)?([^/]+)/osd.xml}o) {
587 $lib = $actor->request(
588 'open-ils.actor.org_unit_list.search' => parent_ou => undef
589 )->gather(1)->[0]->shortname;
596 return opensearch_osd($version, $lib, $class, $base);
600 my $page = $cgi->param('startPage') || 1;
601 my $offset = $cgi->param('startIndex') || 1;
602 my $limit = $cgi->param('count') || 10;
603 my $lang = $cgi->param('language') || 'en-US';
605 $page = 1 if ($page !~ /^\d+$/);
606 $offset = 1 if ($offset !~ /^\d+$/);
607 $limit = 10 if ($limit !~ /^\d+$/); $limit = 25 if ($limit > 25);
608 $lang = 'en-US' if ($lang =~ /^{/ or $lang eq '*');
611 $offset = ($page - 1) * $limit;
616 my ($version,$org,$type,$class,$terms,$sort,$sortdir);
617 (undef,$version,$org,$type,$class,$terms,$sort,$sortdir,$lang) = split '/', $path;
619 $lang ||= $cgi->param('searchLang');
620 $sort ||= $cgi->param('searchSort');
621 $sortdir ||= $cgi->param('searchSortDir');
622 $terms ||= $cgi->param('searchTerms');
623 $class ||= $cgi->param('searchClass') || '-';
624 $type ||= $cgi->param('responseType') || '-';
625 $org ||= $cgi->param('searchOrg') || '-';
627 if ($version eq '1.0') {
629 } elsif ($type eq '-') {
634 $terms = decode_utf8($terms);
637 my $term_copy = $terms;
639 my $complex_terms = 0;
640 if ($terms eq 'help') {
641 print $cgi->header(-type => 'text/html');
645 <title>just type something!</title>
648 <p>You are in a maze of dark, twisty stacks, all alike.</p>
652 return Apache2::Const::OK;
657 while ($term_copy =~ s/((?:keyword|title|author|subject|series|site|dir|sort|lang):[^:]+)$//so) {
659 my ($c,$t) = split ':' => $1;
664 } elsif ($c eq 'sort') {
665 ($sort = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
666 } elsif ($c eq 'dir') {
667 ($sortdir = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
668 } elsif ($c eq 'lang') {
669 ($lang = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
671 $$searches{$c}{term} .= ' '.$t;
672 $cache_key .= $c . $t;
680 $class = 'keyword' if ($class eq '-');
681 $$searches{$class}{term} .= " $term_copy";
682 $cache_key .= $class . $term_copy;
687 $org_unit = $actor->request(
688 'open-ils.actor.org_unit_list.search' => parent_ou => undef
691 $org_unit = $actor->request(
692 'open-ils.actor.org_unit_list.search' => shortname => uc($org)
696 $cache_key .= $org.$sort.$sortdir.$lang;
698 my $rs_name = $cgi->cookie('os_session');
699 my $cached_res = OpenSRF::Utils::Cache->new->get_cache( "os_session:$rs_name" ) if ($rs_name);
702 if (!($recs = $$cached_res{os_results}{$cache_key})) {
703 $rs_name = $cgi->remote_host . '::' . rand(time);
704 $recs = $search->request(
705 'open-ils.search.biblio.multiclass' => {
706 searches => $searches,
707 org_unit => $org_unit->[0]->id,
710 ($sort ? ( 'sort' => $sort ) : ()),
711 ($sortdir ? ( 'sort_dir' => $sortdir ) : ($sort ? (sort_dir => 'asc') : (sort_dir => 'desc') )),
712 ($lang ? ( 'language' => $lang ) : ()),
716 $$cached_res{os_results}{$cache_key} = $recs;
717 OpenSRF::Utils::Cache->new->put_cache( "os_session:$rs_name", $cached_res, 1800 );
723 my $feed = create_record_feed(
725 [ map { $_->[0] } @{$recs->{ids}}[$offset .. $offset + $limit - 1] ],
731 $feed->search($terms);
732 $feed->class($class);
734 if ($complex_terms) {
735 $feed->title("Search results for [$terms] at ".$org_unit->[0]->name);
737 $feed->title("Search results for [$class => $terms] at ".$org_unit->[0]->name);
740 $feed->creator($host);
741 $feed->update_ts(gmtime_ISO8601());
745 'http://a9.com/-/spec/opensearch/1.1/',
752 'http://a9.com/-/spec/opensearch/1.1/',
759 'http://a9.com/-/spec/opensearch/1.1/',
766 $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int($offset + $limit + 1) . "&count=" . $limit =>
767 'application/opensearch+xml'
768 ) if ($offset + $limit < $recs->{count});
772 $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int(($offset - $limit) + 1) . "&count=" . $limit =>
773 'application/opensearch+xml'
778 $base . "/$version/$org/$type/$class?searchTerms=$terms" =>
779 'application/opensearch+xml'
784 $base . "/$version/$org/rss2/$class?searchTerms=$terms" =>
785 'application/rss+xml'
790 $base . "/$version/$org/atom/$class?searchTerms=$terms" =>
791 'application/atom+xml'
796 $base . "/$version/$org/html/$class?searchTerms=$terms" =>
800 $feed->link( unapi => $unapi);
804 $root . "../$lang/skin/default/xml/rresult.xml?rt=list&" .
805 join('&', map { 'rl=' . $_->[0] } grep { ref $_ && defined $_->[0] } @{$recs->{ids}} ),
810 -type => $feed->type,
812 -cookie => $cgi->cookie( -name => 'os_session', -value => $rs_name, -expires => '+30m' ),
815 print entityize($feed->toString) . "\n";
817 return Apache2::Const::OK;
820 sub create_record_feed {
825 my $lib = shift || '-';
828 my $base = $cgi->url;
829 my $host = $cgi->virtual_host || $cgi->server_name;
831 my $year = (gmtime())[5] + 1900;
833 my $feed = new OpenILS::WWW::SuperCat::Feed ($type);
835 $feed->unapi($unapi);
837 $type = 'atom' if ($type eq 'html');
838 $type = 'marcxml' if ($type eq 'htmlcard' or $type eq 'htmlholdings');
840 #$records = $supercat->request( "open-ils.supercat.record.object.retrieve", $records )->gather(1);
842 for my $record (@$records) {
843 next unless($record);
845 #my $rec = $record->id;
848 my $item_tag = "tag:$host,$year:biblio-record_entry/$rec/$lib";
850 my $xml = $supercat->request(
851 "open-ils.supercat.record.$type.retrieve",
856 my $node = $feed->add_item($xml);
859 if ($lib && $type eq 'marcxml') {
860 $xml = $supercat->request( "open-ils.supercat.record.holdings_xml.retrieve", $rec, $lib )->gather(1);
861 $node->add_holdings($xml);
864 $node->id($item_tag);
865 #$node->update_ts(clense_ISO8601($record->edit_date));
866 $node->link(alternate => $feed->unapi . "?id=$item_tag&format=htmlholdings" => 'text/html');
867 $node->link(opac => $feed->unapi . "?id=$item_tag&format=opac");
868 $node->link(unapi => $feed->unapi . "?id=$item_tag");
869 $node->link('unapi-id' => $item_tag);
876 my $stuff = NFC(shift());
877 $stuff =~ s/&(?!\S+;)/&/gso;
878 $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
887 my $year = (gmtime())[5] + 1900;
890 $content .= "Content-type: application/xml\n\n";
891 $content .= "<hold:volumes xmlns:hold='http://open-ils.org/spec/holdings/v1'>";
893 for my $cn (@$tree) {
894 (my $cn_class = $cn->class_name) =~ s/::/-/gso;
895 $cn_class =~ s/Fieldmapper-//gso;
897 my $cn_tag = "tag:open-ils.org,$year:$cn_class/".$cn->id;
898 my $cn_lib = $cn->owning_lib->shortname;
899 my $cn_label = $cn->label;
901 (my $ou_class = $cn->owning_lib->class_name) =~ s/::/-/gso;
902 $ou_class =~ s/Fieldmapper-//gso;
904 my $ou_tag = "tag:open-ils.org,$year:$ou_class/".$cn->owning_lib->id;
905 my $ou_name = $cn->owning_lib->name;
907 $content .= "<hold:volume id='$cn_tag' lib='$cn_lib' label='$cn_label'>";
908 $content .= "<act:owning_lib xmlns:act='http://open-ils.org/spec/actors/v1' id='$ou_tag' name='$ou_name'/>";
909 $content .= $cn->record->marc;
910 $content .= "</hold:volume>";
913 $content .= '</hold:volumes>';
921 return Apache2::Const::DECLINED if (-e $apache->filename);
924 my $year = (gmtime())[5] + 1900;
926 my $host = $cgi->virtual_host || $cgi->server_name;
928 my $rel_name = quotemeta($cgi->url(-relative=>1));
931 $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
933 my $url = $cgi->url(-path_info=>$add_path);
934 my $root = (split 'browse', $url)[0];
935 my $base = (split 'browse', $url)[0] . 'browse';
936 my $unapi = (split 'browse', $url)[0] . 'unapi';
939 my $path = (split 'browse', $url)[1];
941 my (undef,$format,$axis,$site,$string,$page,$page_size) = split '/', $path;
944 $site ||= $cgi->param('searchOrg');
945 $page ||= $cgi->param('startPage') || 0;
946 $page_size ||= $cgi->param('count') || 9;
948 $page = 0 if ($page !~ /^\d+$/);
950 unless ($string and $axis and grep { $axis eq $_ } keys %browse_types) {
951 warn "something's wrong...";
955 $string = decode_utf8($string);
956 $string =~ s/\+/ /go;
959 my $tree = $supercat->request(
960 "open-ils.supercat.$axis.browse",
967 my $content = $browse_types{$axis}{$format}->($tree);
969 return Apache2::Const::OK;