<%@page language="java" import="java.io.*,java.util.zip.*,com.vc.mm.utils.TinyMCE" %><% // warning : do not let any character in the 'out' stream ! /** * Id: tiny_mce_gzip.jsp 535 2008-01-14 15:01:34Z spocke * *modified* by RonanKER 2008-05-27 * * @author Moxiecode * @copyright Copyright � 2006, Moxiecode Systems AB, All rights reserved. * * This file compresses the TinyMCE JavaScript using GZip and * enables the browser to do two requests instead of one for each .js file. * * It's a good idea to use the diskcache option since it reduces the servers workload. * * *modified* : This file has been edited by Ronan Kerdudou from VirageGroup (France) * on may 31th 2006 on V.1.02 : Separation in two files to run on my JSF JBoss server * on june 9th 2006 on V.1.02 : Correcting bugs and debug tracing (log4j) * on may 27th 2008 on V.2.0.1 : migrating original patch from V.1.02 to V.2.0.1 * * note that this script is under LGPL licence. * this script is provided 'AS IS' with no warranties, and confers no rights.. */ String cacheKey = "", cacheFile = "", content = "", enc, suffix, cachePath; String plugins[], languages[], themes[]; boolean diskCache, supportsGzip, isJS, compress, core; int i, x, bytes, expiresOffset; OutputStreamWriter bow; ByteArrayOutputStream bos; GZIPOutputStream gzipStream; FileOutputStream fout; FileInputStream fin; byte buff[]; TinyMCE tinyMCEUtils = new TinyMCE(application); tinyMCEUtils.debug(" tiny_mce_gzip.jsp"); // Get input plugins = tinyMCEUtils.getParam(request, "plugins", "").split(","); languages = tinyMCEUtils.getParam(request, "languages", "").split(","); themes = tinyMCEUtils.getParam(request, "themes", "").split(","); diskCache = tinyMCEUtils.getParam(request, "diskcache", "").equals("true"); isJS = tinyMCEUtils.getParam(request, "js", "").equals("true"); compress = tinyMCEUtils.getParam(request, "compress", "true").equals("true"); core = tinyMCEUtils.getParam(request, "core", "true").equals("true"); suffix = tinyMCEUtils.getParam(request, "suffix", "").equals("_src") ? "_src" : ""; cachePath = tinyMCEUtils.mapPath(request, "."); // Cache path, this is where the .gz files will be stored expiresOffset = 3600 * 24 * 10; // Cache for 10 days in browser cache // Custom extra javascripts to pack String custom[] = {/* "some custom .js file", "some custom .js file" */}; // Headers response.setContentType("text/javascript"); response.addHeader("Vary", "Accept-Encoding"); // Handle proxies response.setDateHeader("Expires", System.currentTimeMillis() + (expiresOffset * 1000)); // Is called directly then auto init with default settings if (!isJS) { out.print(tinyMCEUtils.getFileContents(tinyMCEUtils.mapPath(request, "tiny_mce_gzip.js"))); out.print("tinyMCE_GZ.init({});"); return; } // Setup cache info if (diskCache) { cacheKey = tinyMCEUtils.getParam(request, "plugins", "") + tinyMCEUtils.getParam(request, "languages", "") + tinyMCEUtils.getParam(request, "themes", ""); for (i=0; i