improving unapi support; fixing oia and rdf support
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 26 Jun 2006 23:25:11 +0000 (23:25 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 26 Jun 2006 23:25:11 +0000 (23:25 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@4795 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm
Open-ILS/xsl/MARC21slim2HTMLCard-holdings.xsl

index 042d8e9..f3907ba 100644 (file)
@@ -180,7 +180,7 @@ sub unapi {
                print "Location: $root/../../en-US/skin/default/xml/rdetail.xml?r=$id\n\n"
                        if ($type eq 'record');
                return 302;
-       } else {
+       } elsif (OpenILS::WWW::SuperCat::Feed->exists($format)) {
                my $feed = create_record_feed(
                        $format => [ $id ],
                        $base,
@@ -190,6 +190,7 @@ sub unapi {
                $feed->root($root);
                $feed->creator($host);
                $feed->update_ts(gmtime_ISO8601());
+               $feed->link( unapi => $base);
 
                print "Content-type: ". $feed->type ."; charset=utf-8\n\n";
                print entityize($feed->toString) . "\n";
index 58370a1..769a7ec 100644 (file)
@@ -7,6 +7,14 @@ use XML::LibXSLT;
 use OpenSRF::Utils::SettingsClient;
 use CGI;
 
+sub exists {
+       my $class = shift;
+       my $type = shift;
+
+       return 1 if UNIVERSAL::can("OpenILS::WWW::SuperCat::Feed::$type" => 'new');
+       return 0;
+}
+
 sub new {
        my $class = shift;
        my $type = shift;
@@ -444,6 +452,23 @@ sub new {
        $self->{item_xpath} = '/marc:collection';
        return $self;
 }
+sub link {
+       my $self = shift;
+       my $type = shift;
+       my $id = shift;
+
+       if ($type eq 'unapi') {
+               $self->_create_node(
+                       'marc:collection',
+                       'http://www.w3.org/1999/xhtml',
+                       'xhtml:link',
+                       undef,
+                       { rel => 'meta', href => $id, title => "unapi" }
+               );
+               $linkid++;
+       }
+}
+
 
 package OpenILS::WWW::SuperCat::Feed::marcxml::item;
 use base 'OpenILS::WWW::SuperCat::Feed::marcxml';
@@ -464,7 +489,7 @@ sub link {
        my $type = shift;
        my $id = shift;
 
-       if ($type eq 'unapi' || $type eq 'opac') {
+       if ($type eq 'opac') {
                $self->_create_node(
                        'marc:record',
                        'http://www.w3.org/1999/xhtml',
@@ -473,6 +498,15 @@ sub link {
                        { rel => 'otherFormat', href => $id, title => "Dynamic Details" }
                );
                $linkid++;
+       } elsif ($type eq 'unapi-id') {
+               $self->_create_node(
+                       'marc:record',
+                       'http://www.w3.org/1999/xhtml',
+                       'xhtml:abbr',
+                       undef,
+                       {  title => $id, class => "unapi-id" }
+               );
+               $linkid++;
        }
 }
 
index ef327cb..4764604 100755 (executable)
@@ -13,6 +13,7 @@
        <head>
          <meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
          <link href="{$base_dir}/htmlcard.css" rel="stylesheet" type="text/css" />
+        <xsl:apply-templates select="/marc:collection/xhtml:link"/>
        </head>
        <body>
         <xsl:apply-templates select="//marc:record"/>
@@ -25,6 +26,7 @@
      <xsl:apply-templates select="marc:datafield[@tag!='082' and @tag!='092' and @tag!='010']"/>
      <span class="bottom">
       <xsl:apply-templates select="xhtml:link[@rel='otherFormat' and contains(@href,'format=')]"/>
+      <xsl:apply-templates select="xhtml:abbr[@class='unapi-id']"/>
       <xsl:apply-templates select="marc:controlfield[@tag='001']"/>
       <xsl:apply-templates select="marc:datafield[@tag='082' or @tag='092' or @tag='010']"/>
      </span>
     <br/>
   </xsl:template>
 
-  <xsl:template match="xhtml:link">
-    <a>
-      <xsl:attribute name="href">
-        <xsl:value-of select="@href"/>
+  <xsl:template match="xhtml:abbr">
+    <abbr>
+      <xsl:attribute name="title">
+        <xsl:value-of select="@title"/>
       </xsl:attribute>
-      <xsl:value-of select="@title"/>
-    </a>
-    <br/>
+      <xsl:attribute name="class">
+        <xsl:value-of select="@class"/>
+      </xsl:attribute>
+      <xsl:value-of select="."/>
+    </abbr>
+  </xsl:template>
+
+  <xsl:template match="xhtml:link">
+    <xsl:choose>
+      <xsl:when test="@title='unapi'">
+        <link>
+          <xsl:attribute name="title">
+            <xsl:value-of select="@title"/>
+          </xsl:attribute>
+          <xsl:attribute name="rel">
+            <xsl:value-of select="@rel"/>
+          </xsl:attribute>
+          <xsl:attribute name="href">
+            <xsl:value-of select="@href"/>
+          </xsl:attribute>
+          <xsl:value-of select="."/>
+        </link>
+      </xsl:when>
+      <xsl:when test="@rel='otherFormat' and contains(@href,'format=')">
+        <a>
+          <xsl:attribute name="href">
+            <xsl:value-of select="@href"/>
+          </xsl:attribute>
+          <xsl:value-of select="@title"/>
+        </a>
+        <br/>
+      </xsl:when>
+    </xsl:choose>
   </xsl:template>
 
   <xsl:template match="hold:volumes">