You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by an...@apache.org on 2004/04/04 06:48:35 UTC

cvs commit: cocoon-2.1/src/blocks/bsf/conf bsf.xmap

antonio     2004/04/03 20:48:35

  Modified:    src/blocks/bsf/conf bsf.xmap
  Added:       src/blocks/bsf/samples/generator hello.gy
  Log:
  Add Groovy script generator under BSF block
  
  Revision  Changes    Path
  1.1                  cocoon-2.1/src/blocks/bsf/samples/generator/hello.gy
  
  Index: hello.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.
  */
  
  import groovy.xml.MarkupBuilder;
  
  // Step 1 -- Retrieve helper "beans" from the BSF framework
  source = bsf.lookupBean("source")
  output = bsf.lookupBean("output")
  logger = bsf.lookupBean("logger")
  
  // Step 2 -- Start the generator
  
  logger.debug("START " + source)
  
  //xml = new MarkupBuilder()
  // Use output send the result back to Cocoon
  output.append("<page>")
  output.append("<title>")
  output.append("Hello Groovy Baby!")
  output.append("</title>")
  output.append("<content>")
  output.append("<para>")
  output.append("This is my first Cocoon page in Groovy!")
  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.5       +1 -3      cocoon-2.1/src/blocks/bsf/conf/bsf.xmap
  
  Index: bsf.xmap
  ===================================================================
  RCS file: /home/cvs//cocoon-2.1/src/blocks/bsf/conf/bsf.xmap,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- bsf.xmap	4 Apr 2004 04:44:09 -0000	1.4
  +++ bsf.xmap	4 Apr 2004 04:48:35 -0000	1.5
  @@ -18,9 +18,7 @@
   <xmap xpath="/sitemap/components/generators"
         unless="generator[@name='script']">
   
  -    <map:generator name="script"
  -         src="org.apache.cocoon.generation.ScriptGenerator"
  -         logger="sitemap.generation.scriptgenerator">
  +    <map:generator name="script" src="org.apache.cocoon.generation.ScriptGenerator" logger="sitemap.generation.scriptgenerator">
           <!-- Groovy support -->
           <add-languages>
               <language name="groovy" src="org.codehaus.groovy.bsf.GroovyEngine">