[prev in list] [next in list] [prev in thread] [next in thread] 

List:       forrest-dev
Subject:    svn commit: r373448 - in
From:       twilliams () apache ! org
Date:       2006-01-30 6:23:37
Message-ID: 20060130062340.20014.qmail () minotaur ! apache ! org
[Download RAW message or body]

Author: twilliams
Date: Sun Jan 29 22:23:20 2006
New Revision: 373448

URL: http://svn.apache.org/viewcvs?rev=373448&view=rev
Log:
There is still much work left to do but since much of it involves changing stuff that \
is already working, I want to at least get it into svn so that I can revert if \
necessary.  

Added:
    forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryHome.xsl \
(with props)  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/A_017_7A.jpg
                
      - copied unchanged from r373290, \
forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/big/A_017_7A.jpg
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/A_025_00A.jpg
                
      - copied unchanged from r373290, \
forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/big/A_025_00A.jpg
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/B_007_18A.jpg
                
      - copied unchanged from r373290, \
forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/big/B_007_18A.jpg
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/B_013_12A.jpg
                
      - copied unchanged from r373290, \
forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/big/B_013_12A.jpg
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/B_014_11A.jpg
                
      - copied unchanged from r373290, \
forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/big/B_014_11A.jpg
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/B_023_2A.jpg
                
      - copied unchanged from r373290, \
forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/big/B_023_2A.jpg
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/album.xml \
(with props)  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/
    forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/forrest/
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/forrest/reading/
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/forrest/reading/PersistentImageReader.java \
(with props) Removed:
    forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/big/
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/preview/
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/small/
 Modified:
    forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/forrest.properties
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/input.xmap
    forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources.xmap
    forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryIndexPage.xsl
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryPicture.xsl
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/index.xml
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/site.xml
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/skinconf.xml
  forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/status.xml

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/forrest.properties
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/forrest.properties?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/forrest.properties \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/forrest.properties \
Sun Jan 29 22:23:20 2006 @@ -23,4 +23,9 @@
 # FIXME: FOR-785
 forrest.validate.skinconf=false
 
-project.required.plugins=org.apache.forrest.plugin.input.projectInfo,org.apache.forrest.plugin.input.PhotoGallery
 +project.theme=pelt
+
+forrest.maxmemory=512m
+
+project.required.plugins=org.apache.forrest.plugin.input.PhotoGallery,org.apache.forrest.plugin.output.themer,org.apache.forrest.plugin.internal.structurer
 +#project.required.plugins=org.apache.forrest.plugin.input.PhotoGallery
\ No newline at end of file

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/input.xmap
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/input.xmap?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/input.xmap \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/input.xmap Sun \
Jan 29 22:23:20 2006 @@ -20,21 +20,54 @@
     <map:generators default="file">
       <map:generator name="imagedirectory"
           src="org.apache.cocoon.generation.ImageDirectoryGenerator" />
+      <map:generator name="xpathdirectory" 
+          src="org.apache.cocoon.generation.XPathDirectoryGenerator" />
     </map:generators>
     <map:transformers default="xslt" />
   </map:components>
 
   <map:pipelines>
     <map:pipeline internal-only="false">
+          <map:match pattern="gallery/raw.xml">
+             <map:generate type="xpathdirectory" src="{lm:project.images/gallery/}">
+                <map:parameter name="depth" value="99"/>
+                <map:parameter name="xpath" value="/albuminfo/*"/>
+                <map:parameter name="sort" value="lastmodified"/>
+                <map:parameter name="reverse" value="true"/>
+                <map:parameter name="exclude" \
value="(\.svn$|\w\.thumb.jpg|\w\.small.jpg|Thumbs.db)"/> +                \
<map:parameter name="xmlFiles" value="album\.xml"/> +             </map:generate>
+            <map:serialize type="xml"/>      
+      </map:match>
+    
+      <map:match pattern="gallery/index.xml">
+         <map:generate type="xpathdirectory" src="{lm:project.images/gallery/}">
+            <map:parameter name="depth" value="99"/>
+            <map:parameter name="xpath" value="/albuminfo/*"/>
+            <map:parameter name="sort" value="lastmodified"/>
+            <map:parameter name="reverse" value="true"/>
+            <map:parameter name="exclude" \
value="(\.svn$|\w\.thumb.jpg|\w\.small.jpg|Thumbs.db)"/> +            <map:parameter \
name="xmlFiles" value="\.xml$"/> +         </map:generate>
+        <map:transform src="{lm:photoGallery.transform.dir.galleryHome}"/>
+        <map:serialize type="xml"/>      
+      </map:match>
+      
+      
+ 
       <map:match pattern="gallery/**/dir.xml">
-        <map:generate type="imagedirectory" \
                src="{lm:project.images/gallery/{1}/preview/}">
-          <map:parameter name="exclude" value="Thumbs.db"/> <!-- windows XP \
thumbnails --> +        <map:generate type="imagedirectory" \
src="{lm:project.images/gallery/{1}/}"> +          <!-- HELP:  I'd like to be able to \
have more dynamic image variants (e.g. thumb) +              without having them \
hardcoded like the are but I suck at regex. +          -->
+          <map:parameter name="exclude" \
value="(\w\.thumb.jpg|\w\.small.jpg|Thumbs.db)"/>  </map:generate>
         <map:serialize type="xml" />
       </map:match>
       
       <map:match pattern="gallery/**/index.xml">
-        <map:redirect-to uri="gallery/{1}/index_1.xml"/> 
+        <map:generate src="cocoon://gallery/{1}/index_1.xml"/>
+        <map:serialize type="xml" />
       </map:match>
       
       <map:match pattern="gallery/**/index_*.xml">

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources.xmap
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources.xmap?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources.xmap \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources.xmap \
Sun Jan 29 22:23:20 2006 @@ -25,6 +25,13 @@
       </map:serializer>
     </map:serializers>
     <map:transformers default="xslt" />
+  <map:readers default="resource">
+    <map:reader name="image" 
+      src="org.apache.forrest.reading.PersistentImageReader"
+      logger="core.modules.mapper.lm"
+      pool-max="32"/>
+  </map:readers>
+  
   </map:components>
 
   <map:pipelines>
@@ -36,6 +43,20 @@
           <map:parameter name="label" value="{2}" />
         </map:transform>
         <map:serialize type="svg2png" />
+      </map:match>
+
+      <map:match pattern="gallery/**.thumb.jpg">
+        <map:read type="image" src="{lm:project.images/gallery/{1}.jpg}">
+          <map:parameter name="width" value="150"/>
+          <map:parameter name="variant" value="thumb"/>
+        </map:read>
+      </map:match>
+
+      <map:match pattern="gallery/**.small.jpg">
+        <map:read type="image" src="{lm:project.images/gallery/{1}.jpg}">
+          <map:parameter name="width" value="450"/>
+          <map:parameter name="variant" value="small"/>
+        </map:read>
       </map:match>
 
       <map:match pattern="gallery/**.jpg">

Added: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryHome.xsl
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/resources/stylesheets/dir-to-galleryHome.xsl?rev=373448&view=auto \
                ==============================================================================
                
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryHome.xsl \
                (added)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryHome.xsl \
Sun Jan 29 22:23:20 2006 @@ -0,0 +1,75 @@
+<?xml version="1.0"?>
+<!--
+    Copyright 1999-2005 The Apache Software Foundation or its licensors,
+    as applicable.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:dir="http://apache.org/cocoon/directory/2.0"
+                xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+                xmlns:DC="http://purl.oclc.org/dc/documents/rec-dces-199809.htm#">
+
+  <xsl:param name="gallery-dir">gallery</xsl:param>
+  <xsl:template match="/">
+    <document> 
+      <header> 
+        <title>Photo Gallery Index</title> 
+      </header> 
+      <body> 
+        <section id="overview">
+          <title>
+            Photo Albums 
+          </title> 
+          <xsl:apply-templates select="/dir:directory//dir:directory"/>
+        </section>
+      </body>
+    </document>
+  </xsl:template>
+  
+  <xsl:template match="dir:directory">
+    <section>
+      <title>   
+        <xsl:value-of select="./dir:file/dir:xpath/title"/>   
+      </title>
+      
+       <a>
+        <xsl:attribute name="href">./<xsl:value-of \
select="./@name"/>/index.html</xsl:attribute> +        <xsl:choose>
+          <xsl:when test="count(./dir:file[contains(@name,'.JPG')]) > 0">
+          <img>
+           <xsl:attribute name="src"><xsl:value-of select="./@name"/>/<xsl:value-of \
select="substring-before(./dir:file[contains(@name,'.JPG')]/@name,'.')"/>.thumb.jpg</xsl:attribute>
 +          </img>   
+        </xsl:when>
+        <xsl:otherwise>
+          <img>
+            <xsl:attribute name="src"><xsl:value-of select="./@name"/>/<xsl:value-of \
select="substring-before(./dir:file[contains(@name,'.jpg')]/@name,'.')"/>.thumb.jpg</xsl:attribute>
 +          </img>
+        </xsl:otherwise>
+       </xsl:choose>
+       
+       </a>
+     <p>
+        <em><xsl:value-of select="./dir:file/dir:xpath/description"/></em>
+      </p>
+    </section>
+
+  </xsl:template>   
+
+  
+  
+</xsl:stylesheet>
+

Propchange: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryHome.xsl
                
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryIndexPage.xsl
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/resources/stylesheets/dir-to-galleryIndexPage.xsl?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryIndexPage.xsl \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryIndexPage.xsl \
Sun Jan 29 22:23:20 2006 @@ -95,7 +95,7 @@
 	  <td width="100" height="100" align="center">
 	    <a>
         <xsl:attribute name="href">pic_<xsl:value-of \
                select="position()+$offset"/>.html</xsl:attribute>
-	      <img src="preview/{@name}" />
+        <img src="{substring-before(@name, '.')}.thumb.jpg" />
 	    </a>
 	  </td>
 	</xsl:for-each>

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryPicture.xsl
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/resources/stylesheets/dir-to-galleryPicture.xsl?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryPicture.xsl \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/resources/stylesheets/dir-to-galleryPicture.xsl \
Sun Jan 29 22:23:20 2006 @@ -73,14 +73,14 @@
 		  <xsl:when test="$big = 0">
 		    <a>
           <xsl:attribute name="href">fullPic_<xsl:value-of \
                select="$pos"/>.html</xsl:attribute>
-		      <img src="small/{@name}" /><br/>
+          <img src="{substring-before(@name, '.')}.small.jpg" /><br/>
           Click to View Largest Picture
 		    </a>
 		  </xsl:when>
 		  <xsl:otherwise>
 		    <a>
           <xsl:attribute name="href">pic_<xsl:value-of \
                select="$pos"/>.html</xsl:attribute>
-		      <img src="big/{@name}" /><br/>
+		      <img src="{@name}" /><br/>
           Click to View Smaller Picture
 		    </a>
 		  </xsl:otherwise>

Added: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/album.xml
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/album.xml?rev=373448&view=auto
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/album.xml \
                (added)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/album.xml \
Sun Jan 29 22:23:20 2006 @@ -0,0 +1,6 @@
+<albuminfo>
+  <title>My Sample Photo Gallery</title>
+  <description>This photo gallery is a just a sample that demonstrates the \
Photogallery plugin in  +    Apache Forrest.  
+  </description>
+</albuminfo>
\ No newline at end of file

Propchange: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/images/gallery/demo/album.xml
                
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/index.xml
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/src/documentation/content/xdocs/index.xml?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/index.xml \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/index.xml \
Sun Jan 29 22:23:20 2006 @@ -26,47 +26,31 @@
       <p>This plugin creates a photo album from photographs.</p>
       
       <p>The pictures are expected under 
-      <code>{project:content.xdocs}/images/gallery/**</code> in 
-      folders called <code>preview</code>, <code>small</code> and  
-      <code>big</code>.</p>
+      <code>{project:content.xdocs}/images/gallery/**</code>.  To create your photo 
+      albums simply create a new directory for each photo album under the gallery 
+      directory.  Then place a simple album description file named album.xml in each
+      directory.  Look in the sample gallery for a sample of this album.xml \
file.</p>  
-      <p>To view a screen of thumbnails (generated from the <code>preview</code>
-      directory), you need to request an URL in the form of 
+      <p>To view a screen of thumbnails, you need to request an URL in the form of 
       <code>gallery/**/index.html</code>. By default 20 pictures will be 
       displayed. If you have more than 20 then you will need to use an URL in
       the form of <code>gallery/**/index_X.html</code> (where X is the page 
       number you want to view). 
       See our <a href="gallery/demo/index_1.html">demo index</a> for an example.</p>
       
-      <p>To view a single picture at a size optimised for the delivery mecahnism 
-      (generated from the <code>small</code> directory), you need to request an 
-      URL in the form of <code>gallery/**/pic_PICTURE_NUMBER.html</code>,
+      <p>To view a single picture at a size optimised for the delivery mecahnism, \
you  +      need to request an URL in the form of \
                <code>gallery/**/pic_PICTURE_NUMBER.html</code>,
       where PICTURE_NUMBER is the number of the picture you want to display.
       See our <a href="gallery/demo/pic_1.html">demo one picture</a>,
       <a href="gallery/demo/pic_2.html">demo two picture</a>, 
       <a href="gallery/demo/pic_3.html">demo three picture</a> for examples.</p>
       
-      <p>To view a single picture at its natural size 
-      (generated from the <code>big</code> directory), you need to request an 
+      <p>To view a single picture at its natural size, you need to request an 
       URL in the form of <code>gallery/**/fullPic_PICTURE_NUMBER.html</code>.
       See our <a href="gallery/demo/fullPic_1.html">demo one picture</a>,
       <a href="gallery/demo/fullPic_2.html">demo two picture</a>, 
       <a href="gallery/demo/fullPic_3.html">demo three picture</a> for examples.</p>
-      
-      <note>To create the relevant directory stuctures for your gallery simply
-      run the following script (unix only). We hope to enhance this plugin
-      so that it will automatically create the relevant images for you, but
-      for now you must do it by hand.
-      <code>
-      for i; do
-        echo -n "Converting:" $i "... ";
-        convert -size 100x100 $i -resize 100x100 preview/$i;
-        convert -size 400x400 $i -resize 400x400 small/$i;
-        convert -size 800x800 $i -resize 800x800 big/$i;
-        echo "finished.";
-      done
-      </code> 
-</note>
+
     </section>
   </body>
 </document>

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/site.xml
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/src/documentation/content/xdocs/site.xml?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/site.xml \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/content/xdocs/site.xml \
Sun Jan 29 22:23:20 2006 @@ -34,7 +34,7 @@
 
   <about label="About">
     <index label="Index" href="index.html" description="Welcome to \
                org.apache.forrest.plugin.gallery"/>
-    <forrestPlugins label="Plugins Index" href="site:forrest/plugins" \
description="Index of Forrest Plugins"/> +    <!--<forrestPlugins label="Plugins \
                Index" href="site:forrest/plugins" description="Index of Forrest \
                Plugins"/>-->
     <changes label="Changes" href="changes.html" description="History of Changes" />
     <todo label="Todo" href="todo.html" description="Todo List" />
   </about>

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/skinconf.xml
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/src/documentation/skinconf.xml?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/skinconf.xml \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/documentation/skinconf.xml \
Sun Jan 29 22:23:20 2006 @@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-  Copyright 2002-2006 The Apache Software Foundation or its licensors,
+  Copyright 2002-2005 The Apache Software Foundation or its licensors,
   as applicable.
 
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,15 +16,431 @@
   limitations under the License.
 -->
 
-<!DOCTYPE skinconfig PUBLIC "-//APACHE//DTD Skin Configuration V0.7-1//EN" \
                "http://forrest.apache.org/dtd/skinconfig-v07-1.dtd"
-[
-  <!ENTITY skinconf-common PUBLIC "-//Apache Forrest//ENTITIES Skin Configuration \
                common plugins V0.7-1//EN" "">
-]>
+<!--
+Skin configuration file. This file contains details of your project,
+which will be used to configure the chosen Forrest skin.
+-->
 
+<!DOCTYPE skinconfig PUBLIC "-//APACHE//DTD Skin Configuration V0.7-1//EN" \
"http://forrest.apache.org/dtd/skinconfig-v07-1.dtd">  <skinconfig>
-  &skinconf-common;
+  <!-- To enable lucene search add provider="lucene" (default is google).
+    Add box-location="alt" to move the search box to an alternate location
+    (if the skin supports it) and box-location="all" to show it in all
+    available locations on the page.  Remove the <search> element to show
+    no search box. @domain will enable sitesearch for the specific domain with \
google. +    In other words google will search the @domain for the query string.
+  -->
+  <search name="MyProject" domain="mydomain" provider="google"/>
+
+  <!-- Disable the print link? If enabled, invalid HTML 4.0.1 -->
+  <disable-print-link>true</disable-print-link>  
+  <!-- Disable the PDF link? -->
+  <disable-pdf-link>false</disable-pdf-link>
+  <!-- Disable the POD link? -->
+  <disable-pod-link>true</disable-pod-link>
+  <!-- Disable the Text link? FIXME: NOT YET IMPLEMENETED. -->
+  <disable-txt-link>true</disable-txt-link>
+  <!-- Disable the xml source link? -->
+  <!-- The xml source link makes it possible to access the xml rendition
+    of the source frim the html page, and to have it generated statically.
+    This can be used to enable other sites and services to reuse the
+    xml format for their uses. Keep this disabled if you don't want other
+    sites to easily reuse your pages.-->
+  <disable-xml-link>true</disable-xml-link>
+
+  <!-- Disable navigation icons on all external links? -->
+  <disable-external-link-image>true</disable-external-link-image>
+
+  <!-- Disable w3c compliance links? 
+    Use e.g. align="center" to move the compliance links logos to 
+    an alternate location default is left.
+    (if the skin supports it) -->
+  <disable-compliance-links>false</disable-compliance-links>
+
+  <!-- Render mailto: links unrecognisable by spam harvesters? -->
+  <obfuscate-mail-links>true</obfuscate-mail-links>
+  <obfuscate-mail-value>.at.</obfuscate-mail-value>
+
+  <!-- Disable the javascript facility to change the font size -->
+  <disable-font-script>true</disable-font-script>
+
+  <!-- mandatory project logo
+       default skin: renders it at the top -->
+  <project-name>MyProject</project-name>
+  <project-description>MyProject Description</project-description>
+  <project-url>http://myproj.mygroup.org/</project-url>
+  <project-logo>images/project.png</project-logo>
+  <!-- Alternative static image:
+  <project-logo>images/project-logo.gif</project-logo> -->
+
+  <!-- optional group logo
+       default skin: renders it at the top-left corner -->
+  <group-name>MyGroup</group-name>
+  <group-description>MyGroup Description</group-description>
+  <group-url>http://mygroup.org</group-url>
+  <group-logo>images/group.png</group-logo>
+  <!-- Alternative static image:
+  <group-logo>images/group-logo.gif</group-logo> -->
+
+  <!-- optional host logo (e.g. sourceforge logo)
+       default skin: renders it at the bottom-left corner -->
+  <host-url></host-url>
+  <host-logo></host-logo>
+
+  <!-- relative url of a favicon file, normally favicon.ico -->
+  <favicon-url></favicon-url>
+
+  <!-- The following are used to construct a copyright statement -->
+  <disable-copyright-footer>false</disable-copyright-footer>
+  <year>2005</year>
+  <vendor>The Acme Software Foundation.</vendor>
+  <!-- The optional copyright-link URL will be used as a link in the
+    copyright statement
+  <copyright-link>http://www.apache.org/licenses/</copyright-link>
+  -->
+
+  <!-- Some skins use this to form a 'breadcrumb trail' of links.
+    Use location="alt" to move the trail to an alternate location
+    (if the skin supports it).
+    Omit the location attribute to display the trail in the default location.
+    Use location="none" to not display the trail (if the skin supports it).
+    For some skins just set the attributes to blank.
+    
+    NOTE: If a breadcrumb entry points at a local file the href must
+    be complete, that is it must point to the file itself, not to a 
+    directory.
+  -->
+  <trail>
+    <link1 name="myGroup" href="http://www.apache.org/"/>
+    <link2 name="myProject" href="http://forrest.apache.org/"/>
+    <link3 name="" href=""/>
+  </trail>
+
+  <!-- Configure the TOC, i.e. the Table of Contents.
+  @max-depth
+   how many "section" levels need to be included in the
+   generated Table of Contents (TOC). 
+  @min-sections
+   Minimum required to create a TOC.
+  @location ("page","menu","page,menu", "none")
+   Where to show the TOC.
+  -->
+  <toc max-depth="2" min-sections="1" location="page"/>
+
+  <!-- Heading types can be clean|underlined|boxed  -->
+  <headings type="boxed"/>
+  
+  <!-- The optional feedback element will be used to construct a
+    feedback link in the footer with the page pathname appended:
+    <a href="@href">{@to}</a>
+    -->
+  <feedback to="webmaster@foo.com"
+    href="mailto:webmaster@foo.com?subject=Feedback&#160;" >
+    Send feedback about the website to:
+  </feedback>
+
+  <!-- Optional message of the day (MOTD).
+    Note: This is only implemented in the pelt skin.
+    Note: Beware issue FOR-677 if you use an absolute path uri.
+    If the optional <motd> element is used, then messages will be appended
+    depending on the URI string pattern.
+    motd-option : Each option will match a pattern and apply its text.
+      The "pattern" attribute specifies the pattern to be matched.
+      This can be a specific page, or a general pattern to match a set of pages,
+      e.g. everything in the "samples" directory.
+    motd-title : This text will be added in brackets after the <html><title>
+      and this can be empty.
+    motd-page : This text will be added in a panel on the face of the page,
+      with the "motd-page-url" being the hyperlink "More".
+    Values for the "location" attribute are:
+      page : on the face of the page, e.g. in the spare space of the toc
+      alt : at the bottom of the left-hand navigation panel
+      both : both
+    -->
+
+  <motd>
+    <motd-option pattern="samples/sample.html">
+      <motd-title>sample</motd-title>
+      <motd-page location="both">
+        This is an example of a Message of the day (MOTD).
+      </motd-page>
+      <motd-page-url>faq.html</motd-page-url>
+    </motd-option>
+    <motd-option pattern="samples/faq.html">
+      <motd-title></motd-title>
+      <motd-page location="both">
+        How to enable this MOTD is on this page.
+      </motd-page>
+      <motd-page-url>http://forrest.apache.org/docs/faq.html</motd-page-url>
+    </motd-option>
+  </motd>
+
+  <!--
+    extra-css - here you can define custom css-elements that are 
+    A) overriding the fallback elements or 
+    B) adding the css definition from new elements that you may have 
+       used in your documentation.
+    -->
+  <extra-css>
+    <!--Example of reason B:
+        To define the css definition of a new element that you may have used
+        in the class attribute of a <p> node. 
+        e.g. <p class="quote"/>
+    -->
+    p.quote {
+      margin-left: 2em;
+      padding: .5em;
+      background-color: #f0f0f0;
+      font-family: monospace;
+    }
+    <!--Example:
+        To override the colours of links only in the footer.
+    -->
+    #footer a { color: #0F3660; }
+    #footer a:visited { color: #009999; }
+  </extra-css>
+
+  <colors>
+  <!-- These values are used for the generated CSS files.
+    They essentially "override" the default colors defined in the chosen skin.
+    There are four duplicate "groups" of colors below, denoted by comments:
+      Color group: Forrest, Krysalis, Collabnet, and Lenya using Pelt.
+    They are provided for example only. To customize the colors of any skin,
+    uncomment one of these groups of color elements and change the values
+    of the particular color elements that you wish to change.
+    Note that by default, all color groups are commented-out which means that
+    the default colors provided by the skin are being used.
+  -->
+
+  <!-- Color group: Forrest: example colors similar to forrest.apache.org
+    Some of the element names are obscure, so comments are added to show how
+    the "pelt" skin uses them, other skins might use these elements in a different \
way. +    Tip: temporarily change the value of an element to red (#ff0000) and see \
the effect. +     pelt: breadtrail: the strip at the top of the page and the second \
strip under the tabs +     pelt: header: top strip containing project and group logos
+     pelt: heading|subheading: section headings within the content
+     pelt: navstrip: the strip under the tabs which contains the published date
+     pelt: menu: the left-hand navigation panel
+     pelt: toolbox: the selected menu item
+     pelt: searchbox: the background of the searchbox
+     pelt: border: line border around selected menu item
+     pelt: body: any remaining parts, e.g. the bottom of the page
+     pelt: footer: the second from bottom strip containing credit logos and \
published date +     pelt: feedback: the optional bottom strip containing feedback \
link +  -->
+<!--
+    <color name="breadtrail" value="#cedfef" font="#0F3660" link="#0F3660" \
vlink="#0F3660" hlink="#000066"/> +    <color name="header" value="#294563"/>
+    <color name="tab-selected" value="#4a6d8c" link="#0F3660" vlink="#0F3660" \
hlink="#000066"/> +    <color name="tab-unselected" value="#b5c7e7" link="#0F3660" \
vlink="#0F3660" hlink="#000066"/> +    <color name="subtab-selected" value="#4a6d8c" \
link="#0F3660" vlink="#0F3660" hlink="#000066"/> +    <color name="subtab-unselected" \
value="#4a6d8c" link="#0F3660" vlink="#0F3660" hlink="#000066"/> +    <color \
name="heading" value="#294563"/> +    <color name="subheading" value="#4a6d8c"/>
+    <color name="published" value="#4C6C8F" font="#FFFFFF"/>
+    <color name="feedback" value="#4C6C8F" font="#FFFFFF" align="center"/>
+    <color name="navstrip" value="#4a6d8c" font="#ffffff" link="#0F3660" \
vlink="#0F3660" hlink="#000066"/> +    <color name="menu" value="#4a6d8c" \
font="#cedfef" link="#ffffff" vlink="#ffffff" hlink="#ffcf00"/>     +    <color \
name="toolbox" value="#4a6d8c"/> +    <color name="border" value="#294563"/>
+    <color name="dialog" value="#4a6d8c"/>
+    <color name="searchbox" value="#4a6d8c" font="#000000"/>
+    <color name="body" value="#ffffff" link="#0F3660" vlink="#009999" \
hlink="#000066"/> +    <color name="table" value="#7099C5"/>    
+    <color name="table-cell" value="#f0f0ff"/>    
+    <color name="highlight" value="#ffff00"/>
+    <color name="fixme" value="#cc6600"/>
+    <color name="note" value="#006699"/>
+    <color name="warning" value="#990000"/>
+    <color name="code" value="#CFDCED"/>
+    <color name="footer" value="#cedfef"/>
+-->
+
+  <!-- Color group: Krysalis -->
+<!--
+    <color name="header"    value="#FFFFFF"/>
+
+    <color name="tab-selected" value="#a5b6c6" link="#000000" vlink="#000000" \
hlink="#000000"/> +    <color name="tab-unselected" value="#F7F7F7"  link="#000000" \
vlink="#000000" hlink="#000000"/> +    <color name="subtab-selected" value="#a5b6c6"  \
link="#000000" vlink="#000000" hlink="#000000"/> +    <color name="subtab-unselected" \
value="#a5b6c6"  link="#000000" vlink="#000000" hlink="#000000"/> +
+    <color name="heading" value="#a5b6c6"/>
+    <color name="subheading" value="#CFDCED"/>
+        
+    <color name="navstrip" value="#CFDCED" font="#000000" link="#000000" \
vlink="#000000" hlink="#000000"/> +    <color name="toolbox" value="#a5b6c6"/>
+    <color name="border" value="#a5b6c6"/>
+        
+    <color name="menu" value="#F7F7F7" link="#000000" vlink="#000000" \
hlink="#000000"/>     +    <color name="dialog" value="#F7F7F7"/>
+            
+    <color name="body"    value="#ffffff" link="#0F3660" vlink="#009999" \
hlink="#000066"/> +    
+    <color name="table" value="#a5b6c6"/>    
+    <color name="table-cell" value="#ffffff"/>    
+    <color name="highlight" value="#ffff00"/>
+    <color name="fixme" value="#cc6600"/>
+    <color name="note" value="#006699"/>
+    <color name="warning" value="#990000"/>
+    <color name="code" value="#a5b6c6"/>
+        
+    <color name="footer" value="#a5b6c6"/>
+-->
+
+  <!-- Color group: Collabnet --> 
+<!--
+    <color name="header"    value="#003366"/>
+
+    <color name="tab-selected" value="#dddddd" link="#555555" vlink="#555555" \
hlink="#555555"/> +    <color name="tab-unselected" value="#999999" link="#ffffff" \
vlink="#ffffff" hlink="#ffffff"/> +    <color name="subtab-selected" value="#cccccc" \
link="#000000" vlink="#000000" hlink="#000000"/> +    <color name="subtab-unselected" \
value="#cccccc" link="#555555" vlink="#555555" hlink="#555555"/> +
+    <color name="heading" value="#003366"/>
+    <color name="subheading" value="#888888"/>
+    
+    <color name="navstrip" value="#dddddd" font="#555555"/>
+    <color name="toolbox" value="#dddddd" font="#555555"/>
+    <color name="border" value="#999999"/>
+    
+    <color name="menu" value="#ffffff"/>    
+    <color name="dialog" value="#eeeeee"/>
+            
+    <color name="body"      value="#ffffff"/>
+    
+    <color name="table" value="#ccc"/>    
+    <color name="table-cell" value="#ffffff"/>   
+    <color name="highlight" value="#ffff00"/>
+    <color name="fixme" value="#cc6600"/>
+    <color name="note" value="#006699"/>
+    <color name="warning" value="#990000"/>
+    <color name="code" value="#003366"/>
+        
+    <color name="footer" value="#ffffff"/>
+-->
+ <!-- Color group: Lenya using pelt-->
+<!--
+
+    <color name="header" value="#ffffff"/>
+
+    <color name="tab-selected" value="#E5E4D9" link="#000000" vlink="#000000" \
hlink="#000000"/> +    <color name="tab-unselected" value="#F5F4E9" link="#000000" \
vlink="#000000" hlink="#000000"/> +    <color name="subtab-selected" value="#000000" \
link="#000000" vlink="#000000" hlink="#000000"/> +    <color name="subtab-unselected" \
value="#E5E4D9" link="#000000" vlink="#000000" hlink="#000000"/> +
+    <color name="heading" value="#E5E4D9"/>
+    <color name="subheading" value="#000000"/>
+    <color name="published" value="#000000"/>
+    <color name="navstrip" value="#E5E4D9" font="#000000"/>
+    <color name="toolbox" value="#CFDCED" font="#000000"/>
+    <color name="border" value="#999999"/>
+
+    <color name="menu" value="#E5E4D9" font="#000000" link="#000000" vlink="#000000" \
hlink="#000000"/> +    <color name="dialog" value="#CFDCED"/>
+    <color name="body" value="#ffffff" />
+
+    <color name="table" value="#ccc"/>
+    <color name="table-cell" value="#ffffff"/>
+    <color name="highlight" value="#ffff00"/>
+    <color name="fixme" value="#cc6600"/>
+    <color name="note" value="#006699"/>
+    <color name="warning" value="#990000"/>
+    <color name="code" value="#003366"/>
+
+    <color name="footer" value="#E5E4D9"/>
+-->
+  </colors>
+ 
+  <!-- Settings specific to PDF output. -->
+  <pdf>
+    <!-- 
+       Supported page sizes are a0, a1, a2, a3, a4, a5, executive,
+       folio, legal, ledger, letter, quarto, tabloid (default letter).
+       Supported page orientations are portrait, landscape (default
+       portrait).
+       Supported text alignments are left, right, justify (default left).
+    -->
+    <page size="letter" orientation="portrait" text-align="left"/>
+
+    <!-- 
+       Pattern of the page numbering in the footer - Default is "Page x".
+       first occurrence of '1' digit represents the current page number,
+       second occurrence of '1' digit represents the total page number,
+       anything else is considered as the static part of the numbering pattern.
+       Examples : x is the current page number, y the total page number.
+       <page-numbering-format>none</page-numbering-format> Do not displays the page \
numbering +       <page-numbering-format>1</page-numbering-format> Displays "x"
+       <page-numbering-format>p1.</page-numbering-format> Displays "px."
+       <page-numbering-format>Page 1/1</page-numbering-format> Displays "Page x/y"
+       <page-numbering-format>(1-1)</page-numbering-format> Displays "(x-y)"
+    -->
+    <page-numbering-format>Page 1</page-numbering-format>
+
+    <!--
+       Margins can be specified for top, bottom, inner, and outer
+       edges. If double-sided="false", the inner edge is always left
+       and the outer is always right. If double-sided="true", the
+       inner edge will be left on odd pages, right on even pages,
+       the outer edge vice versa.
+       Specified below are the default settings.
+    -->
+    <margins double-sided="false">
+      <top>1in</top>
+      <bottom>1in</bottom>
+      <inner>1.25in</inner>
+      <outer>1in</outer>
+    </margins>
+
+    <!--
+      Print the URL text next to all links going outside the file
+    -->
+    <show-external-urls>false</show-external-urls>
+
+    <!--
+      Disable the copyright footer on each page of the PDF.
+      A footer is composed for each page. By default, a "credit" with role=pdf
+      will be used, as explained below. Otherwise a copyright statement
+      will be generated. This latter can be disabled.
+    -->
+    <disable-copyright-footer>false</disable-copyright-footer>
+  </pdf>
+
+  <!-- 
+    Credits are typically rendered as a set of small clickable
+    images in the page footer.
+    
+    Use box-location="alt" to move the credits to an alternate location
+    (if the skin supports it).
+
+    For example, pelt skin:
+    - box-location="alt" will place the logo at the end of the
+      left-hand coloured menu panel.
+    - box-location="alt2" will place them underneath that panel
+      in the left-hand whitespace.
+    - Otherwise they are placed next to the compatibility icons
+      at the bottom of the screen.
 
-  <project-name>Plugin: Photo Gallery input</project-name>
-  <project-description>org.apache.forrest.plugin.input.PhotoGallery plugin for \
Apache Forrest</project-description> +    Comment out the whole <credit>-element if \
you want no credits in the +    web pages  
+   -->
+  <credits>
+    <credit box-location="alt">
+      <name>Built with Apache Forrest</name>
+      <url>http://forrest.apache.org/</url>
+      <image>images/built-with-forrest-button.png</image>
+      <width>88</width>
+      <height>31</height>
+    </credit>
+    <!-- A credit with @role="pdf" will be used to compose a footer
+     for each page in the PDF, using either "name" or "url" or both.
+    -->
+    <!--
+    <credit role="pdf">
+      <name>Built with Apache Forrest</name>
+      <url>http://forrest.apache.org/</url>
+    </credit>
+    -->
+  </credits>
 
 </skinconfig>

Added: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/forrest/reading/PersistentImageReader.java
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.inp \
ut.PhotoGallery/src/java/org/apache/forrest/reading/PersistentImageReader.java?rev=373448&view=auto
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/forrest/reading/PersistentImageReader.java \
                (added)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/forrest/reading/PersistentImageReader.java \
Sun Jan 29 22:23:20 2006 @@ -0,0 +1,390 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.forrest.reading;
+
+import java.awt.color.ColorSpace;
+import java.awt.geom.AffineTransform;
+import java.awt.image.AffineTransformOp;
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorConvertOp;
+import java.awt.image.RescaleOp;
+import java.awt.image.WritableRaster;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Map;
+import java.net.URI;
+import javax.imageio.stream.FileImageOutputStream;
+import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.metadata.*;
+import javax.imageio.*;
+import org.apache.avalon.framework.parameters.Parameters;
+import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.environment.SourceResolver;
+import org.apache.cocoon.reading.ResourceReader;
+import org.xml.sax.SAXException;
+
+import com.sun.image.codec.jpeg.ImageFormatException;
+import com.sun.image.codec.jpeg.JPEGCodec;
+import com.sun.image.codec.jpeg.JPEGDecodeParam;
+import com.sun.image.codec.jpeg.JPEGEncodeParam;
+import com.sun.image.codec.jpeg.JPEGImageDecoder;
+import com.sun.image.codec.jpeg.JPEGImageEncoder;
+
+/**
+ * The <code>PersistentImageReader</code> component is used to serve binary image \
data + * in a sitemap pipeline and persist it to disk. It makes use of HTTP Headers \
to determine if + * the requested resource should be written to the \
<code>OutputStream</code> + * or if it can signal that it hasn't changed.
+ *
+ * Parameters:
+ *   <dl>
+ *     <dt>&lt;width&gt;</dt>
+ *     <dd> This parameter is optional. When specified, it determines the
+ *          width of the binary image.
+ *          If no height parameter is specified, the aspect ratio
+ *          of the image is kept. The parameter may be expressed as an int or a \
percentage. + *     </dd>
+ *     <dt>&lt;height&gt;</dt>
+ *     <dd> This parameter is optional. When specified, it determines the
+ *          height of the binary image.
+ *          If no width parameter is specified, the aspect ratio
+ *          of the image is kept. The parameter may be expressed as an int or a \
percentage. + *     </dd>
+ *     <dt>&lt;scale(Red|Green|Blue)&gt;</dt>
+ *     <dd>This parameter is optional. When specified it will cause the
+ *         specified color component in the image to be multiplied by the
+ *         specified floating point value.
+ *     </dd>
+ *     <dt>&lt;offset(Red|Green|Blue)&gt;</dt>
+ *     <dd>This parameter is optional. When specified it will cause the
+ *         specified color component in the image to be incremented by the
+ *         specified floating point value.
+ *     </dd>
+ *     <dt>&lt;grayscale&gt;</dt>
+ *     <dd>This parameter is optional. When specified and set to true it
+ *         will cause each image pixel to be normalized. Default is "false".
+ *     </dd>
+ *     <dt>&lt;allow-enlarging&gt;</dt>
+ *     <dd>This parameter is optional. By default, if the image is smaller
+ *         than the specified width and height, the image will be enlarged.
+ *         In some circumstances this behaviour is undesirable, and can be
+ *         switched off by setting this parameter to "<code>false</code>" so that
+ *         images will be reduced in size, but not enlarged. The default is
+ *         "<code>true</code>".
+ *     </dd>
+ *     <dt>&lt;quality&gt;</dt>
+ *     <dd>This parameter is optional. By default, the quality uses the
+ *         default for the JVM. If it is specified, the proper JPEG quality
+ *         compression is used. The range is 0.0 to 1.0, if specified. 
+ *     </dd>
+ *   </dl>
+ *
+ * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
+ * @author <a href="mailto:stephan@apache.org">Stephan Michels</a>
+ * @author <a href="mailto:tcurdt@apache.org">Torsten Curdt</a>
+ * @author <a href="mailto:eric@plauditdesign.com">Eric Caron</a>
+ * @version $Id: ImageReader.java 348563 2005-11-23 21:02:33Z vgritsenko $
+ */
+final public class PersistentImageReader extends ResourceReader {
+    private static final boolean GRAYSCALE_DEFAULT = false;
+    private static final boolean ENLARGE_DEFAULT = true;
+    private static final boolean FIT_DEFAULT = false;
+
+    private int width;
+    private int height;
+    private float[] scaleColor = new float[3];
+    private float[] offsetColor = new float[3];
+    private float[] quality = new float[1];
+    
+    private String variant = null;
+
+    private boolean enlarge;
+    private boolean fitUniform;
+    private boolean usePercent;
+    private RescaleOp colorFilter;
+    private ColorConvertOp grayscaleFilter;
+
+
+    public void setup(SourceResolver resolver, Map objectModel, String src, \
Parameters par) +    throws ProcessingException, SAXException, IOException {
+
+        char lastChar;
+        String tmpWidth = par.getParameter("width", "0");
+        String tmpHeight = par.getParameter("height", "0");
+       
+        this.variant = par.getParameter("variant", "thumb");
+        getLogger().error("IMAGE VARIANT: " + this.variant);
+        this.scaleColor[0] = par.getParameterAsFloat("scaleRed", -1.0f);
+        this.scaleColor[1] = par.getParameterAsFloat("scaleGreen", -1.0f);
+        this.scaleColor[2] = par.getParameterAsFloat("scaleBlue", -1.0f);
+        this.offsetColor[0] = par.getParameterAsFloat("offsetRed", 0.0f);
+        this.offsetColor[1] = par.getParameterAsFloat("offsetGreen", 0.0f);
+        this.offsetColor[2] = par.getParameterAsFloat("offsetBlue", 0.0f);
+        this.quality[0] = par.getParameterAsFloat("quality", 0.9f);
+
+        boolean filterColor = false;
+        for (int i = 0; i < 3; ++i) {
+            if (this.scaleColor[i] != -1.0f) {
+                filterColor = true;
+            } else {
+                this.scaleColor[i] = 1.0f;
+            }
+            if (this.offsetColor[i] != 0.0f) {
+                filterColor = true;
+            }
+        }
+
+        if (filterColor) {
+            this.colorFilter = new RescaleOp(scaleColor, offsetColor, null);
+        }
+
+        usePercent = false;
+        lastChar = tmpWidth.charAt(tmpWidth.length() - 1);
+        if (lastChar == '%') {
+            usePercent = true;
+            width = Integer.parseInt(tmpWidth.substring(0, tmpWidth.length() - 1));
+        } else {
+            width = Integer.parseInt(tmpWidth);
+        }
+
+        lastChar = tmpHeight.charAt(tmpHeight.length() - 1);
+        if(lastChar == '%') {
+            usePercent = true;
+            height = Integer.parseInt(tmpHeight.substring(0, tmpHeight.length() - \
1)); +        } else {
+            height = Integer.parseInt(tmpHeight);
+        }
+
+        if (par.getParameterAsBoolean("grayscale", GRAYSCALE_DEFAULT)) {
+            this.grayscaleFilter = new \
ColorConvertOp(ColorSpace.getInstance(ColorSpace.CS_GRAY), null); +        }
+
+        this.enlarge = par.getParameterAsBoolean("allow-enlarging", \
ENLARGE_DEFAULT); +        this.fitUniform = par.getParameterAsBoolean("fit-uniform", \
FIT_DEFAULT); +
+        super.setup(resolver, objectModel, src, par);
+    }
+
+    protected void setupHeaders() {
+        // Reset byte ranges support for dynamic response
+        if (byteRanges && hasTransform()) {
+            byteRanges = false;
+        }
+
+        super.setupHeaders();
+    }
+
+    /**
+     * @return True if image transform is specified
+     */
+    private boolean hasTransform() {
+        return width > 0 || height > 0 || null != colorFilter || null != \
grayscaleFilter || (this.quality[0] != 0.9f); +    }
+
+    /**
+     * Returns the affine transform that implements the scaling.
+     * The behavior is the following: if both the new width and height values
+     * are positive, the image is rescaled according to these new values and
+     * the original aspect ratio is lost.
+     * Otherwise, if one of the two parameters is zero or negative, the
+     * aspect ratio is maintained and the positive parameter indicates the
+     * scaling.
+     * If both new values are zero or negative, no scaling takes place (a unit
+     * transformation is applied).
+     */
+    private AffineTransform getTransform(double ow, double oh, double nw, double nh) \
{ +        double wm = 1.0d;
+        double hm = 1.0d;
+
+        if (fitUniform) {
+            //
+            // Compare aspect ratio of image vs. that of the "box"
+            // defined by nw and nh
+            //
+            if (ow/oh > nw/nh) {
+                nh = 0;    // Original image is proportionately wider than the box,
+                        // so scale to fit width
+            } else {
+                nw = 0;    // Scale to fit height
+            }
+        }
+
+        if (nw > 0) {
+            wm = nw / ow;
+            if (nh > 0) {
+                hm = nh / oh;
+            } else {
+                hm = wm;
+            }
+        } else {
+            if (nh > 0) {
+                hm = nh / oh;
+                wm = hm;
+            }
+        }
+
+        if (!enlarge) {
+            if ((nw > ow && nh <= 0) || (nh > oh && nw <=0)) {
+                wm = 1.0d;
+                hm = 1.0d;
+            } else if (nw > ow) {
+                wm = 1.0d;
+            } else if (nh > oh) {
+                hm = 1.0d;
+            }
+        }
+        return new AffineTransform(wm, 0.0d, 0.0d, hm, 0.0d, 0.0d);
+    }
+
+    protected void processStream(InputStream inputStream) throws IOException, \
ProcessingException { +        if (hasTransform()) {
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("image " + ((width == 0) ? "?" : \
Integer.toString(width)) +                                  + "x"    + ((height == 0) \
? "?" : Integer.toString(height)) +                                  + " expires: " + \
expires); +            }
+            String fName = super.inputSource.getURI();
+            fName = fName.replaceFirst(".jpg","." + this.variant + ".jpg");
+            try {
+                JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(inputStream);
+                BufferedImage original = decoder.decodeAsBufferedImage();
+                BufferedImage currentImage = original;
+                
+                if (width > 0 || height > 0) {
+                    JPEGDecodeParam decodeParam = decoder.getJPEGDecodeParam();
+                    double ow = decodeParam.getWidth();
+                    double oh = decodeParam.getHeight();
+
+                    if (usePercent) {
+                        if (width > 0) {
+                            width = Math.round((int)(ow * width) / 100);
+                        }
+                        if (height > 0) {
+                            height = Math.round((int)(oh * height) / 100);
+                        }
+                    }
+
+                    AffineTransformOp filter = new \
AffineTransformOp(getTransform(ow, oh, width, height), \
AffineTransformOp.TYPE_BILINEAR); +                    WritableRaster scaledRaster = \
filter.createCompatibleDestRaster(currentImage.getRaster()); +
+                    filter.filter(currentImage.getRaster(), scaledRaster);
+
+                    //write the thumbnail.
+                
+                    BufferedImage thumbBuffer = new \
BufferedImage(original.getColorModel(), scaledRaster, true, null); +                  \
URI fUri = new URI(fName); +                    fName = fUri.getPath();
+                    File persistentImgFile = new File(fName );
+                    getLogger().debug("TRYING THUMB");
+                    if (persistentImgFile.exists() == false) { 
+                    	persistentImgFile.createNewFile();
+                    }
+            		//FileImageOutputStream persistentImgStream = new \
FileImageOutputStream(persistentImgFile); +            		ImageWriter writer = \
(ImageWriter)ImageIO.getImageWritersByFormatName("JPEG").next(); +            \
ImageWriteParam wp = writer.getDefaultWriteParam(); +            		
+            		ImageOutputStream imgOut = \
ImageIO.createImageOutputStream(persistentImgFile); +            		IIOImage imgImage \
= new IIOImage(thumbBuffer, null, null); +            		writer.setOutput(imgOut);
+            		//ImageIO.write(thumbBuffer,"jpg",imgOut);
+            		
+           	  		writer.write(null,imgImage,wp);
+                 
+                 
+                    currentImage = new BufferedImage(original.getColorModel(), \
scaledRaster, true, null); +                }
+
+                if (null != grayscaleFilter) {
+                    grayscaleFilter.filter(currentImage, currentImage);
+                }
+
+                if (null != colorFilter) {
+                    colorFilter.filter(currentImage, currentImage);
+                }
+
+                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
+                JPEGEncodeParam p = encoder.getDefaultJPEGEncodeParam(currentImage);
+                p.setQuality(this.quality[0], true);
+                encoder.setJPEGEncodeParam(p);
+                encoder.encode(currentImage);
+                
+                
+                
+                out.flush();
+            } catch (java.net.URISyntaxException e) {
+                throw new ProcessingException("Error creating thumbnail: "+ fName \
,e); +            } catch (ImageFormatException e) {
+                throw new ProcessingException("Error reading the image. " +
+                                              "Note that only JPEG images are \
currently supported."); +            } finally {
+              // Bugzilla Bug 25069, close inputStream in finally block
+              // this will close inputStream even if processStream throws
+              // an exception
+              inputStream.close();
+            }
+        } else {
+            // only read the resource - no modifications requested
+            if (getLogger().isDebugEnabled()) {
+                getLogger().debug("passing original resource");
+            }
+            super.processStream(inputStream);
+        }
+    }
+    
+    private void writeThumbnail(WritableRaster img) throws ProcessingException {
+    	try {
+    		String fName = super.inputSource.getURI();
+    		fName = fName.replaceFirst(".",".thumb.");
+    		File persistentImgFile = new File(fName);
+    		FileImageOutputStream persistentImgStream = new \
FileImageOutputStream(persistentImgFile); +    		ImageWriter writer = \
(ImageWriter)ImageIO.getImageWritersByFormatName("JPEG"); +    		IIOImage imgImage = \
new IIOImage(img, null, null); +    		writer.setOutput(persistentImgStream);
+   	  		writer.write((IIOMetadata)null,imgImage ,null);
+    	} catch (Exception e) {
+    		throw new ProcessingException("Error persisting new thumbnail: " + \
super.inputSource.getURI()); +    	}
+    }
+
+    /**
+     * Generate the unique key.
+     * This key must be unique inside the space of this component.
+     *
+     * @return The generated key consists of the src and width and height,
+     *         and the color transform parameters
+    */
+    public Serializable getKey() {
+        return super.getKey().toString()
+                + ':' + this.width
+                + ':' + this.height
+                + ":" + this.scaleColor[0]
+                + ":" + this.scaleColor[1]
+                + ":" + this.scaleColor[2]
+                + ":" + this.offsetColor[0]
+                + ":" + this.offsetColor[1]
+                + ":" + this.offsetColor[2]
+                + ":" + this.quality[0]
+                + ":" + (this.grayscaleFilter == null ? "color" : "bw");
+    }
+
+    public void recycle(){
+        super.recycle();
+        this.colorFilter = null;
+        this.grayscaleFilter = null;
+    }
+}

Propchange: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/src/java/org/apache/forrest/reading/PersistentImageReader.java
                
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/status.xml
                
URL: http://svn.apache.org/viewcvs/forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/status.xml?rev=373448&r1=373447&r2=373448&view=diff
 ==============================================================================
--- forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/status.xml \
                (original)
+++ forrest/trunk/plugins/org.apache.forrest.plugin.input.PhotoGallery/status.xml Sun \
Jan 29 22:23:20 2006 @@ -23,6 +23,10 @@
         Use locationmap for resolution of resources and files. Resources are exposed \
via  {lm:photoGallery.*}
       </action>
+      <action type="add" context="code" dev="TWW">
+        Added a "main" index page that supports multiple galleries.  Automated the \
image +        variant (e.g. thumb, small) creation.  Allow albums to contain \
metadata. +      </action>
     </release>
       
     <release version="0.1" date="not-released">


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic