adding subject searches to feed output
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Mar 2006 03:40:43 +0000 (03:40 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 22 Mar 2006 03:40:43 +0000 (03:40 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@3409 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat.pm
Open-ILS/src/perlmods/OpenILS/WWW/SuperCat/Feed.pm
Open-ILS/xsl/ATOM2XHTML.xsl
Open-ILS/xsl/MARC21slim2ATOM.xsl

index 6e145d0..bb60a2d 100644 (file)
@@ -285,10 +285,7 @@ sub retrieve_metarecord_mods {
 
        my $id = $mr->id;
        $recordIdentifier->appendTextNode(
-               sprintf("tag:open-ils.org,$year-\%0.2d-\%0.2d:biblio-record_entry/$id",
-                       $month,
-                       $day
-               )
+               sprintf("tag:open-ils.org,$year-\%0.2d-\%0.2d:metabib-metarecord/$id", $month, $day)
        );
 
        $recordInfo->appendChild($recordIdentifier);
index 45a2523..af6d597 100644 (file)
@@ -308,7 +308,7 @@ sub bookbag_feed {
 
        my $bucket_tag = "tag:$host,$year:record_bucket/$id";
        if ($type eq 'opac') {
-               print "Location: $base/../../../opac/en-US/skin/default/xml/rresult.xml?rt=list&" .
+               print "Location: $root/../en-US/skin/default/xml/rresult.xml?rt=list&" .
                        join('&', map { "rl=" . $_->target_biblio_record_entry } @{ $bucket->items }) .
                        "\n\n";
                return Apache2::Const::OK;
@@ -321,19 +321,20 @@ sub bookbag_feed {
        );
        $feed->root($root);
 
-       $feed->title("Items in Book Bag #".$bucket->id);
+       $feed->title("Items in Book Bag [".$bucket->name."]");
        $feed->creator($host);
        $feed->update_ts(gmtime_ISO8601());
 
-       $feed->link(atom => $base . "/bookbag/atom/$id" => 'application/atom+xml');
-       $feed->link(rss2 => $base . "/bookbag/rss2/$id");
-       $feed->link(html => $base . "/bookbag/html/$id" => 'text/html');
+       $feed->link(atom => $base . "/atom/$id" => 'application/atom+xml');
+       $feed->link(rss2 => $base . "/rss2/$id");
+       $feed->link(html => $base . "/html/$id" => 'text/html');
+       $feed->link(unapi => $unapi);
 
        $feed->link(
                OPAC =>
                $root . '../en-US/skin/default/xml/rresult.xml?rt=list&' .
                        join('&', map { 'rl=' . $_->target_biblio_record_entry } @{$bucket->items} ),
-               'text/xhtml'
+               'text/html'
        );
 
 
@@ -450,10 +451,10 @@ sub opensearch_feed {
        my $limit = $cgi->param('count') || 10;
        my $lang = $cgi->param('language') || 'en-US';
 
-       $page = 1 if ($page =~ /^{/);
-       $offset = 1 if ($offset =~ /^{/);
-       $limit = 10 if ($limit =~ /^{/);
-       $lang = 'en-US' if ($lang =~ /^{/);
+       $page = 1 if ($page !~ /^\d+$/);
+       $offset = 1 if ($offset =~ /^\d+$/);
+       $limit = 10 if ($limit =~ /^\d+$/); $limit = 25 if ($limit > 25);
+       $lang = 'en-US' if ($lang =~ /^{/ or $lang eq '*');
 
        if ($page > 1) {
                $offset = ($page - 1) * $limit;
@@ -500,6 +501,7 @@ sub opensearch_feed {
                $unapi,
        );
        $feed->root($root);
+       $feed->lib($org);
 
        $feed->title("Search results for [$class => $terms] at ".$org_unit->[0]->name);
        $feed->creator($host);
@@ -544,10 +546,7 @@ sub opensearch_feed {
                'application/opensearch+xml'
        );
 
-       $feed->link(
-               unapi =>
-               $unapi
-       );
+       $feed->link( unapi => $unapi);
 
        $feed->link(
                alternate =>
index 8203a35..285acd0 100644 (file)
@@ -35,6 +35,13 @@ sub type {
        return $self->{type};
 }
 
+sub lib {
+       my $self = shift;
+       my $lib = shift;
+       $self->{lib} = $lib if ($lib);
+       return $self->{lib};
+}
+
 sub base {
        my $self = shift;
        my $base = shift;
@@ -402,6 +409,7 @@ sub toString {
        my $self = shift;
        my $base = $self->base;
        my $root = $self->root;
+       my $lib = $self->lib || '-';
 
        $self->composeDoc;
 
@@ -417,7 +425,7 @@ sub toString {
         # 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'");
+       my $new_doc = $atom2html_xslt->transform($self->{doc}, base_dir => "'$root'", lib => "'$lib'");
        return $new_doc->toString(1); 
 }
 
index 0fb3354..3781a0a 100644 (file)
@@ -67,7 +67,7 @@ To-do list:
        <xsl:variable name="t-untitleditem">(untitled)</xsl:variable> <!-- text of untitled items when the title needs to be shown) -->
        <xsl:variable name="t-entrylink">view full entry</xsl:variable> <!-- text of the link to the full entry (used with <content src="" /> in atom) -->
        <xsl:variable name="t-authors">by</xsl:variable> <!-- label before one or more author/contributors (eg the 'by' in 'by Joe'); leave blank to not show authors -->
-       <xsl:variable name="t-categories">categories:</xsl:variable> <!-- label before one or more categories; leave blank to not show categories -->
+       <xsl:variable name="t-categories">Subjects:</xsl:variable> <!-- label before one or more categories; leave blank to not show categories -->
        <xsl:variable name="t-source">from</xsl:variable> <!-- label of source (e.g. 'from' or 'via' in English); leave blank to not show sources -->
        <xsl:variable name="t-comments">comments</xsl:variable> <!-- leave blank to not show link to comments -->
        <xsl:variable name="t-download">download</xsl:variable> <!-- leave this or t-enclosure blank to not show link to enclosures -->
@@ -125,7 +125,7 @@ To-do list:
                                        <link rel="shortcut icon" href="{$iconurl}" />
                                </xsl:if>
                                <link rel="stylesheet" type="text/css" title="default" media="screen">
-                                       <xsl:attribute name="href"><xsl:value-of select="concat($base_dir,'/os.css')"/></xsl:attribute>
+                                       <xsl:attribute name="href"><xsl:value-of select="concat($base_dir,'os.css')"/></xsl:attribute>
                                </link>
                                <!-- rel links -->
 
@@ -382,9 +382,14 @@ To-do list:
                        </xsl:variable>
                        <xsl:variable name="maybeurl" select="(@domain | @scheme)[1]" />
                        <xsl:variable name="url">
-                               <xsl:if test="starts-with($maybeurl, 'http')">
-                                       <xsl:value-of select="concat($maybeurl, '#', $category)" />
-                               </xsl:if>
+                               <xsl:choose>
+                                       <xsl:when test="starts-with($maybeurl, 'http')">
+                                               <xsl:value-of select="concat($maybeurl, '#', $category)" />
+                                       </xsl:when>
+                                       <xsl:otherwise>
+                                               <xsl:value-of select="concat($base_dir, 'opensearch/1.1/', $lib, '/html/subject/', translate(normalize-space($name), ' ,()', '+'))" />
+                                       </xsl:otherwise>
+                               </xsl:choose>
                        </xsl:variable>
                        <xsl:choose>
                                <xsl:when test="string-length($url)&gt;0"><a href="{$url}"><xsl:value-of select="$name" /></a></xsl:when>
index 476732a..e706763 100644 (file)
@@ -59,7 +59,7 @@
                        <xsl:for-each select="marc:datafield[@tag=655]">
                                <category>
                                        <xsl:attribute name="term">
-                                               <xsl:value-of select="."/>
+                                               <xsl:value-of select="./marc:subfield[@code='a' or @code='v']"/>
                                        </xsl:attribute>
                                </category>
                        </xsl:for-each>