geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ga...@apache.org
Subject svn commit: r1424268 - in /geronimo/site/trunk: template/ wiki-export/conf/ wiki-export/src/main/java/org/apache/cxf/cwiki/
Date Thu, 20 Dec 2012 01:53:40 GMT
Author: gawor
Date: Thu Dec 20 01:53:39 2012
New Revision: 1424268

URL: http://svn.apache.org/viewvc?rev=1424268&view=rev
Log:
handle multiple templates at the same time, warn about missing pages, etc.

Added:
    geronimo/site/trunk/wiki-export/conf/xbean.cfg
    geronimo/site/trunk/wiki-export/conf/yoko.cfg
Modified:
    geronimo/site/trunk/template/xbean_autoexport_template.xml
    geronimo/site/trunk/template/yoko_autoexport_template.xml
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Renderer.java
    geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: geronimo/site/trunk/template/xbean_autoexport_template.xml
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/template/xbean_autoexport_template.xml?rev=1424268&r1=1424267&r2=1424268&view=diff
==============================================================================
--- geronimo/site/trunk/template/xbean_autoexport_template.xml (original)
+++ geronimo/site/trunk/template/xbean_autoexport_template.xml Thu Dec 20 01:53:39 2012
@@ -28,8 +28,7 @@
     ## FIXME: Must be a more efficient way to find a page...
     ##
     
-    #foreach ($child in $page.space.pages)
-        #if ($child.title.equals($title))
+            #set ($child = $pageManager.getPage($page.space.key,$title))
             #set ($content = $renderer.convertWikiToXHtml($child.toPageContext(), $child.content).trim())
             
             ##
@@ -41,8 +40,6 @@
             #set ($content = $content.substring(0, $end))
             
             $content
-        #end
-    #end
 #end
 ##
 #macro (topNav)

Modified: geronimo/site/trunk/template/yoko_autoexport_template.xml
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/template/yoko_autoexport_template.xml?rev=1424268&r1=1424267&r2=1424268&view=diff
==============================================================================
--- geronimo/site/trunk/template/yoko_autoexport_template.xml (original)
+++ geronimo/site/trunk/template/yoko_autoexport_template.xml Thu Dec 20 01:53:39 2012
@@ -25,8 +25,7 @@
     ## FIXME: Must be a more efficient way to find a page...
     ##
     
-    #foreach ($child in $page.space.pages)
-        #if ($child.title.equals($title))
+            #set ($child = $pageManager.getPage($page.space.key,$title))
             #set ($content = $renderer.convertWikiToXHtml($child.toPageContext(), $child.content).trim())
             
             ##
@@ -38,8 +37,6 @@
             #set ($content = $content.substring(0, $end))
             
             $content
-        #end
-    #end
 #end
 ##
 #macro (topNav)

Added: geronimo/site/trunk/wiki-export/conf/xbean.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/xbean.cfg?rev=1424268&view=auto
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/xbean.cfg (added)
+++ geronimo/site/trunk/wiki-export/conf/xbean.cfg Thu Dec 20 01:53:39 2012
@@ -0,0 +1,6 @@
+spaceKey:XB
+pageCacheFile:cache/xbean.pageCache
+templateName:../template/xbean_autoexport_template.xml
+outputDir:/xbean
+globalPages:Navigation,Banner,QuickLinks
+mainDivClass:wiki-content maincontent

Added: geronimo/site/trunk/wiki-export/conf/yoko.cfg
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/conf/yoko.cfg?rev=1424268&view=auto
==============================================================================
--- geronimo/site/trunk/wiki-export/conf/yoko.cfg (added)
+++ geronimo/site/trunk/wiki-export/conf/yoko.cfg Thu Dec 20 01:53:39 2012
@@ -0,0 +1,6 @@
+spaceKey:YOKO
+pageCacheFile:cache/yoko.pageCache
+templateName:../template/yoko_autoexport_template.xml
+outputDir:/yoko
+globalPages:Navigation,Banner,QuickLinks
+mainDivClass:wiki-content maincontent

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java?rev=1424268&r1=1424267&r2=1424268&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/PageManager.java Thu
Dec 20 01:53:39 2012
@@ -37,6 +37,8 @@ public class PageManager {
             if (s == null) {
                 s = exporter.loadPageContent(page, null, null);
             }
+        } else {
+            System.err.println("Page not found: " + title);
         }
         return page;
     }

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Renderer.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Renderer.java?rev=1424268&r1=1424267&r2=1424268&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Renderer.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/Renderer.java Thu Dec
20 01:53:39 2012
@@ -31,19 +31,21 @@ public class Renderer {
     }
     
     public String convertWikiToXHtml(Object context, String content) {
-        int start = 0;
-        if (content.startsWith("<div")) {
-            int pos = content.indexOf(">", 1);
-            if (pos != -1) {
-                start = pos + 1;
+        if (content != null) {
+            int start = 0;
+            if (content.startsWith("<div")) {
+                int pos = content.indexOf(">", 1);
+                if (pos != -1) {
+                    start = pos + 1;
+                }
             }
+            int end = content.length();
+            if (content.endsWith("</div>")) {
+                end -= "</div>".length();
+            }
+            content = content.substring(start, end);
         }
-        int end = content.length();
-        if (content.endsWith("</div>")) {
-            end -= "</div>".length();
-        }
-        content = content.substring(start, end);
-
+        
         return content;
     }
     

Modified: geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1424268&r1=1424267&r2=1424268&view=diff
==============================================================================
--- geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ geronimo/site/trunk/wiki-export/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Thu
Dec 20 01:53:39 2012
@@ -82,6 +82,7 @@ import org.apache.cxf.transports.http.co
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
+import org.apache.velocity.app.VelocityEngine;
 import org.apache.velocity.runtime.resource.loader.URLResourceLoader;
 import org.ccil.cowan.tagsoup.Parser;
 import org.ccil.cowan.tagsoup.XMLWriter;
@@ -164,18 +165,19 @@ public class SiteExporter implements Run
         props.put("resource.loader", "url");
         props.put("url.resource.loader.class", clzName);
         props.put("url.resource.loader.root", "");
-        synchronized (Velocity.class) {
-            Velocity.init(props);
+        
+        VelocityEngine engine = new VelocityEngine();
+        engine.init(props);
             
-            URL url = ClassLoaderUtils.getResource(templateName, this.getClass());
-            if (url == null) {
-                File file = new File(templateName);
-                if (file.exists()) {
-                    url = file.toURI().toURL();
-                }
+        URL url = ClassLoaderUtils.getResource(templateName, this.getClass());
+        if (url == null) {
+            File file = new File(templateName);
+            if (file.exists()) {
+                url = file.toURI().toURL();
             }
-            template = Velocity.getTemplate(url.toURI().toString());
         }
+        template = engine.getTemplate(url.toURI().toString());
+               
         outputDir.mkdirs();
     }
     



Mime
View raw message