- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 22 Oct 2009 14:25:22 +0000
- To: www-validator-cvs@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