[open-ils-commits] r954 - in conifer/branches/rel_1_6_0/src/perlmods/OpenILS: . WWW (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Aug 11 13:47:52 EDT 2010


Author: dbs
Date: 2010-08-11 13:47:48 -0400 (Wed, 11 Aug 2010)
New Revision: 954

Removed:
   conifer/branches/rel_1_6_0/src/perlmods/OpenILS/Utils/
Modified:
   conifer/branches/rel_1_6_0/src/perlmods/OpenILS/WWW/SuperCat.pm
Log:
Bring SRU goodness to OpenILS::WWW::SuperCat


Modified: conifer/branches/rel_1_6_0/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- conifer/branches/rel_1_6_0/src/perlmods/OpenILS/WWW/SuperCat.pm	2010-08-11 17:42:12 UTC (rev 953)
+++ conifer/branches/rel_1_6_0/src/perlmods/OpenILS/WWW/SuperCat.pm	2010-08-11 17:47:48 UTC (rev 954)
@@ -145,7 +145,7 @@
 		->gather(1);
 
     $list = [ map { (keys %$_)[0] } @$list ];
-    push @$list, 'htmlholdings','html', 'marctxt';
+    push @$list, 'htmlholdings','html', 'marctxt', 'ris';
 
     for my $browse_axis ( qw/title author subject topic series item-age/ ) {
         for my $record_browse_format ( @$list ) {
@@ -260,6 +260,7 @@
 	<format name='html-full' type='text/html'/>
 	<format name='htmlholdings-full' type='text/html'/>
 	<format name='marctxt' type='text/plain'/>
+	<format name='ris' type='text/plain'/>
 				FORMATS
 			} elsif ($type eq 'metarecord') {
 				$body .= <<"				FORMATS";
@@ -315,6 +316,7 @@
 	<format name='html-full' type='text/html'/>
 	<format name='htmlholdings-full' type='text/html'/>
 	<format name='marctxt' type='text/plain'/>
+	<format name='ris' type='text/plain'/>
 			FORMATS
 
 
@@ -407,7 +409,7 @@
 	       @{ $supercat->request("open-ils.supercat.$type.formats")->gather(1) }
 	     and !grep
 	       { $_ eq $base_format }
-	       qw/opac html htmlholdings marctxt/
+	       qw/opac html htmlholdings marctxt ris/
 	) {
 		print "Content-type: text/html; charset=utf-8\n\n";
 		$apache->custom_response( 406, <<"		HTML");
@@ -553,6 +555,10 @@
 				   <format>
 				     <name>marctxt</name>
 				     <type>text/plain</type>
+				   </format>
+				   <format>
+				     <name>ris</name>
+				     <type>text/plain</type>
 				   </format>";
 			}
 
@@ -622,6 +628,10 @@
 			   <format>
 			     <name>marctxt</name>
 			     <type>text/plain</type>
+			   </format>
+			   <format>
+			     <name>ris</name>
+			     <type>text/plain</type>
 			   </format>";
 
 		for my $h (@$list) {
@@ -1232,7 +1242,7 @@
 	$feed->unapi($unapi) if ($flesh);
 
 	$type = 'atom' if ($type eq 'html');
-	$type = 'marcxml' if (($type eq 'htmlholdings') || ($type eq 'marctxt'));
+	$type = 'marcxml' if (($type eq 'htmlholdings') || ($type eq 'marctxt') || ($type eq 'ris'));
 
 	#$records = $supercat->request( "open-ils.supercat.record.object.retrieve", $records )->gather(1);
 
@@ -1410,7 +1420,7 @@
     'bib.titlealternative'  => 'title',
     'bib.titleseries'       => 'series',
     'eg.series'             => 'title',
-    'eg.identifier'             => 'keyword|identifier',
+    'eg.identifier'         => 'keyword|identifier',
 
     # Author/Name class:
     'eg.author'             => 'author',
@@ -1658,7 +1668,7 @@
 			'open-ils.search.biblio.multiclass.query' => {offset => $offset, limit => $limit} => $search_string => 1
 		)->gather(1);
 
-        my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
+		my $bre = $supercat->request( 'open-ils.supercat.record.object.retrieve' => [ map { $_->[0] } @{$recs->{ids}} ] )->gather(1);
 
 		foreach my $record (@$bre) {
 			my $marcxml = $record->marc;
@@ -1669,6 +1679,13 @@
 				my $bib_holdings = $supercat->request('open-ils.supercat.record.basic_holdings.retrieve', $record->id, $shortname || '-')->gather(1);
 				my $marc = MARC::Record->new_from_xml($marcxml, 'UTF8', 'XML');
 
+				# Force record leader to 'a' as our data is always UTF8
+				# Avoids marc8_to_utf8 from being invoked with horrible results
+				# on the off-chance the record leader isn't correct
+				my $ldr = $marc->leader;
+				substr($ldr, 9, 1, 'a');
+				$marc->leader($ldr);
+
 				# Expects the record ID in the 001
 				$marc->delete_field($_) for ($marc->field('001'));
 				if (!$marc->field('001')) {
@@ -1703,7 +1720,8 @@
 					)
 				);
 
-				$marcxml = $marc->as_xml_record();
+				# Ensure the data is encoded as UTF8 before we hand it off
+				$marcxml = encode_utf8($marc->as_xml_record());
 				$marcxml =~ s/^<\?xml version="1.0" encoding="UTF-8"\?>//o;
 
 			}
@@ -1716,9 +1734,9 @@
 			);
 		}
 
-        $resp->numberOfRecords($recs->{count});
+		$resp->numberOfRecords($recs->{count});
 
-    } elsif ( $resp->type eq 'explain' ) {
+	} elsif ( $resp->type eq 'explain' ) {
 		if (!$ex_doc) {
 			my $host = $cgi->virtual_host || $cgi->server_name;
 
@@ -1783,9 +1801,9 @@
 		);
 	}
 
-   	print $cgi->header( -type => 'application/xml' );
-   	print $U->entityize($resp->asXML) . "\n";
-    return Apache2::Const::OK;
+	print $cgi->header( -type => 'application/xml' );
+	print $U->entityize($resp->asXML) . "\n";
+	return Apache2::Const::OK;
 }
 
 



More information about the open-ils-commits mailing list