[open-ils-commits] r20367 - trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Sun May 1 11:29:41 EDT 2011


Author: erickson
Date: 2011-05-01 11:29:39 -0400 (Sun, 01 May 2011)
New Revision: 20367

Modified:
   trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm
Log:
ContentCafe summary of avaible item content

Added "available_json" support for Content Cafe.  Returns and array of
available content for a given item, where the content type is mapped to
one of the Evergreen standard added content types, e.g. "summary",
"anotes", "reviews", ...

Modified: trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm
===================================================================
--- trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm	2011-05-01 13:53:22 UTC (rev 20366)
+++ trunk/Open-ILS/src/perlmods/lib/OpenILS/WWW/AddedContent/ContentCafe.pm	2011-05-01 15:29:39 UTC (rev 20367)
@@ -206,7 +206,28 @@
         $self->fetch_content('AnnotationDetail', $key));
 }
 
+sub available_json {
+    my($self, $key) = @_;
+    my $xml = $self->fetch_content('AvailableContent', $key);
+    my $doc = XML::LibXML->new->parse_string($xml);
 
+    my @avail;
+    for my $node ($doc->findnodes('//*[text()="true"]')) {
+        push(@avail, 'summary') if $node->nodeName eq 'Annotation';
+        push(@avail, 'jacket') if $node->nodeName eq 'Jacket';
+        push(@avail, 'toc') if $node->nodeName eq 'TOC';
+        push(@avail, 'anotes') if $node->nodeName eq 'Biography';
+        push(@avail, 'excerpt') if $node->nodeName eq 'Excerpt';
+        push(@avail, 'reviews') if $node->nodeName eq 'Review';
+    }
+
+    return { 
+        content_type => 'text/plain', 
+        content => OpenSRF::Utils::JSON->perl2JSON(\@avail)
+    };
+}
+
+
 # --------------------------------------------------------------------------
 
 



More information about the open-ils-commits mailing list