You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2015/12/22 00:47:06 UTC

svn commit: r1721283 - in /maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer: DefaultSiteRenderer.java SiteRenderingContext.java

Author: hboutemy
Date: Mon Dec 21 23:47:06 2015
New Revision: 1721283

URL: http://svn.apache.org/viewvc?rev=1721283&view=rev
Log:
[DOXIASITETOOLS-133] added an option to dump Velocity processed Doxia files before parsing

Modified:
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
    maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java?rev=1721283&r1=1721282&r2=1721283&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/DefaultSiteRenderer.java Mon Dec 21 23:47:06 2015
@@ -344,7 +344,30 @@ public class DefaultSiteRenderer
 
                     velocity.getEngine().mergeTemplate( resource, siteContext.getInputEncoding(), vc, sw );
 
-                    reader = new StringReader( sw.toString() );
+                    String doxiaContent = sw.toString();
+
+                    if ( siteContext.getVelocityDocumentOutput() != null )
+                    {
+                        // save Velocity processing result, ie the Doxia content that will be parsed after
+                        if ( !siteContext.getVelocityDocumentOutput().exists() )
+                        {
+                            siteContext.getVelocityDocumentOutput().mkdirs();
+                        }
+
+                        String input = renderingContext.getInputName();
+                        File outputFile = new File( siteContext.getVelocityDocumentOutput(),
+                                                    input.substring( 0, input.length() - 3 ) );
+
+                        File outputParent = outputFile.getParentFile();
+                        if ( !outputParent.exists() )
+                        {
+                            outputParent.mkdirs();
+                        }
+
+                        FileUtils.fileWrite( outputFile, siteContext.getInputEncoding(), doxiaContent );
+                    }
+
+                    reader = new StringReader( doxiaContent );
                 }
                 catch ( Exception e )
                 {

Modified: maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java
URL: http://svn.apache.org/viewvc/maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java?rev=1721283&r1=1721282&r2=1721283&view=diff
==============================================================================
--- maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java (original)
+++ maven/doxia/doxia-sitetools/trunk/doxia-site-renderer/src/main/java/org/apache/maven/doxia/siterenderer/SiteRenderingContext.java Mon Dec 21 23:47:06 2015
@@ -71,6 +71,8 @@ public class SiteRenderingContext
 
     private Date publishDate;
 
+    private File velocityDocumentOutput;
+
     /**
      * If input documents should be validated before parsing.
      * By default no validation is performed.
@@ -397,5 +399,22 @@ public class SiteRenderingContext
     {
         this.publishDate = publishDate;
     }
-    
+
+    /**
+     * Directory where to save documents after Velocity processing (*.vm), but before parsing them with Doxia.
+     * @return not null if the documents are to be saved
+     */
+    public File getVelocityDocumentOutput()
+    {
+        return velocityDocumentOutput;
+    }
+
+    /**
+     * Where to (eventually) save documents after Velocity processing (*.vm), but before parsing them with Doxia?
+     * @param velocityDocumentOutput not null if the documents are to be saved
+     */
+    public void setVelocityDocumentOutput( File velocityDocumentOutput )
+    {
+        this.velocityDocumentOutput = velocityDocumentOutput;
+    }
 }