You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/09/20 21:14:43 UTC

svn commit: r290532 - in /cocoon: blocks/portal-sample/trunk/samples/coplets/gallery/ blocks/portal-sample/trunk/samples/profiles/copletdata/ blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/ trunk/

Author: cziegeler
Date: Tue Sep 20 12:14:20 2005
New Revision: 290532

URL: http://svn.apache.org/viewcvs?rev=290532&view=rev
Log:
Provide sample for caching uri coplet adapter (Gallery coplet) and fix event hierarchy

Modified:
    cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl
    cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl
    cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/sitemap.xmap
    cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml
    cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/CopletStatusEvent.java
    cocoon/trunk/status.xml

Modified: cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl?rev=290532&r1=290531&r2=290532&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl (original)
+++ cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/gallery.xsl Tue Sep 20 12:14:20 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-  Copyright 1999-2004 The Apache Software Foundation
+  Copyright 1999-2005 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.
@@ -17,7 +17,9 @@
 <!-- $Id$ 
 
 -->
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:java="http://xml.apache.org/xalan/java">
 
 <!-- The current picture (index) to display -->
 <xsl:param name="pic"/>
@@ -25,73 +27,75 @@
 <xsl:param name="fullscreen"/>
 
 <xsl:template match="pictures" xmlns:cl="http://apache.org/cocoon/portal/coplet/1.0">
-<xsl:variable name="maxp" select="count(picture)"/>
+  <xsl:variable name="maxp" select="count(picture)"/>
 
-<xsl:choose>
-<xsl:when test="$fullscreen='true'">
-  <!-- This is the two column version: 
-  <table>
-    <xsl:for-each select="picture">
-        <xsl:if test="position() mod 2 = 1">
+  <xsl:choose>
+    <xsl:when test="$fullscreen='true'">
+      <!-- This is the two column version: 
+      <table><tbody>
+        <xsl:for-each select="picture">
+          <xsl:if test="position() mod 2 = 1">
             <tr>        
-                <td><img src="{.}"/></td>
-                <xsl:choose>
-                    <xsl:when test="position() = last()">
-                        <td>&#160;</td>
-                    </xsl:when>
-                    <xsl:otherwise>
-                        <xsl:variable name="p" select="position()+1"/>
-                        <td><img src="{//picture[position()=$p]}"/></td>
-                    </xsl:otherwise>
-                </xsl:choose>
+              <td><img src="{.}"/></td>
+              <xsl:choose>
+                <xsl:when test="position() = last()">
+                  <td>&#160;</td>
+                </xsl:when>
+                <xsl:otherwise>
+                  <xsl:variable name="p" select="position()+1"/>
+                  <td><img src="{//picture[position()=$p]}"/></td>
+                </xsl:otherwise>
+              </xsl:choose>
             </tr>
+          </xsl:if>
+        </xsl:for-each>
+      </tbody></table>
+      -->
+      <!-- And this is the simple version -->
+      <table><tbody>
+        <tr width="100%">
+          <td>
+            <xsl:for-each select="picture">
+              <img src="{.}"/><xsl:text> </xsl:text>
+            </xsl:for-each>
+          </td>
+        </tr>
+      </tbody></table>
+      <p>Date: <xsl:value-of select="java:java.util.Date.new()"/></p>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:variable name="picn">
+        <xsl:choose>
+          <xsl:when test="$pic=$maxp">1</xsl:when>
+          <xsl:when test="$pic=''">2</xsl:when>
+          <xsl:otherwise><xsl:value-of select="$pic+1"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="picp">
+        <xsl:choose>
+          <xsl:when test="$pic=1 or $pic=''"><xsl:value-of select="$maxp"/></xsl:when>
+          <xsl:otherwise><xsl:value-of select="$pic - 1"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+      <xsl:variable name="showpicindex">
+        <xsl:choose>
+          <xsl:when test="$pic=1 or $pic=''">1</xsl:when>
+          <xsl:otherwise><xsl:value-of select="$pic"/></xsl:otherwise>
+        </xsl:choose>
+      </xsl:variable>
+
+      <p>Picture <xsl:value-of select="$showpicindex"/> of <xsl:value-of select="$maxp"/>
+        <xsl:if test="$showpicindex &gt; 1">
+          - <cl:link path="attributes/picture" value="{$picp}" coplet="Gallery-Petstore">&#xAB; Previous</cl:link>
         </xsl:if>
-    </xsl:for-each>
-  </table>
-  -->
-  <!-- And this is the simple version -->
-      <table>
-          <tr width="100%">
-              <td>
-                <xsl:for-each select="picture">
-                   <img src="{.}"/><xsl:text> </xsl:text>
-                </xsl:for-each>
-              </td>
-          </tr>
-      </table>
-</xsl:when>
-<xsl:otherwise>
-  <xsl:variable name="picn">
-    <xsl:choose>
-      <xsl:when test="$pic=$maxp">1</xsl:when>
-      <xsl:when test="$pic=''">2</xsl:when>
-      <xsl:otherwise><xsl:value-of select="$pic+1"/></xsl:otherwise>
-    </xsl:choose>
-  </xsl:variable>
-  <xsl:variable name="picp">
-    <xsl:choose>
-      <xsl:when test="$pic=1 or $pic=''"><xsl:value-of select="$maxp"/></xsl:when>
-      <xsl:otherwise><xsl:value-of select="$pic - 1"/></xsl:otherwise>
-    </xsl:choose>
-  </xsl:variable>
-  <xsl:variable name="showpicindex">
-    <xsl:choose>
-      <xsl:when test="$pic=1 or $pic=''">1</xsl:when>
-      <xsl:otherwise><xsl:value-of select="$pic"/></xsl:otherwise>
-    </xsl:choose>
-  </xsl:variable>
-
-  <p>Picture <xsl:value-of select="$showpicindex"/> of <xsl:value-of select="$maxp"/>
-    <xsl:if test="$showpicindex &gt; 1">
-      - <cl:link path="attributes/picture" value="{$picp}">&#xAB; Previous</cl:link>
-    </xsl:if>
-    <xsl:if test="$showpicindex &lt; $maxp">
-      - <cl:link path="attributes/picture" value="{$picn}">Next &#xBB;</cl:link>
-    </xsl:if>
-    </p>
-    <p><cl:link path="attributes/picture" value="{picture[position()=$showpicindex]}" coplet="GalleryViewer-1">Push to Viewer</cl:link></p>
-    <img src="{picture[position()=$showpicindex]}"/>
-</xsl:otherwise>
-</xsl:choose>
+        <xsl:if test="$showpicindex &lt; $maxp">
+          - <cl:link path="attributes/picture" value="{$picn}" coplet="Gallery-Petstore">Next &#xBB;</cl:link>
+        </xsl:if>
+      </p>
+      <p><cl:link path="attributes/picture" value="{picture[position()=$showpicindex]}" coplet="GalleryViewer-1">Push to Viewer</cl:link></p>
+      <img src="{picture[position()=$showpicindex]}"/>
+      <p>Date: <xsl:value-of select="java:java.util.Date.new()"/></p>
+    </xsl:otherwise>
+  </xsl:choose>
 </xsl:template>
 </xsl:stylesheet>

Modified: cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl?rev=290532&r1=290531&r2=290532&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl (original)
+++ cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/picture.xsl Tue Sep 20 12:14:20 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-  Copyright 1999-2004 The Apache Software Foundation
+  Copyright 1999-2005 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.
@@ -17,10 +17,13 @@
 <!-- $Id$ 
 
 -->
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:java="http://xml.apache.org/xalan/java">
 
 <!-- The current picture to display -->
 <xsl:param name="pic"/>
+<xsl:param name="tpic"/>
 
 <xsl:template match="pictures" xmlns:cl="http://apache.org/cocoon/portal/coplet/1.0">
     <xsl:choose>
@@ -29,6 +32,9 @@
         </xsl:when>
         <xsl:otherwise>
             <img src="{$pic}"/>
+            <p><cl:link path="temporaryAttributes/pictitle" value="{$pic}" coplet="GalleryViewer-1">Show file name</cl:link>
+            <br/><xsl:value-of select="$tpic"/></p>
+            <p>Date: <xsl:value-of select="java:java.util.Date.new()"/></p>
         </xsl:otherwise>
     </xsl:choose>
 </xsl:template>

Modified: cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/sitemap.xmap?rev=290532&r1=290531&r2=290532&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/sitemap.xmap (original)
+++ cocoon/blocks/portal-sample/trunk/samples/coplets/gallery/sitemap.xmap Tue Sep 20 12:14:20 2005
@@ -1,6 +1,6 @@
 <?xml version="1.0"?>
 <!--
-  Copyright 1999-2004 The Apache Software Foundation
+  Copyright 1999-2005 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.
@@ -24,7 +24,10 @@
 	<map:match pattern="images/*.jpg">
     	<map:read mime-type="image/jpg" src="samplepics/{1}.jpg"/>
    	</map:match>
-
+  </map:pipeline>
+  <!--  We are using the caching uri coplet adapter caching the 
+        content anyway, so no need to use pipeline caching. -->
+  <map:pipeline type="noncaching">
     <!-- this is a gallery coplet -->
     <map:match pattern="browser">
         <map:generate type="directory" src="{coplet:copletData/attributes/image-dir}">
@@ -37,13 +40,17 @@
             <map:parameter name="pic" value="{coplet:attributes/picture}"/>
             <map:parameter name="fullscreen" value="{coplet:aspectDatas/fullScreen}"/>
         </map:transform>
+        <!-- This must be commented out if CachingURICopletAdapter is used in profiles/copletdata
+             due to links that needs to be cached untranslated.
         <map:transform type="portal-coplet"/>
+        -->
         <map:serialize type="xml"/>
     </map:match>
     <map:match pattern="viewer">
         <map:generate src="picture.xml"/>
         <map:transform type="xslt" src="picture.xsl">
             <map:parameter name="pic" value="{coplet:attributes/picture}"/>
+            <map:parameter name="tpic" value="{coplet:temporaryAttributes/pictitle}"/>
         </map:transform>
         <map:serialize type="xml"/>
     </map:match>

Modified: cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml?rev=290532&r1=290531&r2=290532&view=diff
==============================================================================
--- cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml (original)
+++ cocoon/blocks/portal-sample/trunk/samples/profiles/copletdata/portal.xml Tue Sep 20 12:14:20 2005
@@ -196,7 +196,11 @@
      -->
    <coplet-data id="Gallery" name="standard">
       <title>Picture Gallery</title>
-      <coplet-base-data>URICoplet</coplet-base-data>
+      <coplet-base-data>CachingURICoplet</coplet-base-data>
+      <attribute>
+        <name>buffer</name>
+        <value xsi:type="java:java.lang.Boolean">true</value>
+      </attribute>
       <attribute>
          <name>uri</name>
          <value xsi:type="java:java.lang.String">cocoon:/coplets/gallery/browser</value>
@@ -216,7 +220,11 @@
    </coplet-data>
    <coplet-data id="GalleryViewer" name="standard">
       <title>Gallery Viewer</title>
-      <coplet-base-data>URICoplet</coplet-base-data>
+      <coplet-base-data>CachingURICoplet</coplet-base-data>
+      <attribute>
+        <name>buffer</name>
+        <value xsi:type="java:java.lang.Boolean">true</value>
+      </attribute>
       <attribute>
          <name>uri</name>
          <value xsi:type="java:java.lang.String">cocoon:/coplets/gallery/viewer</value>

Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/CopletStatusEvent.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/CopletStatusEvent.java?rev=290532&r1=290531&r2=290532&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/CopletStatusEvent.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/event/impl/CopletStatusEvent.java Tue Sep 20 12:14:20 2005
@@ -17,6 +17,7 @@
 
 import org.apache.cocoon.portal.coplet.CopletInstanceData;
 import org.apache.cocoon.portal.event.ComparableEvent;
+import org.apache.cocoon.portal.event.CopletInstanceEvent;
 import org.apache.cocoon.portal.event.Event;
 
 /**
@@ -28,7 +29,7 @@
  * @version CVS $Id$
  */
 public abstract class CopletStatusEvent
-    implements Event, ComparableEvent {
+    implements Event, ComparableEvent, CopletInstanceEvent {
 
     protected CopletInstanceData coplet;
 
@@ -47,4 +48,10 @@
         return false;
     }
 
+    /**
+     * @see org.apache.cocoon.portal.event.ActionEvent#getTarget()
+     */
+    public Object getTarget() {
+        return this.coplet;
+    }
 }

Modified: cocoon/trunk/status.xml
URL: http://svn.apache.org/viewcvs/cocoon/trunk/status.xml?rev=290532&r1=290531&r2=290532&view=diff
==============================================================================
--- cocoon/trunk/status.xml (original)
+++ cocoon/trunk/status.xml Tue Sep 20 12:14:20 2005
@@ -570,6 +570,12 @@
    </action>
   </release>
   <release version="2.1.8" date="TBD">
+    <action dev="CZ" type="update" fixes-bug="32994" due-to="Michal Durdina" due-to-email="durdina@asset.sk">
+      Portal Block: Provide sample for caching uri coplet adapter (Gallery coplet).
+    </action>
+    <action dev="CZ" type="fix">
+      Portal Block: Add missing interface CopletInstanceEvent to FullScreenCopletEvent.
+    </action>
     <action dev="AG" type="add" fixes-bug="31600" due-to="Jason Johnston" due-to-email="apache.bugs@lojjic.net">
       Caching support for XInclude Transformer
     </action>