You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/02/07 21:02:24 UTC

svn commit: r1068088 - in /cxf/web: pom.xml src/main/java/org/apache/cxf/cwiki/SiteExporter.java src/main/resources/template.vm template/ template/template.vm

Author: dkulp
Date: Mon Feb  7 20:02:23 2011
New Revision: 1068088

URL: http://svn.apache.org/viewvc?rev=1068088&view=rev
Log:
Externalize the template location

Added:
    cxf/web/template/
    cxf/web/template/template.vm
      - copied unchanged from r1068043, cxf/web/src/main/resources/template.vm
Removed:
    cxf/web/src/main/resources/template.vm
Modified:
    cxf/web/pom.xml
    cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java

Modified: cxf/web/pom.xml
URL: http://svn.apache.org/viewvc/cxf/web/pom.xml?rev=1068088&r1=1068087&r2=1068088&view=diff
==============================================================================
--- cxf/web/pom.xml (original)
+++ cxf/web/pom.xml Mon Feb  7 20:02:23 2011
@@ -81,6 +81,8 @@
                             <argument>${output.dir}</argument>
                             <argument>-space</argument>
                             <argument>${space.key}</argument>
+                            <argument>-template</argument>
+                            <argument>${basedir}/template/template.vm</argument>
                         </arguments>
                     </configuration>
                 </plugin>

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java?rev=1068088&r1=1068087&r2=1068088&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/SiteExporter.java Mon Feb  7 20:02:23 2011
@@ -56,6 +56,7 @@ import org.xml.sax.ContentHandler;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.helpers.XMLUtils;
@@ -65,6 +66,7 @@ import org.apache.cxf.staxutils.StaxUtil
 import org.apache.velocity.Template;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.app.Velocity;
+import org.apache.velocity.runtime.resource.loader.URLResourceLoader;
 import org.ccil.cowan.tagsoup.Parser;
 import org.ccil.cowan.tagsoup.XMLWriter;
 
@@ -97,6 +99,7 @@ public class SiteExporter {
     String password = "autoexport-cxf";
     String spaceKey = "CXF";
     String pageCacheFile = "pagesConfig.obj";
+    String templateName = "template.vm";
     boolean forceAll;
     
     File outputDir = new File(".");
@@ -134,22 +137,37 @@ public class SiteExporter {
                 pageCacheFile = it.next();
             } else if ("-force".equals(s)) {
                 forceAll = true;
+            } else if ("-template".equals(s)) {
+                templateName = it.next();
             }
         }
         
         Properties props = new Properties();
-        String clzName = "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader";
-        props.put("resource.loader", "class");
-        props.put("class.resource.loader.class", clzName);
+        String clzName = URLResourceLoader.class.getName();
+        props.put("resource.loader", "url");
+        props.put("url.resource.loader.class", clzName);
+        props.put("url.resource.loader.root", "");
         Velocity.init(props);
-
-        template = Velocity.getTemplate("template.vm");
+        
+        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());
         outputDir.mkdirs();
     }
     
     public void run() throws Exception {
         loadPagesCache();
-        if (checkRSS()) {
+        
+        // debug stuff, force regen of a page
+        //modifiedPages.add(findPage("FAQ"));
+        //modifiedPages.add(findPage("FAQ"));
+        
+        if (modifiedPages.isEmpty() && checkRSS()) {
             return;
         }
         
@@ -165,13 +183,7 @@ public class SiteExporter {
         if (forceAll) {
             modifiedPages = new LinkedList<Page>(pages.values());
         }
-        /*
-        // debug stuff, force regen of a page
-        modifiedPages.add(findPage("Setting up Eclipse for Running and Debugging Distributed OSGi"));
-        modifiedPages.add(findPage("Apache CXF 2.3.2 Release Notes"));
-        modifiedPages.add(findPage("FAQ"));
-        modifiedPages.add(findPage("Apache CXF 2.1.3 Release Notes"));
-        */
+
         
         renderPages();
         savePages();