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');
183 } elsif (OpenILS::WWW::SuperCat::Feed->exists($format)) {
184 my $feed = create_record_feed(
191 $feed->creator($host);
192 $feed->update_ts(gmtime_ISO8601());
193 $feed->link( unapi => $base);
195 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
196 print entityize($feed->toString) . "\n";
198 return Apache2::Const::OK;
201 my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
205 print "Content-type: text/html; charset=utf-8\n\n";
206 $apache->custom_response( 404, <<" HTML");
209 <title>$type $id not found!</title>
213 <center>Sorry, we couldn't $command a $type with the id of $id in format $format.</center>
220 print "Content-type: application/xml; charset=utf-8\n\n";
221 print $req->gather(1);
223 return Apache2::Const::OK;
229 return Apache2::Const::DECLINED if (-e $apache->filename);
234 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
235 my $rel_name = $cgi->url(-relative=>1);
236 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
239 my $url = $cgi->url(-path_info=>$add_path);
240 my $root = (split 'supercat', $url)[0];
241 my $base = (split 'supercat', $url)[0] . 'supercat';
242 my $path = (split 'supercat', $url)[1];
243 my $unapi = (split 'supercat', $url)[0] . 'unapi';
245 my $host = $cgi->virtual_host || $cgi->server_name;
247 my ($id,$type,$format,$command) = reverse split '/', $path;
250 if ( $path =~ m{^/formats(?:/([^\/]+))?$}o ) {
251 print "Content-type: application/xml; charset=utf-8\n";
254 ->request("open-ils.supercat.$1.formats")
262 <type>text/html</type>
266 my ($type) = keys %$h;
267 print "<format><name>$type</name><type>application/xml</type>";
269 for my $part ( qw/namespace_uri docs schema_location/ ) {
270 print "<$part>$$h{$type}{$part}</$part>"
271 if ($$h{$type}{$part});
277 print "</formats>\n";
279 return Apache2::Const::OK;
283 ->request("open-ils.supercat.record.formats")
288 ->request("open-ils.supercat.metarecord.formats")
292 my %hash = map { ( (keys %$_)[0] => (values %$_)[0] ) } @$list;
293 $list = [ map { { $_ => $hash{$_} } } sort keys %hash ];
298 <type>text/html</type>
302 my ($type) = keys %$h;
303 print "<format><name>$type</name><type>application/xml</type>";
305 for my $part ( qw/namespace_uri docs schema_location/ ) {
306 print "<$part>$$h{$type}{$part}</$part>"
307 if ($$h{$type}{$part});
313 print "</formats>\n";
316 return Apache2::Const::OK;
319 if ($format eq 'opac') {
320 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?m=$id\n\n"
321 if ($type eq 'metarecord');
322 print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
323 if ($type eq 'record');
325 } elsif ($format =~ /^html/o) {
326 my $feed = create_record_feed( $format => [ $id ], $unapi,);
329 $feed->creator($host);
330 $feed->update_ts(gmtime_ISO8601());
332 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
333 print entityize($feed->toString) . "\n";
335 return Apache2::Const::OK;
338 my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
342 print "Content-type: text/html; charset=utf-8\n\n";
343 $apache->custom_response( 404, <<" HTML");
346 <title>$type $id not found!</title>
350 <center>Sorry, we couldn't $command a $type with the id of $id.</center>
357 print "Content-type: application/xml; charset=utf-8\n\n";
358 print entityize( $parser->parse_string( $req->gather(1) )->documentElement->toString );
360 return Apache2::Const::OK;
366 return Apache2::Const::DECLINED if (-e $apache->filename);
370 my $year = (gmtime())[5] + 1900;
371 my $host = $cgi->virtual_host || $cgi->server_name;
374 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
375 my $rel_name = $cgi->url(-relative=>1);
376 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
379 my $url = $cgi->url(-path_info=>$add_path);
380 my $root = (split 'feed', $url)[0];
381 my $base = (split 'bookbag', $url)[0] . 'bookbag';
382 my $path = (split 'bookbag', $url)[1];
383 my $unapi = (split 'feed', $url)[0] . 'unapi';
386 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
388 my ($id,$type) = reverse split '/', $path;
390 my $bucket = $actor->request("open-ils.actor.container.public.flesh", 'biblio', $id)->gather(1);
391 return Apache2::Const::NOT_FOUND unless($bucket);
393 my $bucket_tag = "tag:$host,$year:record_bucket/$id";
394 if ($type eq 'opac') {
395 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
396 join('&', map { "rl=" . $_->target_biblio_record_entry } @{ $bucket->items }) .
401 my $feed = create_record_feed(
403 [ map { $_->target_biblio_record_entry } @{ $bucket->items } ],
408 $feed->title("Items in Book Bag [".$bucket->name."]");
409 $feed->creator($host);
410 $feed->update_ts(gmtime_ISO8601());
412 $feed->link(rss => $base . "/rss2/$id" => 'application/rss+xml');
413 $feed->link(alternate => $base . "/atom/$id" => 'application/atom+xml');
414 $feed->link(html => $base . "/html/$id" => 'text/html');
415 $feed->link(unapi => $unapi);
419 '/opac/en-US/skin/default/xml/rresult.xml?rt=list&' .
420 join('&', map { 'rl=' . $_->target_biblio_record_entry } @{$bucket->items} ),
425 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
426 print entityize($feed->toString) . "\n";
428 return Apache2::Const::OK;
433 return Apache2::Const::DECLINED if (-e $apache->filename);
437 my $year = (gmtime())[5] + 1900;
438 my $host = $cgi->virtual_host || $cgi->server_name;
441 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
442 my $rel_name = $cgi->url(-relative=>1);
443 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
446 my $url = $cgi->url(-path_info=>$add_path);
447 my $root = (split 'feed', $url)[0];
448 my $base = (split 'freshmeat', $url)[0] . 'freshmeat';
449 my $path = (split 'freshmeat', $url)[1];
450 my $unapi = (split 'feed', $url)[0] . 'unapi';
453 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
457 my ($type,$rtype,$axis,$limit,$date) = split '/', $path;
460 my $list = $supercat->request("open-ils.supercat.$rtype.record.$axis.recent", $date, $limit)->gather(1);
462 if ($type eq 'opac') {
463 print "Location: $root/../../en-US/skin/default/xml/rresult.xml?rt=list&" .
464 join('&', map { "rl=" . $_ } @$list) .
469 my $feed = create_record_feed( $type, $list, $unapi);
473 $feed->title("Up to $limit recent $rtype ${axis}s from $date forward");
475 $feed->title("$limit most recent $rtype ${axis}s");
478 $feed->creator($host);
479 $feed->update_ts(gmtime_ISO8601());
481 $feed->link(rss => $base . "/rss2/$rtype/$axis/$limit/$date" => 'application/rss+xml');
482 $feed->link(alternate => $base . "/atom/$rtype/$axis/$limit/$date" => 'application/atom+xml');
483 $feed->link(html => $base . "/html/$rtype/$axis/$limit/$date" => 'text/html');
484 $feed->link(unapi => $unapi);
488 '/opac/en-US/skin/default/xml/rresult.xml?rt=list&' .
489 join('&', map { 'rl=' . $_} @$list ),
494 print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
495 print entityize($feed->toString) . "\n";
497 return Apache2::Const::OK;
506 if ($version eq '1.0') {
508 Content-type: application/opensearchdescription+xml; charset=utf-8
510 <?xml version="1.0" encoding="UTF-8"?>
511 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">
512 <Url>$base/1.0/$lib/-/$class/{searchTerms}?startPage={startPage}&startIndex={startIndex}&count={count}</Url>
513 <Format>http://a9.com/-/spec/opensearchrss/1.0/</Format>
514 <ShortName>$lib</ShortName>
515 <LongName>Search $lib</LongName>
516 <Description>Search the $lib OPAC by $class.</Description>
517 <Tags>$lib book library</Tags>
518 <SampleSearch>harry+potter</SampleSearch>
519 <Developer>Mike Rylander for GPLS/PINES</Developer>
520 <Contact>feedback\@open-ils.org</Contact>
521 <SyndicationRight>open</SyndicationRight>
522 <AdultContent>false</AdultContent>
523 </OpenSearchDescription>
527 Content-type: application/opensearchdescription+xml; charset=utf-8
529 <?xml version="1.0" encoding="UTF-8"?>
530 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
531 <ShortName>$lib</ShortName>
532 <Description>Search the $lib OPAC by $class.</Description>
533 <Tags>$lib book library</Tags>
534 <Url type="application/rss+xml"
535 template="$base/1.1/$lib/rss2/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
536 <Url type="application/atom+xml"
537 template="$base/1.1/$lib/atom/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
538 <Url type="application/x-mods3+xml"
539 template="$base/1.1/$lib/mods3/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
540 <Url type="application/x-mods+xml"
541 template="$base/1.1/$lib/mods/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
542 <Url type="application/x-marcxml+xml"
543 template="$base/1.1/$lib/marcxml/$class/{searchTerms}?startPage={startPage?}&startIndex={startIndex?}&count={count?}&language={language?}"/>
544 <LongName>Search $lib</LongName>
545 <Query role="example" searchTerms="harry+potter" />
546 <Developer>Mike Rylander for GPLS/PINES</Developer>
547 <Contact>feedback\@open-ils.org</Contact>
548 <SyndicationRight>open</SyndicationRight>
549 <AdultContent>false</AdultContent>
550 <Language>en-US</Language>
551 <OutputEncoding>UTF-8</OutputEncoding>
552 <InputEncoding>UTF-8</InputEncoding>
553 </OpenSearchDescription>
557 return Apache2::Const::OK;
560 sub opensearch_feed {
562 return Apache2::Const::DECLINED if (-e $apache->filename);
565 my $year = (gmtime())[5] + 1900;
567 my $host = $cgi->virtual_host || $cgi->server_name;
570 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
571 my $rel_name = $cgi->url(-relative=>1);
572 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
575 my $url = $cgi->url(-path_info=>$add_path);
576 my $root = (split 'opensearch', $url)[0];
577 my $base = (split 'opensearch', $url)[0] . 'opensearch';
578 my $unapi = (split 'opensearch', $url)[0] . 'unapi';
581 my $path = $cgi->path_info;
583 #warn "URL breakdown: $url ($rel_name) -> $root -> $base -> $path -> $unapi";
585 if ($path =~ m{^/?(1\.\d{1})/(?:([^/]+)/)?([^/]+)/osd.xml}o) {
592 $lib = $actor->request(
593 'open-ils.actor.org_unit_list.search' => parent_ou => undef
594 )->gather(1)->[0]->shortname;
601 return opensearch_osd($version, $lib, $class, $base);
605 my $page = $cgi->param('startPage') || 1;
606 my $offset = $cgi->param('startIndex') || 1;
607 my $limit = $cgi->param('count') || 10;
608 my $lang = $cgi->param('language') || 'en-US';
610 $page = 1 if ($page !~ /^\d+$/);
611 $offset = 1 if ($offset !~ /^\d+$/);
612 $limit = 10 if ($limit !~ /^\d+$/); $limit = 25 if ($limit > 25);
613 $lang = 'en-US' if ($lang =~ /^{/ or $lang eq '*');
616 $offset = ($page - 1) * $limit;
621 my ($version,$org,$type,$class,$terms,$sort,$sortdir);
622 (undef,$version,$org,$type,$class,$terms,$sort,$sortdir,$lang) = split '/', $path;
624 $lang ||= $cgi->param('searchLang');
625 $sort ||= $cgi->param('searchSort');
626 $sortdir ||= $cgi->param('searchSortDir');
627 $terms ||= $cgi->param('searchTerms');
628 $class ||= $cgi->param('searchClass') || '-';
629 $type ||= $cgi->param('responseType') || '-';
630 $org ||= $cgi->param('searchOrg') || '-';
632 if ($version eq '1.0') {
634 } elsif ($type eq '-') {
639 $terms = decode_utf8($terms);
642 my $term_copy = $terms;
644 my $complex_terms = 0;
645 if ($terms eq 'help') {
646 print $cgi->header(-type => 'text/html');
650 <title>just type something!</title>
653 <p>You are in a maze of dark, twisty stacks, all alike.</p>
657 return Apache2::Const::OK;
662 while ($term_copy =~ s/((?:keyword|title|author|subject|series|site|dir|sort|lang):[^:]+)$//so) {
663 my ($c,$t) = split ':' => $1;
668 } elsif ($c eq 'sort') {
669 ($sort = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
670 } elsif ($c eq 'dir') {
671 ($sortdir = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
672 } elsif ($c eq 'lang') {
673 ($lang = lc($t)) =~ s/^\s*(\w+)\s*$/$1/go;
675 $$searches{$c}{term} .= ' '.$t;
676 $cache_key .= $c . $t;
683 $class = 'keyword' if ($class eq '-');
684 $$searches{$class}{term} .= " $term_copy";
685 $cache_key .= $class . $term_copy;
690 $org_unit = $actor->request(
691 'open-ils.actor.org_unit_list.search' => parent_ou => undef
694 $org_unit = $actor->request(
695 'open-ils.actor.org_unit_list.search' => shortname => uc($org)
699 $cache_key .= $org.$sort.$sortdir.$lang;
701 my $rs_name = $cgi->cookie('os_session');
702 my $cached_res = OpenSRF::Utils::Cache->new->get_cache( "os_session:$rs_name" ) if ($rs_name);
705 if (!($recs = $$cached_res{os_results}{$cache_key})) {
706 $rs_name = $cgi->remote_host . '::' . rand(time);
707 $recs = $search->request(
708 'open-ils.search.biblio.multiclass' => {
709 searches => $searches,
710 org_unit => $org_unit->[0]->id,
713 ($sort ? ( 'sort' => $sort ) : ()),
714 ($sortdir ? ( 'sort_dir' => $sortdir ) : ($sort ? (sort_dir => 'asc') : (sort_dir => 'desc') )),
715 ($lang ? ( 'language' => $lang ) : ()),
719 $$cached_res{os_results}{$cache_key} = $recs;
720 OpenSRF::Utils::Cache->new->put_cache( "os_session:$rs_name", $cached_res, 1800 );
726 my $feed = create_record_feed(
728 [ map { $_->[0] } @{$recs->{ids}}[$offset .. $offset + $limit - 1] ],
734 $feed->search($terms);
735 $feed->class($class);
737 if ($complex_terms) {
738 $feed->title("Search results for [$terms] at ".$org_unit->[0]->name);
740 $feed->title("Search results for [$class => $terms] at ".$org_unit->[0]->name);
743 $feed->creator($host);
744 $feed->update_ts(gmtime_ISO8601());
748 'http://a9.com/-/spec/opensearch/1.1/',
755 'http://a9.com/-/spec/opensearch/1.1/',
762 'http://a9.com/-/spec/opensearch/1.1/',
769 $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int($offset + $limit + 1) . "&count=" . $limit =>
770 'application/opensearch+xml'
771 ) if ($offset + $limit < $recs->{count});
775 $base . "/$version/$org/$type/$class?searchTerms=$terms&startIndex=" . int(($offset - $limit) + 1) . "&count=" . $limit =>
776 'application/opensearch+xml'
781 $base . "/$version/$org/$type/$class?searchTerms=$terms" =>
782 'application/opensearch+xml'
787 $base . "/$version/$org/rss2/$class?searchTerms=$terms" =>
788 'application/rss+xml'
793 $base . "/$version/$org/atom/$class?searchTerms=$terms" =>
794 'application/atom+xml'
799 $base . "/$version/$org/html/$class?searchTerms=$terms" =>
803 $feed->link( unapi => $unapi);
807 $root . "../$lang/skin/default/xml/rresult.xml?rt=list&" .
808 join('&', map { 'rl=' . $_->[0] } grep { ref $_ && defined $_->[0] } @{$recs->{ids}} ),
813 -type => $feed->type,
815 -cookie => $cgi->cookie( -name => 'os_session', -value => $rs_name, -expires => '+30m' ),
818 print entityize($feed->toString) . "\n";
820 return Apache2::Const::OK;
823 sub create_record_feed {
828 my $lib = shift || '-';
831 my $base = $cgi->url;
832 my $host = $cgi->virtual_host || $cgi->server_name;
834 my $year = (gmtime())[5] + 1900;
836 my $feed = new OpenILS::WWW::SuperCat::Feed ($type);
838 $feed->unapi($unapi);
840 $type = 'atom' if ($type eq 'html');
841 $type = 'marcxml' if ($type eq 'htmlcard' or $type eq 'htmlholdings');
843 #$records = $supercat->request( "open-ils.supercat.record.object.retrieve", $records )->gather(1);
845 for my $record (@$records) {
846 next unless($record);
848 #my $rec = $record->id;
851 my $item_tag = "tag:$host,$year:biblio-record_entry/$rec/$lib";
853 my $xml = $supercat->request(
854 "open-ils.supercat.record.$type.retrieve",
859 my $node = $feed->add_item($xml);
862 if ($lib && $type eq 'marcxml') {
863 $xml = $supercat->request( "open-ils.supercat.record.holdings_xml.retrieve", $rec, $lib )->gather(1);
864 $node->add_holdings($xml);
867 $node->id($item_tag);
868 #$node->update_ts(clense_ISO8601($record->edit_date));
869 $node->link(alternate => $feed->unapi . "?id=$item_tag&format=htmlholdings" => 'text/html');
870 $node->link(opac => $feed->unapi . "?id=$item_tag&format=opac");
871 $node->link(unapi => $feed->unapi . "?id=$item_tag");
872 $node->link('unapi-id' => $item_tag);
879 my $stuff = NFC(shift());
880 $stuff =~ s/&(?!\S+;)/&/gso;
881 $stuff =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe;
890 my $year = (gmtime())[5] + 1900;
893 $content .= "Content-type: application/xml\n\n";
894 $content .= "<hold:volumes xmlns:hold='http://open-ils.org/spec/holdings/v1'>";
896 for my $cn (@$tree) {
897 (my $cn_class = $cn->class_name) =~ s/::/-/gso;
898 $cn_class =~ s/Fieldmapper-//gso;
900 my $cn_tag = "tag:open-ils.org,$year:$cn_class/".$cn->id;
901 my $cn_lib = $cn->owning_lib->shortname;
902 my $cn_label = $cn->label;
904 (my $ou_class = $cn->owning_lib->class_name) =~ s/::/-/gso;
905 $ou_class =~ s/Fieldmapper-//gso;
907 my $ou_tag = "tag:open-ils.org,$year:$ou_class/".$cn->owning_lib->id;
908 my $ou_name = $cn->owning_lib->name;
910 $content .= "<hold:volume id='$cn_tag' lib='$cn_lib' label='$cn_label'>";
911 $content .= "<act:owning_lib xmlns:act='http://open-ils.org/spec/actors/v1' id='$ou_tag' name='$ou_name'/>";
912 $content .= $cn->record->marc;
913 $content .= "</hold:volume>";
916 $content .= '</hold:volumes>';
924 return Apache2::Const::DECLINED if (-e $apache->filename);
927 my $year = (gmtime())[5] + 1900;
929 my $host = $cgi->virtual_host || $cgi->server_name;
932 if ( $cgi->server_software !~ m|^Apache/2.2| ) {
933 my $rel_name = $cgi->url(-relative=>1);
934 $add_path = 1 if ($cgi->url(-path_info=>1) !~ /$rel_name$/);
937 my $url = $cgi->url(-path_info=>$add_path);
938 my $root = (split 'browse', $url)[0];
939 my $base = (split 'browse', $url)[0] . 'browse';
940 my $unapi = (split 'browse', $url)[0] . 'unapi';
943 my $path = (split 'browse', $url)[1];
945 my (undef,$format,$axis,$site,$string,$page,$page_size) = split '/', $path;
948 $site ||= $cgi->param('searchOrg');
949 $page ||= $cgi->param('startPage') || 0;
950 $page_size ||= $cgi->param('count') || 9;
952 $page = 0 if ($page !~ /^\d+$/);
954 unless ($string and $axis and grep { $axis eq $_ } keys %browse_types) {
955 warn "something's wrong...";
959 $string = decode_utf8($string);
960 $string =~ s/\+/ /go;
963 my $tree = $supercat->request(
964 "open-ils.supercat.$axis.browse",
971 my $content = $browse_types{$axis}{$format}->($tree);
973 return Apache2::Const::OK;