cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/bsf/samples/generator helloGroovyMarkup.gy hello.gy
Date Thu, 15 Apr 2004 15:36:15 GMT
bdelacretaz    2004/04/15 08:36:15

  Modified:    src/blocks/bsf/conf bsf.xsamples
               src/blocks/bsf/samples samples.xml
               src/blocks/bsf/samples/generator hello.gy
  Added:       src/blocks/bsf/samples/generator helloGroovyMarkup.gy
  Log:
  GroovyMarkup sample added
  
  Revision  Changes    Path
  1.2       +1 -1      cocoon-2.1/src/blocks/bsf/conf/bsf.xsamples
  
  Index: bsf.xsamples
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/bsf/conf/bsf.xsamples,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- bsf.xsamples	4 Apr 2004 04:44:09 -0000	1.1
  +++ bsf.xsamples	15 Apr 2004 15:36:14 -0000	1.2
  @@ -18,7 +18,7 @@
   <xsamples xpath="/samples" unless="group[@name='BSF']">
     <group name="BSF">
       <sample name="BSF Block" href="bsf/">
  -      Examples using script generator and script action.
  +      Examples using scriptable generators and actions.
       </sample>
     </group>
   </xsamples>
  
  
  
  1.3       +6 -3      cocoon-2.1/src/blocks/bsf/samples/samples.xml
  
  Index: samples.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/bsf/samples/samples.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- samples.xml	15 Apr 2004 08:40:17 -0000	1.2
  +++ samples.xml	15 Apr 2004 15:36:15 -0000	1.3
  @@ -24,8 +24,11 @@
     </group>
   
     <group name="Hello World!">
  -    <sample name="Groovy" href="generator/hello.gy">
  -        Simple Groovy generator sample
  +    <sample name="Groovy generator" href="generator/hello.gy">
  +        Simple Groovy generator
  +    </sample>
  +    <sample name="GroovyMarkup generator" href="generator/helloGroovyMarkup.gy">
  +        GroovyMarkup syntax example
       </sample>
     </group>
   </samples>
  
  
  
  1.3       +1 -18     cocoon-2.1/src/blocks/bsf/samples/generator/hello.gy
  
  Index: hello.gy
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/bsf/samples/generator/hello.gy,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- hello.gy	5 Apr 2004 12:25:33 -0000	1.2
  +++ hello.gy	15 Apr 2004 15:36:15 -0000	1.3
  @@ -14,8 +14,6 @@
   * limitations under the License.
   */
   
  -import groovy.xml.MarkupBuilder
  -
   // Step 1 -- Retrieve helper "beans" from the BSF framework
   source = bsf.lookupBean("source")
   output = bsf.lookupBean("output")
  @@ -25,8 +23,8 @@
   
   logger.debug("START " + source)
   
  -//xml = new MarkupBuilder()
   // Use output send the result back to Cocoon
  +// (see helloGroovyMarkup for much better syntax)
   output.append("<page>")
   output.append("<title>")
   output.append("Hello Groovy Baby!")
  @@ -37,18 +35,3 @@
   output.append("</para>")
   output.append("</content>")
   output.append("</page>")
  -
  -
  -/* The following code is prettier, but currently does not work :-(
  -will be fixed the the next release of groovy */
  -/*
  -xml.page() {
  -    title("Hello2")
  -    content() {
  -        para("This is my first Cocoon page in Groovy!")
  -    }
  -}
  -logger.debug("END " + source)
  -
  -output.append xml
  -*/
  
  
  
  1.1                  cocoon-2.1/src/blocks/bsf/samples/generator/helloGroovyMarkup.gy
  
  Index: helloGroovyMarkup.gy
  ===================================================================
  /*
  * 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.
  */
  
  // Generate XML using the (way cool) GroovyMarkup syntax
  import groovy.xml.SAXBuilder
  
  // Create a Groovy Builder which writes directly to
  // the Cocoon pipeline
  contentHandler = bsf.lookupBean("contentHandler")
  xml = new SAXBuilder(contentHandler)
  
  // Builder does not seem to call this
  contentHandler.startDocument()
  
  // generate XML. See GroovyMarkup docs for more info
  // Look ma, no angle brackets ;-)
  xml.page() {
      content() {
          section() {
              title("GroovyMarkup test")
  
              p("Hello, GroovyMarkup world!")
  
              ul() {
                  for(i in 1..5) {
                      li("This is item " + i)
                  }
              }
  
              p("This was generated on ") {
                  b(new Date())
              }
          }
      }
  }
  
  // That's it.
  contentHandler.endDocument()
  
  
  

Mime
View raw message