geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r515505 - in /geronimo/sandbox/hokeypokey/trunk: ./ src/main/assembly/ src/main/groovy/hokeypokey/ src/main/groovy/hokeypokey/commands/ src/main/groovy/hokeypokey/exporter/ src/main/groovy/hokeypokey/util/
Date Wed, 07 Mar 2007 09:28:13 GMT
Author: jdillon
Date: Wed Mar  7 01:28:06 2007
New Revision: 515505

URL: http://svn.apache.org/viewvc?view=rev&rev=515505
Log:
Semi-functional site export

Added:
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
  (with props)
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy
  (with props)
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
  (with props)
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy
  (with props)
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
  (with props)
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy  
(with props)
Modified:
    geronimo/sandbox/hokeypokey/trunk/pom.xml
    geronimo/sandbox/hokeypokey/trunk/src/main/assembly/bin.xml
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/getpage.groovy
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/removepage.groovy

Modified: geronimo/sandbox/hokeypokey/trunk/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/pom.xml?view=diff&rev=515505&r1=515504&r2=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/pom.xml (original)
+++ geronimo/sandbox/hokeypokey/trunk/pom.xml Wed Mar  7 01:28:06 2007
@@ -47,6 +47,20 @@
         <url>http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk</url>
     </scm>
     
+    <dependencies>
+        <dependency>
+            <groupId>velocity</groupId>
+            <artifactId>velocity-dep</artifactId>
+            <version>1.4</version>
+        </dependency>
+        
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.3</version>
+        </dependency>
+    </dependencies>
+    
     <build>
         <defaultGoal>install</defaultGoal>
         

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/assembly/bin.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/assembly/bin.xml?view=diff&rev=515505&r1=515504&r2=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/assembly/bin.xml (original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/assembly/bin.xml Wed Mar  7 01:28:06 2007
@@ -82,4 +82,10 @@
             </excludes>
         </fileSet>
     </fileSets>
+    
+    <dependencySets>
+        <dependencySet>
+            <outputDirectory>lib</outputDirectory>
+        </dependencySet>
+    </dependencySets>
 </assembly>

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy?view=diff&rev=515505&r1=515504&r2=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy (original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/HokeyPokey.groovy Wed Mar
 7 01:28:06 2007
@@ -23,7 +23,7 @@
 
 package hokeypokey
 
-import groovy.net.xmlrpc.XMLRPCServerProxy
+import hokeypokey.util.CliBuilder
 
 /**
  * Do the Hokey Pokey!
@@ -31,13 +31,15 @@
 class HokeyPokey
 {
     private URL url = new URL('http://cwiki.apache.org/confluence/rpc/xmlrpc')
+    
     private String username
+    
     private String password
     
     void main(List args) {
         assert args != null // can be empty
         
-        def cli = new CliBuilder(usage : 'hokeypokey [option]* <command> [command-option]*')
+        def cli = new hokeypokey.util.CliBuilder(usage : 'hokeypokey [option]* <command>
[command-option]*')
         
         cli.h(longOpt: 'help', 'Print out this message.')
         cli.U(longOpt: 'url', args: 1, argName: 'url', 'The confluence URL')
@@ -45,10 +47,7 @@
         cli.p(longOpt: 'password', args: 1, argName: 'pass', 'Password to authenticate with')
         
         def options = cli.parse(args)
-        if (options == null) {
-            println ('Error in processing command line options.')
-            return
-        }
+        assert options != null
         
         if (options.h) { cli.usage(); return }
         if (options.U) { url = new URL(options.U) }
@@ -62,13 +61,18 @@
         
         def command = arguments[0]
         
-        run(command, arguments[1..-1])
+        if (arguments.size() > 1) {
+            run(command, arguments[1..-1])
+        }
+        else {
+            run(command, [])
+        }
     }
     
     def run(command, args) {
         // println "Running command: $command w/args: ${args.join(', ')}"
         
-        def type = getClass().classLoader.loadClass("hokeypokey.commands.${command}")
+        def type = getClass().classLoader.loadClass("hokeypokey.commands.$command")
         def obj = type.newInstance()
         obj.client = new Client(url, username, password)
         obj.run(args)

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy?view=diff&rev=515505&r1=515504&r2=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy (original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/addpage.groovy Wed
Mar  7 01:28:06 2007
@@ -23,7 +23,7 @@
 
 package hokeypokey.commands
 
-import groovy.net.xmlrpc.XMLRPCServerProxy
+import hokeypokey.util.CliBuilder
 
 /**
  * Do the Hokey Pokey!
@@ -31,24 +31,22 @@
 class addpage extends HokeyPokeyCommand
 {
     private String space
+    
     private String title
+    
     private String parent
     
     def run(args) {
-        // println "Running ${args.join(', ')}"
-        
         def cli = new CliBuilder(usage : 'hokeypokey addpage [option]* <file>')
         
         cli.h(longOpt: 'help', 'Print out this message.')
-        cli.s(longOpt: 'space', args: 1, argName: 'name', 'Space name (required)')
-        cli.t(longOpt: 'title', args: 1, argName: 'name', 'Page title (required)')
+        cli.s(longOpt: 'space', args: 1, argName: 'name', required: true, 'Space name')
+        cli.t(longOpt: 'title', args: 1, argName: 'name', required: true, 'Page title')
         cli.p(longOpt: 'parent', args: 1, argName: 'name', 'Page parent name')
         
         def options = cli.parse(args)
-        if (options == null) {
-            println ('Error in processing command line options.')
-            return
-        }
+        assert options != null
+        
         if (options.h) { cli.usage(); return }
         if (options.s) { space = options.s }
         if (options.t) { title = options.t }
@@ -56,10 +54,6 @@
         
         def arguments = options.arguments()
         if (arguments.size() != 1) {
-            cli.usage(); return
-        }
-        
-        if (!space && !title) {
             cli.usage(); return
         }
         

Added: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy?view=auto&rev=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
(added)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
Wed Mar  7 01:28:06 2007
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//
+// $Id$
+//
+
+package hokeypokey.commands
+
+import hokeypokey.util.CliBuilder
+import hokeypokey.exporter.SpaceExporter
+import hokeypokey.exporter.TemplateEngine
+
+/**
+ * Do the Hokey Pokey!
+ */
+class exportspace extends HokeyPokeyCommand
+{
+    private String space
+    
+    private List searchPath = [ '.' ]
+    
+    private List libraries
+    
+    // private String templateName
+    
+    // private File outputDirectory
+    
+    def run(args) {
+        def cli = new CliBuilder(usage : 'hokeypokey exportspace [option]*')
+        
+        cli.h(longOpt: 'help', 'Print out this message.')
+        cli.s(longOpt: 'space', args: 1, argName: 'name', required: true, 'Space name')
+        cli.p(longOpt: 'path', args: 1, argName: 'path', 'Template search path (CSV)')
+        cli.l(longOpt: 'library', args: 1, argName: 'lib', 'Macro libraries (CSV)')
+        // cli.t(longOpt: 'template', args: 1, argName: 'name', 'Template name')
+        
+        def options = cli.parse(args)
+        assert options != null
+        
+        if (options.h) { cli.usage(); return }
+        if (options.s) { space = options.s }
+        if (options.p) { searchPath = options.p.tokenize(',') }
+        if (options.l) { libraries = options.l.tokenize(',') }
+        // if (options.t) { templateName = options.t }
+        
+        def arguments = options.arguments()
+        println arguments
+        
+        if (arguments.size() != 0) {
+            cli.usage(); return
+        }
+        
+        client.login()
+        
+        try {
+            def engine = new TemplateEngine()
+            engine.searchPath = searchPath
+            engine.libraries = libraries
+            
+            def exporter = new SpaceExporter(client, engine)
+            
+            println "Exporting space: $space"
+            
+            exporter.export(space)
+        }
+        finally {
+            client.logout()
+        }
+    }
+}
+

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/getpage.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/getpage.groovy?view=diff&rev=515505&r1=515504&r2=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/getpage.groovy (original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/getpage.groovy Wed
Mar  7 01:28:06 2007
@@ -23,7 +23,7 @@
 
 package hokeypokey.commands
 
-import groovy.net.xmlrpc.XMLRPCServerProxy
+import hokeypokey.util.CliBuilder
 
 /**
  * Do the Hokey Pokey!
@@ -31,22 +31,22 @@
 class getpage extends HokeyPokeyCommand
 {
     private String space
+    
     private String title
+    
     private File file
     
     def run(args) {
         def cli = new CliBuilder(usage : 'hokeypokey getpage [option]*')
         
         cli.h(longOpt: 'help', 'Print out this message.')
-        cli.s(longOpt: 'space', args: 1, argName: 'name', 'Space name (required)')
-        cli.t(longOpt: 'title', args: 1, argName: 'name', 'Page title (required)')
+        cli.s(longOpt: 'space', args: 1, argName: 'name', required: true, 'Space name')
+        cli.t(longOpt: 'title', args: 1, argName: 'name', required: true, 'Page title')
         cli.f(longOpt: 'file', args: 1, argName: 'file', 'Save page contents to file')
         
         def options = cli.parse(args)
-        if (options == null) {
-            println ('Error in processing command line options.')
-            return
-        }
+        assert options != null
+        
         if (options.h) { cli.usage(); return }
         if (options.s) { space = options.s }
         if (options.t) { title = options.t }
@@ -54,10 +54,6 @@
         
         def arguments = options.arguments()
         if (arguments.size() != 0) {
-            cli.usage(); return
-        }
-        
-        if (!space && !title) {
             cli.usage(); return
         }
         

Modified: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/removepage.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/removepage.groovy?view=diff&rev=515505&r1=515504&r2=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/removepage.groovy
(original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/removepage.groovy
Wed Mar  7 01:28:06 2007
@@ -23,7 +23,7 @@
 
 package hokeypokey.commands
 
-import groovy.net.xmlrpc.XMLRPCServerProxy
+import hokeypokey.util.CliBuilder
 
 /**
  * Do the Hokey Pokey!
@@ -31,30 +31,25 @@
 class removepage extends HokeyPokeyCommand
 {
     private String space
+    
     private String title
     
     def run(args) {
         def cli = new CliBuilder(usage : 'hokeypokey removepage [option]*')
         
         cli.h(longOpt: 'help', 'Print out this message.')
-        cli.s(longOpt: 'space', args: 1, argName: 'name', 'Space name (required)')
-        cli.t(longOpt: 'title', args: 1, argName: 'name', 'Page title (required)')
+        cli.s(longOpt: 'space', args: 1, argName: 'name', required: true, 'Space name')
+        cli.t(longOpt: 'title', args: 1, argName: 'name', required: true, 'Page title')
         
         def options = cli.parse(args)
-        if (options == null) {
-            println ('Error in processing command line options.')
-            return
-        }
+        assert options != null
+        
         if (options.h) { cli.usage(); return }
         if (options.s) { space = options.s }
         if (options.t) { title = options.t }
         
         def arguments = options.arguments()
         if (arguments.size() != 0) {
-            cli.usage(); return
-        }
-        
-        if (!space && !title) {
             cli.usage(); return
         }
         

Added: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy?view=auto&rev=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy
(added)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy
Wed Mar  7 01:28:06 2007
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//
+// $Id$
+//
+
+package hokeypokey.exporter
+
+import hokeypokey.Client
+
+/**
+ * Do the Hokey Pokey!
+ */
+class PageFinder
+{
+    private Client client
+    
+    private List pages
+    
+    def PageFinder(Client client, List pages) {
+        assert client
+        assert pages
+        
+        this.client = client
+        this.pages = pages
+    }
+    
+    def byTitle(String title) {
+        assert title
+        
+        for (page in pages) {
+            if (title == page.title) {
+                return page
+            }
+        }
+        
+        // null?  or exception?
+    }
+}
+

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/PageFinder.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy?view=auto&rev=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
(added)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
Wed Mar  7 01:28:06 2007
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//
+// $Id$
+//
+
+package hokeypokey.exporter
+
+import hokeypokey.Client
+
+/**
+ * Do the Hokey Pokey!
+ */
+class SpaceExporter
+{
+    private Client client
+    
+    private TemplateEngine engine
+    
+    File outputDirectory = new File('output')
+    
+    def SpaceExporter(Client client, TemplateEngine engine) {
+        assert client
+        assert engine
+        
+        this.client = client
+        this.engine = engine
+    }
+    
+    def export(String spaceKey) {
+        assert spaceKey
+        
+        def space = client.getSpace(spaceKey)
+        
+        def template = engine.getTemplate("${space.key}.vm")
+        
+        def pages = client.getPages(space.key)
+        
+        // Export each page with the clean style (no html preamble/style muck)
+        def renderParams = [ style: 'clean' ]
+        
+        outputDirectory.mkdirs()
+        
+        pages.each { page ->
+            println page
+            
+            def body = client.renderContent(page.space, page.id, '', renderParams)
+            
+            template.params.body = body
+            template.params.space = space
+            template.params.page = page
+            
+            //
+            // NOTE: May want to set this for AE compatiblity
+            //
+            //       template.params.page.space = space
+            //
+            
+            // Helper to find pages
+            template.params.pageFinder = new PageFinder(client, pages)
+            
+            //
+            // TODO: Add render helper
+            //
+            
+            def fileName = page.title.toLowerCase().replace(' ', '-') + '.html'
+            def file = new File(outputDirectory, fileName)
+            template.render(file)
+            
+            //
+            // TODO: Hookup filters so we can inline content massaging (w/ happy ending)
+            //
+            
+            // Handle attachements
+            /*
+            def attachements = client.getAttachments(page.id)
+            if (attachements) {
+                println 'Attachements:'
+                attachements.each { attachment ->
+                    println "    ${attachment.title}"
+                }
+            }
+            */
+        }
+        
+        /*
+        def blogEntries = client.getBlogEntries(space)
+        blogEntries.each { news ->
+            println news
+            
+            def content = client.renderContent(news.space, news.id, '', renderParams)
+            println '----8<----'
+            println content
+            println '---->8----'
+            println ''
+        }
+        */
+    }
+}
+

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy?view=auto&rev=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy
(added)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy
Wed Mar  7 01:28:06 2007
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//
+// $Id$
+//
+
+package hokeypokey.exporter
+
+import org.apache.velocity.VelocityContext
+
+/**
+ * Do the Hokey Pokey!
+ */
+class Template
+{
+    private org.apache.velocity.Template template
+    
+    String name
+    
+    Map params = [:]
+    
+    def Template(String name, org.apache.velocity.Template template) {
+        assert name
+        assert template
+        
+        this.name = name
+        this.template = template
+    }
+    
+    void render(Writer writer) {
+        assert writer
+        
+        def context = new VelocityContext()
+        
+        params.each {
+            context.put(it.key, it.value)
+        }
+        
+        template.merge(context, writer)
+    }
+    
+    void render(File file) {
+        assert file
+        assert file.parentFile.exists()
+        
+        def writer = file.newWriter()
+        try {
+            render(writer)
+        }
+        finally {
+            writer.close()
+        }
+    }
+}
+

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/Template.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy?view=auto&rev=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
(added)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
Wed Mar  7 01:28:06 2007
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//
+// $Id$
+//
+
+package hokeypokey.exporter
+
+import org.apache.velocity.app.VelocityEngine
+
+/**
+ * Do the Hokey Pokey!
+ */
+class TemplateEngine
+{
+    private VelocityEngine velocity = new VelocityEngine()
+    
+    private boolean initalized = false
+    
+    List searchPath = [ '.' ]
+    
+    List libraries = null
+    
+    private init() {
+        velocity.setProperty('resource.loader', 'file')
+        velocity.setProperty('file.resource.loader.description', 'Velocity File Resource
Loader')
+        velocity.setProperty('file.resource.loader.class', 'org.apache.velocity.runtime.resource.loader.FileResourceLoader')
+        velocity.setProperty('file.resource.loader.cache', 'false')
+        velocity.setProperty('file.resource.loader.path', searchPath.join(','))
+        
+        println searchPath.join(',')
+        
+        if (libraries) {
+            velocity.setProperty('velocimacro.library', libraries.join(','))
+        }
+        
+        // velocity.setProperty('runtime.log.logsystem.class', 'org.apache.velocity.runtime.log.NullLogSystem')
+        
+        velocity.init()
+        
+        initalized = true
+    }
+    
+    Template getTemplate(name) {
+        assert name
+        
+        if (!initalized) {
+            init()
+        }
+        
+        return new Template(name, velocity.getTemplate(name))
+    }
+}
+

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy
URL: http://svn.apache.org/viewvc/geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy?view=auto&rev=515505
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy (added)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy Wed
Mar  7 01:28:06 2007
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+//
+// $Id$
+//
+
+package hokeypokey.util
+
+import groovy.util.OptionAccessor
+
+/**
+ * Do the Hokey Pokey!
+ */
+class CliBuilder
+    extends groovy.util.CliBuilder
+{
+    OptionAccessor parse(args) {
+        return new OptionAccessor(parser.parse(options, args as String[], true))
+    }
+}
+

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Propchange: geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/util/CliBuilder.groovy
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message