You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axkit-dev@xml.apache.org by ma...@sergeant.org on 2006/08/05 03:30:41 UTC

[SVN] [41] Slight cleanup

Revision: 41
Author:   matt
Date:     2006-08-05 01:30:18 +0000 (Sat, 05 Aug 2006)

Log Message:
-----------
Slight cleanup

Modified Paths:
--------------
    trunk/plugins/demo/gallery

Modified: trunk/plugins/demo/gallery
===================================================================
--- trunk/plugins/demo/gallery	2006-08-05 01:04:33 UTC (rev 40)
+++ trunk/plugins/demo/gallery	2006-08-05 01:30:18 UTC (rev 41)
@@ -175,6 +175,7 @@
     my $uri = $self->client->headers_in->request_uri;
     $uri =~ s/\?.*//;
     
+    # generate path and config data.
     my ($uri_path) = $uri =~ /(.*)\//;
     $uri =~ s/^\///;            # Trim the leading '/'
     $uri = "<full><e>$uri</e><u>" . uri_decode($uri) . "</u></full>\n" .
@@ -224,6 +225,7 @@
     }
     $xml .= "</GallerySizes>";
     
+    # add image data
     $xml .= <<EOXML;
     </perl-vars>
   </config>
@@ -242,12 +244,32 @@
     
     $input->dom($xml);
     
+    my $rdf = $self->get_exif_rdf("$path/$file");
+    
+    if ($rdf) {
+        my ($image_node) = $input->dom->findnodes('/imagesheet/image');
+        $image_node->appendWellBalancedChunk($rdf);
+    }
+    
+    my $out = $input->transform(
+        XSLT($self->config->docroot . '/stylesheets/imagesheet2html.xsl')
+    );
+    
+    return OK, $out;
+}
+
+## here we extract the EXIF data and convert it to RDF.
+sub get_exif_rdf {
+    my ($self, $filename) = @_;
+    
     my $cache = $self->cache;
-    my $rdf = $cache->get("$path/$file+rdf");
+    my $rdf = $cache->get("${filename}+rdf");
     
     if (!$rdf) {
+        $rdf = '';
+        
         my $info = {};
-        $info->{imageinfo} = ImageInfo("$path/$file");
+        $info->{imageinfo} = ImageInfo($filename);
         
         if(! $info->{error}) {
             # Work out the width/height ratio, and calculate
@@ -379,22 +401,14 @@
                             Output => \$rdf);
             $ser->serialize();
             
-            $cache->set("$path/$file+rdf", $rdf);
+            $cache->set("${filename}+rdf", $rdf);
         }
     }
     
-    if ($rdf) {
-        my ($image_node) = $input->dom->findnodes('/imagesheet/image');
-        $image_node->appendWellBalancedChunk($rdf);
-    }
-    
-    my $out = $input->transform(
-        XSLT($self->config->docroot . '/stylesheets/imagesheet2html.xsl')
-    );
-    
-    return OK, $out;
+    return $rdf;
 }
 
+## Directories get turned into a "proofsheet" of images
 sub serve_dir {
     my ($self, $input) = @_;
     
@@ -419,6 +433,9 @@
         XSLT($self->config->docroot . "/stylesheets/filelist2proofsheet.xsl")
         );
     
+    # Now we have the full proofsheet, we need to trim it down to just the
+    # images we want for this "page". We use Data::Page to tell us which
+    # images those are.
     $dom = $out->dom;
     
     my $per_page = $self->get_cfg('ImagesPerProofsheet');
@@ -443,6 +460,8 @@
         $node->parentNode->removeChild($node);
     }
     
+    
+    # Now add in some XML for the page navigation
     my $pages_xml = '<pages>';
 	for ($page->first_page .. $page->last_page) {
 		$pages_xml .= "<page number='$_'";
@@ -453,6 +472,7 @@
     
     $dom->documentElement->appendWellBalancedChunk($pages_xml);
     
+    # Add in some info about the URL and each image
     my $uri = $self->client->headers_in->request_uri;
     $uri =~ s/^\///;
     $uri = join("\n",
@@ -480,6 +500,7 @@
 EOXML
     }
     
+    # Finally we add in the config info
     $self->log(LOGINFO, "Augmenting config info");
     
 	my @variables = qw(ProofsheetColumns ImagesPerProofsheet