cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hepab...@apache.org
Subject svn commit: r314929 - in /cocoon: blocks/core-samples-additional/trunk/samples/ blocks/core-samples-additional/trunk/samples/resources/ blocks/core-samples-additional/trunk/samples/resources/i18n/ blocks/core-samples-additional/trunk/samples/stylesheet...
Date Wed, 12 Oct 2005 14:28:16 GMT
Author: hepabolu
Date: Wed Oct 12 07:28:01 2005
New Revision: 314929

URL: http://svn.apache.org/viewcvs?rev=314929&view=rev
Log:
Syncing the changes to CalenderGenerator and the calendar sample 
(core-samples-additional) from branch to trunk. Also moved the calendar2html 
stylesheet to a more appropriate place under the core-samples-additional block.

Added:
    cocoon/blocks/core-samples-additional/trunk/samples/resources/
    cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/
    cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages.xml
    cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_fr.xml
    cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_nl.xml
    cocoon/blocks/core-samples-additional/trunk/samples/stylesheets/calendar2html.xslt   (contents,
props changed)
      - copied, changed from r314854, cocoon/trunk/src/webapp/stylesheets/system/calendar2html.xslt
Removed:
    cocoon/trunk/src/webapp/stylesheets/system/calendar2html.xslt
Modified:
    cocoon/blocks/core-samples-additional/trunk/samples/sitemap.xmap
    cocoon/trunk/src/java/org/apache/cocoon/generation/CalendarGenerator.java

Added: cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages.xml?rev=314929&view=auto
==============================================================================
--- cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages.xml (added)
+++ cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages.xml Wed Oct
12 07:28:01 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<!--+
+    | Default (English) message catalogue file for Cocoon 2 CalendarGenerator sample
+    |
+    | CVS $Id:  $
+    +-->
+    
+    <catalogue xml:lang="en">
+        <message key="SUNDAY">Sunday</message>
+        <message key="MONDAY">Monday</message>
+        <message key="TUESDAY">Tuesday</message>
+        <message key="WEDNESDAY">Wednesday</message>
+        <message key="THURSDAY">Thursday</message>
+        <message key="FRIDAY">Friday</message>
+        <message key="SATURDAY">Saturday</message>
+    </catalogue>
+    

Added: cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_fr.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_fr.xml?rev=314929&view=auto
==============================================================================
--- cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_fr.xml (added)
+++ cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_fr.xml Wed
Oct 12 07:28:01 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<!--+
+    | French message catalogue file for Cocoon 2 CalendarGenerator sample
+    |
+    | CVS $Id:  $
+    +-->
+    
+    <catalogue xml:lang="fr">
+        <message key="SUNDAY">dimanche</message>
+        <message key="MONDAY">lundi</message>
+        <message key="TUESDAY">mardi</message>
+        <message key="WEDNESDAY">mercredi</message>
+        <message key="THURSDAY">jeudi</message>
+        <message key="FRIDAY">vendredi</message>
+        <message key="SATURDAY">samedi</message>
+    </catalogue>
+    

Added: cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_nl.xml
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_nl.xml?rev=314929&view=auto
==============================================================================
--- cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_nl.xml (added)
+++ cocoon/blocks/core-samples-additional/trunk/samples/resources/i18n/messages_nl.xml Wed
Oct 12 07:28:01 2005
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<!--+
+    | Dutch message catalogue file for Cocoon 2 CalendarGenerator sample
+    |
+    | CVS $Id:  $
+    +-->
+    
+    <catalogue xml:lang="nl">
+        <message key="SUNDAY">Zondag</message>
+        <message key="MONDAY">Maandag</message>
+        <message key="TUESDAY">Dinsdag</message>
+        <message key="WEDNESDAY">Woensdag</message>
+        <message key="THURSDAY">Donderdag</message>
+        <message key="FRIDAY">Vrijdag</message>
+        <message key="SATURDAY">Zaterdag</message>
+    </catalogue>
+    

Modified: cocoon/blocks/core-samples-additional/trunk/samples/sitemap.xmap
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core-samples-additional/trunk/samples/sitemap.xmap?rev=314929&r1=314928&r2=314929&view=diff
==============================================================================
--- cocoon/blocks/core-samples-additional/trunk/samples/sitemap.xmap (original)
+++ cocoon/blocks/core-samples-additional/trunk/samples/sitemap.xmap Wed Oct 12 07:28:01 2005
@@ -26,6 +26,15 @@
       <map:generator name="linkstatus" src="org.apache.cocoon.generation.LinkStatusGenerator"/>
       <map:generator name="calendar" src="org.apache.cocoon.generation.CalendarGenerator"/>
     </map:generators>
+    <map:transformers default="xslt">
+      <!-- Configure i18n transformer -->
+      <map:transformer name="i18n" logger="sitemap.transformer.i18n" src="org.apache.cocoon.transformation.I18nTransformer">
+         <catalogues default="messages">
+            <catalogue id="messages" name="messages" location="resources/i18n"/>
+         </catalogues>
+         <cache-at-startup>true</cache-at-startup>
+      </map:transformer>
+    </map:transformers>
   </map:components>
 
   <!-- =========================== Views =================================== -->
@@ -194,11 +203,21 @@
           <map:parameter name="month" value="6"/>
           <map:parameter name="year" value="1998"/>
           -->
+          <!-- Uncomment the line below to set a fixed date format -->
+          <!--
           <map:parameter name="dateFormat" value="EEEE, MMMM d yyyy"/>
-          <map:parameter name="lang" value="en"/>
-          <map:parameter name="country" value="US"/>
+          -->
+          <map:parameter name="lang" value="{request-param:lang}"/>
+          <map:parameter name="country" value="{request-param:country}"/>
         </map:generate>
-        <map:transform src="context://stylesheets/system/calendar2html.xslt"/>
+        <map:transform src="stylesheets/calendar2html.xslt"/>
+        <!-- to localize the column headers, remove the comments below -->
+        <!--
+        <map:transform type="i18n">
+           <map:parameter name="default-catalogue-id" value="messages"/>
+           <map:parameter name="locale" value="{request-param:lang}"/>
+        </map:transform> 
+        -->
         <map:serialize/>
       </map:match>
 

Copied: cocoon/blocks/core-samples-additional/trunk/samples/stylesheets/calendar2html.xslt
(from r314854, cocoon/trunk/src/webapp/stylesheets/system/calendar2html.xslt)
URL: http://svn.apache.org/viewcvs/cocoon/blocks/core-samples-additional/trunk/samples/stylesheets/calendar2html.xslt?p2=cocoon/blocks/core-samples-additional/trunk/samples/stylesheets/calendar2html.xslt&p1=cocoon/trunk/src/webapp/stylesheets/system/calendar2html.xslt&r1=314854&r2=314929&rev=314929&view=diff
==============================================================================
--- cocoon/trunk/src/webapp/stylesheets/system/calendar2html.xslt (original)
+++ cocoon/blocks/core-samples-additional/trunk/samples/stylesheets/calendar2html.xslt Wed
Oct 12 07:28:01 2005
@@ -15,10 +15,11 @@
   limitations under the License.
 -->
 
-<!-- CVS $Id: calendar2html.xslt,v 1.3 2004/04/09 14:31:48 ugo Exp $ -->
+<!-- CVS $Id$ -->
 
 <xsl:stylesheet version="1.0"
                 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
                 xmlns:calendar="http://apache.org/cocoon/calendar/1.0">
 
   <xsl:template match="/">
@@ -60,6 +61,10 @@
   padding-bottom: 2px;
 }
 
+.calendar .weekend {
+background-color: #c0c0c0;
+}
+
 .calendar .daytitle {
   position: relative;
   left: 0;
@@ -91,7 +96,22 @@
         </style>
       </head>
       <body>
-        <xsl:apply-templates/>
+          <p>
+              This sample shows a calendar that can be filled with events. The calendar is
localized, try one of the
+              following examples:
+          </p>
+          <p>
+              <a href="cal?lang=en&amp;country=US">US English</a><br/>
+              <a href="cal?lang=en&amp;country=GB">UK English</a><br/>
+              <a href="cal?lang=nl">Dutch</a><br/>
+              <a href="cal?lang=fr">French</a><br/>
+          </p>
+          <p>Note: the column headers are not localized, you can do that by simply
inserting the appropriate
+              i18n tags and transformer. Check the sample sources (sitemap and XSLT style
sheet) and uncomment
+              the lines.
+          </p>
+          <hr/>
+          <xsl:apply-templates/>
       </body>
     </html>
   </xsl:template>
@@ -104,13 +124,16 @@
         </caption>
         <thead>
           <tr>
-            <th>Sunday</th>
-            <th>Monday</th>
-            <th>Tuesday</th>
-            <th>Wednesday</th>
-            <th>Thursday</th>
-            <th>Friday</th>
-            <th>Saturday</th>
+            <xsl:for-each select="calendar:week[2]/calendar:day">
+              <th>
+                <xsl:if test="@weekday = 'SATURDAY' or @weekday='SUNDAY'">
+                  <xsl:attribute name="class">weekend</xsl:attribute>
+                </xsl:if>
+                <!-- The lines below provide i18n localization for headers -->
+                <!-- Note that you also need to provide the appropriate message files
-->
+                <i18n:text><xsl:value-of select="@weekday"/></i18n:text>
+              </th>
+            </xsl:for-each>
           </tr>
         </thead>
         <tbody>
@@ -119,7 +142,7 @@
       </table>
     </div>
   </xsl:template>
-  
+
   <xsl:template match="calendar:week">
     <tr>
       <xsl:if test="position() = 1">
@@ -146,6 +169,9 @@
       </xsl:if>
       <xsl:for-each select="calendar:day">
         <td>
+          <xsl:if test="@weekday = 'SATURDAY' or @weekday = 'SUNDAY'">
+            <xsl:attribute name="class">weekend</xsl:attribute>
+          </xsl:if>
           <div class="daytitle"><xsl:value-of select="@number"/></div>
           <p><xsl:value-of select="@date"/></p>
         </td>
@@ -175,4 +201,4 @@
     </tr>
   </xsl:template>
 
-</xsl:stylesheet>
\ No newline at end of file
+</xsl:stylesheet>

Propchange: cocoon/blocks/core-samples-additional/trunk/samples/stylesheets/calendar2html.xslt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/core-samples-additional/trunk/samples/stylesheets/calendar2html.xslt
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/src/java/org/apache/cocoon/generation/CalendarGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/src/java/org/apache/cocoon/generation/CalendarGenerator.java?rev=314929&r1=314928&r2=314929&view=diff
==============================================================================
--- cocoon/trunk/src/java/org/apache/cocoon/generation/CalendarGenerator.java (original)
+++ cocoon/trunk/src/java/org/apache/cocoon/generation/CalendarGenerator.java Wed Oct 12 07:28:01
2005
@@ -54,10 +54,10 @@
  *     year="2004" month="January" prevMonth="12" prevYear="2003"
  *     nextMonth="02" nextYear="2004"&gt;
  *   &lt;calendar:week number="1"&gt;
- *     &lt;calendar:day number="1" date="January 1, 2004"/&gt;
- *     &lt;calendar:day number="2" date="January 2, 2004"/&gt;
- *     &lt;calendar:day number="3" date="January 3, 2004"/&gt;
- *     &lt;calendar:day number="4" date="January 4, 2004"/&gt;
+ *     &lt;calendar:day number="1" weekday="THURSDAY" date="January 1, 2004"/&gt;
+ *     &lt;calendar:day number="2" weekday="FRIDAY" date="January 2, 2004"/&gt;
+ *     &lt;calendar:day number="3" weekday="SATURDAY" date="January 3, 2004"/&gt;
+ *     &lt;calendar:day number="4" weekday="SUNDAY" date="January 4, 2004"/&gt;
  *   &lt;/calendar:week&gt;
  *   ...
  * &lt;/calendar:calendar&gt;
@@ -105,6 +105,7 @@
     protected static final String YEAR_ATTR_NAME       = "year";
     protected static final String DATE_ATTR_NAME       = "date";
     protected static final String NUMBER_ATTR_NAME     = "number";
+    protected static final String WEEKDAY_ATTR_NAME    = "weekday";
     protected static final String PREV_MONTH_ATTR_NAME = "prevMonth";
     protected static final String PREV_YEAR_ATTR_NAME  = "prevYear";
     protected static final String NEXT_MONTH_ATTR_NAME = "nextMonth";
@@ -139,7 +140,17 @@
     
     /** Do we need to pad out the first and last weeks? */
     protected boolean padWeeks;
-    
+
+    /* Add the day of the week 
+     * 
+     * since SUNDAY=1, we start with a dummy
+     * entry. 
+     */
+    protected String weekdays[] = { "",
+        "SUNDAY", "MONDAY", "TUESDAY", "WEDNESDAY", "THURSDAY", 
+        "FRIDAY", "SATURDAY"
+    };
+	
     /**
      * Set the request parameters. Must be called before the generate method.
      *
@@ -240,6 +251,8 @@
                     attributes.clear();
                     attributes.addAttribute("", NUMBER_ATTR_NAME, NUMBER_ATTR_NAME, "CDATA",
                             String.valueOf(previous.get(Calendar.DAY_OF_MONTH)));
+                    attributes.addAttribute("", WEEKDAY_ATTR_NAME, WEEKDAY_ATTR_NAME, "CDATA",
+                            weekdays[previous.get(Calendar.DAY_OF_WEEK)]);
                     attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA",
                             dateFormatter.format(previous.getTime()));
                     this.contentHandler.startElement(URI, DAY_NODE_NAME,
@@ -262,6 +275,8 @@
             attributes.clear();
             attributes.addAttribute("", NUMBER_ATTR_NAME, NUMBER_ATTR_NAME, "CDATA",
                     String.valueOf(start.get(Calendar.DAY_OF_MONTH)));
+            attributes.addAttribute("", WEEKDAY_ATTR_NAME, WEEKDAY_ATTR_NAME, "CDATA",
+                    weekdays[start.get(Calendar.DAY_OF_WEEK)]);
             attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA",
                     dateFormatter.format(start.getTime()));
             this.contentHandler.startElement(URI, DAY_NODE_NAME,
@@ -282,6 +297,8 @@
                 attributes.clear();
                 attributes.addAttribute("", NUMBER_ATTR_NAME, NUMBER_ATTR_NAME, "CDATA",
                         String.valueOf(end.get(Calendar.DAY_OF_MONTH)));
+                attributes.addAttribute("", WEEKDAY_ATTR_NAME, WEEKDAY_ATTR_NAME, "CDATA",
+                        weekdays[end.get(Calendar.DAY_OF_WEEK)]);
                 attributes.addAttribute("", DATE_ATTR_NAME, DATE_ATTR_NAME, "CDATA",
                         dateFormatter.format(end.getTime()));
                 this.contentHandler.startElement(URI, DAY_NODE_NAME,
@@ -290,9 +307,11 @@
                 this.contentHandler.endElement(URI, DAY_NODE_NAME,
                         PREFIX + ':' + DAY_NODE_NAME);
                 end.add(Calendar.DAY_OF_MONTH, 1); 		
+                if (firstDay == end.get(Calendar.DAY_OF_WEEK)) { 
+                    this.contentHandler.endElement(URI, WEEK_NODE_NAME,
+                       PREFIX + ':' + WEEK_NODE_NAME);
+                }
             }
-            this.contentHandler.endElement(URI, WEEK_NODE_NAME,
-                    PREFIX + ':' + WEEK_NODE_NAME);
         }
         this.contentHandler.endElement(URI, CALENDAR_NODE_NAME,
                 PREFIX + ':' + CALENDAR_NODE_NAME);



Mime
View raw message