geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r515548 - in /geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey: commands/exportspace.groovy exporter/SpaceExporter.groovy exporter/TemplateEngine.groovy
Date Wed, 07 Mar 2007 12:26:49 GMT
Author: jdillon
Date: Wed Mar  7 04:26:48 2007
New Revision: 515548

URL: http://svn.apache.org/viewvc?view=rev&rev=515548
Log:
Hook up page and news page for the same export

Modified:
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
    geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy

Modified: 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=diff&rev=515548&r1=515547&r2=515548
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
(original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/commands/exportspace.groovy
Wed Mar  7 04:26:48 2007
@@ -61,7 +61,6 @@
         // if (options.t) { templateName = options.t }
         
         def arguments = options.arguments()
-        println arguments
         
         if (arguments.size() != 0) {
             cli.usage(); return
@@ -75,8 +74,6 @@
             engine.libraries = libraries
             
             def exporter = new SpaceExporter(client, engine)
-            
-            println "Exporting space: $space"
             
             exporter.export(space)
         }

Modified: 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=diff&rev=515548&r1=515547&r2=515548
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
(original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/SpaceExporter.groovy
Wed Mar  7 04:26:48 2007
@@ -51,12 +51,12 @@
         
         def space = client.getSpace(spaceKey)
         
+        println "Exporting space: ${space.name} (${space.key})"
+        
         def template = engine.getTemplate("${space.key}.vm")
         
         def pages = client.getPages(space.key)
         
-        outputDirectory.mkdirs()
-        
         def renderPage = { page ->
             assert page
             
@@ -75,35 +75,39 @@
             throw new Exception("No such page for title: $title")
         }
         
-        def pageHref = { page ->
+        def pageBaseName = { page ->
             assert page
             
-            //
-            // FIXME: This is probably not correct... but kinda close to what AE does.
-            //
+            def baseName
             
-            return page.title.toLowerCase().replace(' ', '-') + '.html'
-        }
-        
-        def pageAttachDir = { page ->
-            assert page
+            if (page.publishDate) {
+                // This is deprecated, but screw it
+                def date = new Date(page.publishDate)
+                
+                baseName = "${date.year + 1900}/${date.month}/${date.date}/${page.title}"
+            }
+            else {
+                baseName = page.title
+            }
             
             //
             // FIXME: This is probably not correct... but kinda close to what AE does.
             //
             
-            return new File(outputDirectory, page.title.toLowerCase().replace(' ', '-') +
'.attach')
+            return baseName.toLowerCase().replace(' ', '-')
         }
         
-        println "Exporting space: ${space.name} (${space.key})"
+        def pageHref = { page ->
+            return pageBaseName(page) + '.html'
+        }
         
-        pages.each { page ->
-            println "    ${page.title}"
-            
-            //
-            // TODO: Generalize this, the same basic thing (except the filename)
-            //       is used for news posts too
-            //
+        def pageAttachDir = { page ->
+            return pageBaseName(page) + '.attach'
+        }
+        
+        def exportPage = { page ->
+            def baseName = pageBaseName(page)
+            println "    ${baseName}"
             
             def body = renderPage(page)
             
@@ -122,14 +126,16 @@
             // TODO: Hook up massaging filters...
             //
             
-            def file = new File(outputDirectory, pageHref(page))
+            def file = new File(outputDirectory, "${baseName}.html")
+            file.parentFile.mkdirs()
+            
             file.write(writer.buffer.toString())
             
-            // Handle attachments
             def attachments = client.getAttachments(page.id)
             if (attachments) {
-                def dir = pageAttachDir(page)
+                def dir = new File("${baseName}.attach")
                 dir.mkdirs()
+                
                 attachments.each { attachment ->
                     print "        ${attachment.fileName}"
                     
@@ -151,18 +157,16 @@
             }
         }
         
-        /*
-        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 ''
+        pages.each { page ->
+            exportPage(page)
+        }
+        
+        def newsPages = client.getBlogEntries(space.key)
+        if (newsPages) {
+            newsPages.each { page ->
+                exportPage(page)
+            }
         }
-        */
     }
 }
 

Modified: 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=diff&rev=515548&r1=515547&r2=515548
==============================================================================
--- geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
(original)
+++ geronimo/sandbox/hokeypokey/trunk/src/main/groovy/hokeypokey/exporter/TemplateEngine.groovy
Wed Mar  7 04:26:48 2007
@@ -45,8 +45,6 @@
         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(','))
         }



Mime
View raw message