[open-ils-commits] r13424 - in trunk/Open-ILS: src/perlmods/OpenILS/WWW src/perlmods/OpenILS/WWW/SuperCat web/opac/locale/en-US web/opac/skin/default/js web/opac/skin/default/xml xsl (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Jun 19 17:24:35 EDT 2009


Author: miker
Date: 2009-06-19 17:24:30 -0400 (Fri, 19 Jun 2009)
New Revision: 13424

Added:
   trunk/Open-ILS/xsl/MARC21slim2MARCtxt.xsl
Modified:
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
   trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm
   trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
   trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
   trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml
Log:
Patch from Warren Layton implementing RefWorks export via SuperCat:

"The patch a new transform, MARC21slim2MARCtxt.xsl, which converts MARC
into the MARC-ish plain text format accepted by RefWorks (see [1]).
The patch also adds a new feed to SuperCat, called "marctxt"."

As well as a reworked patch for the default opac skin to expose this
functionality as a link next to the "Place a Hold" link.



Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm	2009-06-19 20:55:20 UTC (rev 13423)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm	2009-06-19 21:24:30 UTC (rev 13424)
@@ -744,4 +744,57 @@
 package OpenILS::WWW::SuperCat::Feed::htmlholdings::item;
 use base 'OpenILS::WWW::SuperCat::Feed::htmlcard::item';
 
+
+package OpenILS::WWW::SuperCat::Feed::marctxt;
+use base 'OpenILS::WWW::SuperCat::Feed::marcxml';
+
+sub new {
+	my $class = shift;
+	my $self = $class->SUPER::new;
+	$self->{type} = 'text/plain';
+	$self->{xsl} = "/MARC21slim2MARCtxt.xsl";
+	return $self;
+}
+
+
+our ($_parser, $_xslt, $xslt_file);
+
+sub toString {
+	my $self = shift;
+	my $base = $self->base || '';
+	my $root = $self->root || '';
+	my $search = $self->search || '';
+	my $class = $self->class || '';
+	my $lib = $self->lib || '-';
+
+	$self->composeDoc;
+
+        $_parser ||= new XML::LibXML;
+        $_xslt ||= new XML::LibXSLT;
+
+	$xslt_file ||=
+                OpenSRF::Utils::SettingsClient
+       	                ->new
+               	        ->config_value( dirs => 'xsl' ).
+                $self->{xsl};
+
+        # parse the MARC text xslt ...
+        my $marctxt_xslt = $_xslt->parse_stylesheet( $_parser->parse_file($xslt_file) );
+
+	my $new_doc = $marctxt_xslt->transform(
+		$self->{doc},
+		base_dir => "'$root'",
+		lib => "'$lib'",
+		searchTerms => "'$search'",
+		searchClass => "'$class'",
+	);
+
+	return $marctxt_xslt->output_string($new_doc); 
+}
+
+
+package OpenILS::WWW::SuperCat::Feed::marctxt::item;
+use base 'OpenILS::WWW::SuperCat::Feed::marcxml::item';
+
+
 1;

Modified: trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2009-06-19 20:55:20 UTC (rev 13423)
+++ trunk/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm	2009-06-19 21:24:30 UTC (rev 13424)
@@ -145,7 +145,7 @@
 		->gather(1);
 
     $list = [ map { (keys %$_)[0] } @$list ];
-    push @$list, 'htmlholdings','html';
+    push @$list, 'htmlholdings','html', 'marctxt';
 
     for my $browse_axis ( qw/title author subject topic series item-age/ ) {
         for my $record_browse_format ( @$list ) {
@@ -256,6 +256,7 @@
 	<format name='htmlholdings' type='text/html'/>
 	<format name='html-full' type='text/html'/>
 	<format name='htmlholdings-full' type='text/html'/>
+	<format name='marctxt' type='text/plain'/>
 				FORMATS
 			} elsif ($type eq 'metarecord') {
 				$body .= <<"				FORMATS";
@@ -310,6 +311,7 @@
 	<format name='htmlholdings' type='text/html'/>
 	<format name='html-full' type='text/html'/>
 	<format name='htmlholdings-full' type='text/html'/>
+	<format name='marctxt' type='text/plain'/>
 			FORMATS
 
 
@@ -402,7 +404,7 @@
 	       @{ $supercat->request("open-ils.supercat.$type.formats")->gather(1) }
 	     and !grep
 	       { $_ eq $base_format }
-	       qw/opac html htmlholdings/
+	       qw/opac html htmlholdings marctxt/
 	) {
 		print "Content-type: text/html; charset=utf-8\n\n";
 		$apache->custom_response( 406, <<"		HTML");
@@ -541,6 +543,10 @@
 				   <format>
 				     <name>html-full</name>
 				     <type>text/html</type>
+				   </format>
+				   <format>
+				     <name>marctxt</name>
+				     <type>text/plain</type>
 				   </format>";
 			}
 
@@ -606,6 +612,10 @@
 			   <format>
 			     <name>html-full</name>
 			     <type>text/html</type>
+			   </format>
+			   <format>
+			     <name>marctxt</name>
+			     <type>text/plain</type>
 			   </format>";
 
 		for my $h (@$list) {
@@ -1210,7 +1220,7 @@
 	$feed->unapi($unapi) if ($flesh);
 
 	$type = 'atom' if ($type eq 'html');
-	$type = 'marcxml' if ($type eq 'htmlholdings');
+	$type = 'marcxml' if (($type eq 'htmlholdings') || ($type eq 'marctxt'));
 
 	#$records = $supercat->request( "open-ils.supercat.record.object.retrieve", $records )->gather(1);
 

Modified: trunk/Open-ILS/web/opac/locale/en-US/opac.dtd
===================================================================
--- trunk/Open-ILS/web/opac/locale/en-US/opac.dtd	2009-06-19 20:55:20 UTC (rev 13423)
+++ trunk/Open-ILS/web/opac/locale/en-US/opac.dtd	2009-06-19 21:24:30 UTC (rev 13424)
@@ -434,6 +434,7 @@
 <!ENTITY opac.holds.xulRecipient "Enter recipient barcode">
 <!ENTITY opac.holds.recipient "Recipient">
 <!ENTITY opac.holds.placeHold "Place Hold">
+<!ENTITY opac.holds.exportRefWorks "Export to RefWorks">
 <!ENTITY opac.holds.contactPhone "Contact telephone number">
 <!ENTITY opac.holds.contactEmail "Contact email address">
 <!ENTITY opac.holds.pickupLocation "Pickup location">

Modified: trunk/Open-ILS/web/opac/skin/default/js/rdetail.js
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/js/rdetail.js	2009-06-19 20:55:20 UTC (rev 13423)
+++ trunk/Open-ILS/web/opac/skin/default/js/rdetail.js	2009-06-19 21:24:30 UTC (rev 13424)
@@ -368,6 +368,25 @@
 	$('rdetail_place_hold').setAttribute(
 			'href','javascript:holdsDrawEditor({record:"'+record.doc_id()+'",type:"T"});');
 
+    var RW = $('rdetail_exp_refworks');
+    if (RW) {
+
+        var here = (findOrgUnit(getLocation())).name();
+        var org_name = here.replace(" ", "+");
+        var cgi = new CGI();
+        
+    	RW.setAttribute(
+                'href',
+                'http://www.refworks.com/express/expressimport.asp?vendor='
+                    + org_name
+                    + '&filter=MARC+Format&database=All+MARC+Formats&encoding=65001&url=http%3A%2F%2F'
+                    + cgi.server_name+'/opac/extras/supercat/marctxt/record/'
+                    + record.doc_id()
+        );
+
+    	RW.setAttribute('target', 'RefWorksMain');
+    }
+
 	$('rdetail_img_link').setAttribute('href', buildISBNSrc(cleanISBN(record.isbn()), 'large'));
 	G.ui.rdetail.image.setAttribute("src", buildISBNSrc(cleanISBN(record.isbn())));
 	runEvt("rdetail", "recordDrawn");

Modified: trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml
===================================================================
--- trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml	2009-06-19 20:55:20 UTC (rev 13423)
+++ trunk/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml	2009-06-19 21:24:30 UTC (rev 13424)
@@ -51,8 +51,12 @@
 					<span>&rdetail.detailMain.headerLabel;</span>
 				</td>
 
-				<td align='right' style='padding-right: 7px;' width='33%'>
-					<span style='padding-right: 7px;'>
+                <td align='right' style='padding-right: 7px;' width='33%'>
+				    <span style='padding-right: 7px;'>
+                        <a id='rdetail_exp_refworks'>&opac.holds.exportRefWorks;</a>
+                   </span>
+                   <span style='padding-right: 7px;'>
+
 						<a id='rdetail_place_hold' class='classic_link'>&opac.holds.placeHold;</a>
 					</span>
 					<span style='padding-right: 7px;' class='hide_me' id='rdetail_more_actions'>

Added: trunk/Open-ILS/xsl/MARC21slim2MARCtxt.xsl
===================================================================
--- trunk/Open-ILS/xsl/MARC21slim2MARCtxt.xsl	                        (rev 0)
+++ trunk/Open-ILS/xsl/MARC21slim2MARCtxt.xsl	2009-06-19 21:24:30 UTC (rev 13424)
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" exclude-result-prefixes="marc">
+    <xsl:output method="text"/>
+
+    <xsl:template match="marc:record">
+       <xsl:text>&#10;LEADER </xsl:text>
+       <xsl:value-of select="marc:leader"/>
+        
+        <xsl:for-each select="marc:controlfield">
+            <xsl:text>&#10;</xsl:text>
+            <xsl:value-of select="@tag"/>
+            <xsl:text>    </xsl:text>
+            <xsl:value-of select="marc:controlfield"/>
+            <xsl:value-of select="."/>
+        </xsl:for-each>
+
+        <xsl:for-each select="marc:datafield">
+            <xsl:text>&#10;</xsl:text>
+            <xsl:value-of select="@tag"/>
+            <xsl:text> </xsl:text>
+            <xsl:value-of select="@ind1"/>
+            <xsl:value-of select="@ind2"/>
+            <xsl:text> </xsl:text>
+            <xsl:for-each select="marc:subfield">
+                <xsl:if test="@code != 'a'">
+                    <xsl:text>|</xsl:text>
+                    <xsl:value-of select="@code"/>
+                </xsl:if>
+                <xsl:value-of select="."/>
+            </xsl:for-each>
+        </xsl:for-each>
+
+       <xsl:text>&#10;</xsl:text>
+	</xsl:template>
+</xsl:stylesheet>
+



More information about the open-ils-commits mailing list