W3C home > Mailing lists > Public > www-validator-cvs@w3.org > October 2009

2006/unicorn/src/org/w3c/unicorn/util Templates.java,1.2,1.3

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 22 Oct 2009 14:25:22 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1N0ybS-0005Eu-R9@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util
In directory hutz:/tmp/cvs-serv20089/src/org/w3c/unicorn/util

Modified Files:
	Templates.java 
Log Message:
added compactor.jar (http://mindprod.com/products1.html#COMPACTOR) to compress html files before sending to the client

Index: Templates.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/util/Templates.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Templates.java	28 Aug 2009 12:39:56 -0000	1.2
+++ Templates.java	22 Oct 2009 14:25:20 -0000	1.3
@@ -1,5 +1,6 @@
 package org.w3c.unicorn.util;
 
+import java.io.StringWriter;
 import java.io.Writer;
 
 import org.apache.velocity.VelocityContext;
@@ -7,12 +8,15 @@
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
 import org.w3c.unicorn.Framework;
+import com.mindprod.compactor.*;
 
 public class Templates {
 	
 	public static void write(String templateName, VelocityContext context, Writer writer) {
 		try {
-			Framework.getVelocityEngine().mergeTemplate(templateName, "UTF-8", context, writer);
+			StringWriter sw = new StringWriter();
+			Framework.getVelocityEngine().mergeTemplate(templateName, "UTF-8", context, sw);
+			writer.append(Compactor.compactString(sw.toString(), templateName));
 		} catch (ResourceNotFoundException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
Received on Thursday, 22 October 2009 14:25:26 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:39 UTC