From b84501479e851edb41d9849e550a1d083aa45c91 Mon Sep 17 00:00:00 2001 From: miker Date: Fri, 19 Jun 2009 21:24:30 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.open-ils.org/ILS/trunk@13424 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm | 16 +++++-- Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm | 53 ++++++++++++++++++++++ Open-ILS/web/opac/locale/en-US/opac.dtd | 1 + Open-ILS/web/opac/skin/default/js/rdetail.js | 19 ++++++++ .../web/opac/skin/default/xml/page_rdetail.xml | 8 +++- Open-ILS/xsl/MARC21slim2MARCtxt.xsl | 36 +++++++++++++++ 6 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/xsl/MARC21slim2MARCtxt.xsl diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm index 16f23e616c..55d54c072f 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm @@ -145,7 +145,7 @@ sub child_init { ->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 @@ sub unapi { + FORMATS } elsif ($type eq 'metarecord') { $body .= <<" FORMATS"; @@ -310,6 +311,7 @@ sub unapi { + FORMATS @@ -402,7 +404,7 @@ sub unapi { @{ $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 @@ sub supercat { html-full text/html + + + marctxt + text/plain "; } @@ -606,6 +612,10 @@ sub supercat { html-full text/html + + + marctxt + text/plain "; for my $h (@$list) { @@ -1210,7 +1220,7 @@ sub create_record_feed { $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); diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm index 27f9d6b032..5c1687243d 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm @@ -744,4 +744,57 @@ sub new { 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; diff --git a/Open-ILS/web/opac/locale/en-US/opac.dtd b/Open-ILS/web/opac/locale/en-US/opac.dtd index fdaf6562a3..f920c1e111 100644 --- a/Open-ILS/web/opac/locale/en-US/opac.dtd +++ b/Open-ILS/web/opac/locale/en-US/opac.dtd @@ -434,6 +434,7 @@ Please see a librarian to renew your account."> + diff --git a/Open-ILS/web/opac/skin/default/js/rdetail.js b/Open-ILS/web/opac/skin/default/js/rdetail.js index 5c81e45f30..ff81d9f98e 100644 --- a/Open-ILS/web/opac/skin/default/js/rdetail.js +++ b/Open-ILS/web/opac/skin/default/js/rdetail.js @@ -368,6 +368,25 @@ function _rdetailDraw(r) { $('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"); diff --git a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml b/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml index 9d259ce59f..b91dbd46a2 100644 --- a/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml +++ b/Open-ILS/web/opac/skin/default/xml/page_rdetail.xml @@ -51,8 +51,12 @@ &rdetail.detailMain.headerLabel; - - + + + &opac.holds.exportRefWorks; + + + &opac.holds.placeHold; diff --git a/Open-ILS/xsl/MARC21slim2MARCtxt.xsl b/Open-ILS/xsl/MARC21slim2MARCtxt.xsl new file mode 100644 index 0000000000..5cf6d93b43 --- /dev/null +++ b/Open-ILS/xsl/MARC21slim2MARCtxt.xsl @@ -0,0 +1,36 @@ + + + + + + LEADER + + + + + + + + + + + + + + + + + + + + | + + + + + + + + + + -- 2.11.0