my $apache = shift;
return Apache2::Const::DECLINED if (-e $apache->filename);
- print "Content-type: application/xml; charset=utf-8\n";
-
my $cgi = new CGI;
+ my $rel_name = quotemeta($cgi->url(-relative=>1));
+
+ my $add_path = 1;
+ $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
+
+
+ my $url = $cgi->url(-path_info=>$add_path);
+ my $root = (split 'unapi', $url)[0];
+ my $base = (split 'unapi', $url)[0] . 'unapi';
+
my $uri = $cgi->param('uri') || '';
- my $base = $cgi->url;
my $host = $cgi->virtual_host || $cgi->server_name;
my $format = $cgi->param('format');
my ($id,$type,$command) = ('','','');
if (!$format) {
+ print "Content-type: application/xml; charset=utf-8\n";
+
if ($uri =~ m{^tag:[^:]+:([^\/]+)/(\d+)}o) {
$id = $2;
$type = 'record';
print "Location: $base/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
if ($type eq 'record');
return 302;
+ } elsif ($format =~ /^html/o) {
+ my $feed = create_record_feed(
+ $format => [ $id ],
+ $base,
+ );
+
+ $feed->root($root);
+ $feed->creator($host);
+ $feed->update_ts(gmtime_ISO8601());
+
+ print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
+ print entityize($feed->toString) . "\n";
+
+ return Apache2::Const::OK;
}
- print "\n" . $supercat->request("open-ils.supercat.$type.$format.$command",$id)->gather(1);
+ my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
+ $req->wait_complete;
+
+ if ($req->failed) {
+ print "Content-type: text/html; charset=utf-8\n\n";
+ $apache->custom_response( 404, <<" HTML");
+ <html>
+ <head>
+ <title>$type $id not found!</title>
+ </head>
+ <body>
+ <br/>
+ <center>Sorry, we couldn't $command a $type with the id of $id.</center>
+ </body>
+ </html>
+ HTML
+ return 404;
+ }
+
+ print "Content-type: application/xml; charset=utf-8\n\n";
+ print $req->gather(1);
return Apache2::Const::OK;
}
my $apache = shift;
return Apache2::Const::DECLINED if (-e $apache->filename);
- my $path = $apache->path_info;
-
my $cgi = new CGI;
- my $base = $cgi->url;
+
+ my $rel_name = quotemeta($cgi->url(-relative=>1));
+
+ my $add_path = 1;
+ $add_path = 0 if ($cgi->url(-path_info=>1) =~ /$rel_name$/);
+
+
+ my $url = $cgi->url(-path_info=>$add_path);
+ my $root = (split 'supercat', $url)[0];
+ my $base = (split 'supercat', $url)[0] . 'supercat';
+ my $path = (split 'supercat', $url)[1];
+ my $unapi = (split 'supercat', $url)[0] . 'unapi';
+
+ my $host = $cgi->virtual_host || $cgi->server_name;
my ($id,$type,$format,$command) = reverse split '/', $path;
- print "Content-type: application/xml; charset=utf-8\n";
if ( $path =~ m{^/formats(?:/([^\/]+))?$}o ) {
+ print "Content-type: application/xml; charset=utf-8\n";
if ($1) {
my $list = $supercat
->request("open-ils.supercat.$1.formats")
print "Location: $base/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
if ($type eq 'record');
return 302;
+ } elsif ($format =~ /^html/o) {
+ my $feed = create_record_feed( $format => [ $id ], $unapi,);
+
+ $feed->root($root);
+ $feed->creator($host);
+ $feed->update_ts(gmtime_ISO8601());
+
+ print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
+ print entityize($feed->toString) . "\n";
+
+ return Apache2::Const::OK;
+ }
+
+ my $req = $supercat->request("open-ils.supercat.$type.$format.$command",$id);
+ $req->wait_complete;
+
+ if ($req->failed) {
+ print "Content-type: text/html; charset=utf-8\n\n";
+ $apache->custom_response( 404, <<" HTML");
+ <html>
+ <head>
+ <title>$type $id not found!</title>
+ </head>
+ <body>
+ <br/>
+ <center>Sorry, we couldn't $command a $type with the id of $id.</center>
+ </body>
+ </html>
+ HTML
+ return 404;
}
- print "\n" . $supercat->request("open-ils.supercat.$type.$format.$command",$id)->gather(1);
+ print "Content-type: application/xml; charset=utf-8\n\n";
+ print $req->gather(1);
return Apache2::Const::OK;
}
$feed->unapi($unapi);
$type = 'atom' if ($type eq 'html');
+ $type = 'marcxml' if ($type eq 'htmlcard');
for my $rec (@$records) {
my $item_tag = "tag:$host,$year:biblio-record_entry/" . $rec;
package OpenILS::WWW::SuperCat::Feed::html::item;
use base 'OpenILS::WWW::SuperCat::Feed::atom::item';
+#----------------------------------------------------------
+
+package OpenILS::WWW::SuperCat::Feed::htmlcard;
+use base 'OpenILS::WWW::SuperCat::Feed::marcxml';
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new;
+ $self->type('text/html');
+ 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 $lib = $self->lib || '-';
+
+ $self->composeDoc;
+
+ $_parser ||= new XML::LibXML;
+ $_xslt ||= new XML::LibXSLT;
+
+ $xslt_file ||=
+ OpenSRF::Utils::SettingsClient
+ ->new
+ ->config_value( dirs => 'xsl' ).
+ "/MARC21slim2HTMLCard.xsl";
+
+ # parse the MODS xslt ...
+ my $atom2html_xslt = $_xslt->parse_stylesheet( $_parser->parse_file($xslt_file) );
+
+ my $new_doc = $atom2html_xslt->transform(
+ $self->{doc},
+ base_dir => "'$root'",
+ lib => "'$lib'",
+ searchTerms => "'$search'",
+ );
+
+ return $new_doc->toString(1);
+}
+
+
+package OpenILS::WWW::SuperCat::Feed::htmlcard::item;
+use base 'OpenILS::WWW::SuperCat::Feed::marcxml::item';
+
1;
--- /dev/null
+html { font: 9pt Verdana, Arial, "Arial Unicode MS", Helvetica, sans-serif; line-height: 1.4em; text-align: left; }
+blockquote { margin-left: 20px; margin-bottom: 1em; }
+body { background: #FFF; margin: 1pc; padding: 0;}
+p.mainheading { font-weight:bold; margin-bottom: 0pt;margin-top:0pt}
+span.title { font-style:italic; text-indent:15pt;}
+span.titlemain { font-style:italic; text-indent:0pt; font-weight:bold;}
+span.counter { font-weight:bold; padding-left:6pt; padding-right:4pt; }
+p.note { font-size:8pt; margin-bottom:0pt; margin-top:0pt;}
+p.extent { margin-bottom:0pt; margin-top:0pt; text-indent:15pt;}
+span.link { clear:left;}
+span.DDC { margin-left:6pt; font-weight:bold; }
+span.LCCN { font-style:italic; font-family:times;}
+div.cardimage { background: ivory; width:350pt;border:brown solid 1px;padding:10pt;}
+span.oclc {font-family:fixed;}
+span.bottom { display:block; text-align:right;}
div#searchdiv {
z-index:10;
position: absolute;
- top: 100;
+ top: 0;
right: 0;
width:11em;
background-color: lightgray;
border:2px solid lightblue;
border-right: 0px;
+ border-top: 0px;
filter: alpha(opacity=50);
-moz-opacity: .5;
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:marc="http://www.loc.gov/MARC21/slim"
+ version="1.0">
+ <xsl:output method="html" doctype-public="-//W3C/DTD HTML 4.01 Transitional//EN" doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
+ <xsl:template match="/">
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
+ <link href="{$base_dir}/htmlcard.css" rel="stylesheet" type="text/css" />
+ </head>
+ <body>
+ <xsl:apply-templates select="//marc:record"/>
+ </body>
+ </html>
+ </xsl:template>
+
+ <xsl:template match="marc:record">
+ <div class="cardimage">
+ <xsl:apply-templates select="marc:datafield[@tag!='082' and @tag!='092' and @tag!='010']"/>
+ <span class="bottom">
+ <xsl:apply-templates select="marc:controlfield[@tag='001']"/>
+ <xsl:apply-templates select="marc:datafield[@tag='082' or @tag='092' or @tag='010']"/>
+ </span>
+ </div>
+ <br/>
+ </xsl:template>
+
+ <xsl:template match="marc:controlfield">
+ <span class="oclc">#<xsl:value-of select="substring(.,4)"/></span>
+ </xsl:template>
+
+ <xsl:template match="marc:datafield">
+ <xsl:if test="starts-with(@tag, '1')">
+ <p class="mainheading"><xsl:value-of select="."/></p>
+ </xsl:if>
+
+ <xsl:if test="starts-with(@tag, '24') and /marc:record/marc:datafield[@tag='100']">
+ <span class="title"><xsl:value-of select="."/></span>
+ </xsl:if>
+
+ <xsl:if test="starts-with(@tag, '24') and not(/marc:record/marc:datafield[@tag='100'])">
+ <span class="titlemain"><xsl:value-of select="."/></span><br/>
+ </xsl:if>
+
+ <xsl:if test="@tag='260'">
+ <xsl:value-of select="."/>
+ </xsl:if>
+
+ <xsl:if test="@tag='300'">
+ <p class="extent"><xsl:value-of select="."/></p>
+ </xsl:if>
+
+ <xsl:if test="starts-with(@tag, '5')">
+ <p class="note"><xsl:value-of select="."/></p>
+ </xsl:if>
+
+ <xsl:if test="@tag='650'">
+ <span class='counter'><xsl:number count="marc:datafield[@tag='650']"/>.</span> <xsl:apply-templates select="marc:subfield"/>
+ </xsl:if>
+
+ <xsl:if test="@tag='653'">
+ <span class="counter"><xsl:number format="i" count="marc:datafield[@tag='653']"/>.</span> <xsl:apply-templates select="marc:subfield"/>
+ </xsl:if>
+
+ <xsl:if test="@tag='010'">
+ <xsl:variable name="LCCN.nospace" select="translate(., ' ', '')"/>
+ <xsl:variable name="LCCN.length" select="string-length($LCCN.nospace)"/>
+ <xsl:variable name="LCCN.display" select="concat(substring($LCCN.nospace, 1, $LCCN.length - 6), '-', format-number(substring($LCCN.nospace, $LCCN.length - 5),'#'))"/>
+ <span class="LCCN">LCCN:<xsl:value-of select="$LCCN.display"/></span>
+ </xsl:if>
+
+ <xsl:if test="@tag='082' or @tag='092'">
+ <span class="DDC"><xsl:value-of select="marc:subfield[@code='a']"/></span>
+ </xsl:if>
+
+ <xsl:if test="@tag='856'">
+ <br/><xsl:apply-templates mode="link" select="marc:subfield" />
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="marc:subfield" mode="link">
+ <xsl:if test="@code='u'">
+ <span class="link">
+ <a class="url" href="{.}"/>
+ </span>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template match="marc:subfield">
+ <xsl:if test="@code!='2'">
+ <xsl:if test="@code!='a'">--</xsl:if>
+ <xsl:value-of select="."/>
+ </xsl:if>
+ </xsl:template>
+
+</xsl:stylesheet>