prabhuish / webutilities

Automatically exported from code.google.com/p/webutilities
0 stars 0 forks source link

Enhancement: Providing debug mode option for developers #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Webutilities can be enhanced with debug mode (debug=true/false) option which 
will enable the developer to debug javascript and css issues during development.

Original issue reported on code.google.com by chandran...@gmail.com on 8 Nov 2011 at 6:03

GoogleCodeExporter commented 9 years ago
Did you mean when this option is on (may be URL parameter as ....?_dbg_=1 or 
....?dev=1), JS/CSS should be served non-minified (i.e don't pass it through 
YUIMInFilter)?

Original comment by rr.patil...@gmail.com on 8 Nov 2011 at 6:19

GoogleCodeExporter commented 9 years ago

Original comment by rr.patil...@gmail.com on 9 Nov 2011 at 3:20

GoogleCodeExporter commented 9 years ago
Yes. Sending a querystring parameter (like ...?_dbg_=1 or ...?dev=1) shold be 
served as non-minified version.

If possible serve the comma seperated files individually if debug mode is on. 
This may be enabled in a propertis file in which case a JSTL tag can be used to 
read this parameter and write seperately.

Original comment by chandran...@gmail.com on 9 Nov 2011 at 11:45

GoogleCodeExporter commented 9 years ago
Great, and I also need this in debug mode:
- see non-minified version
- but report errors while minimizing

Somthing like this in YUIMinFilter:
...
Writer outWriter = out;
OutputStream nullOutputStream = null;

boolean skipMinifying = rq.getParameter(Constants.PARAM_DEBUG) != null || 
rq.getParameter(Constants.PARAM_SKIP_CACHE) != null;
if(skipMinifying) {
    LOGGER.trace("Debug mode");
    nullOutputStream = new NullOutputStream();
    outWriter = new PrintWriter(nullOutputStream);
} 

//work on generated response
if (lowerUrl.endsWith(EXT_JS) || lowerUrl.endsWith(EXT_JSON) || 
(wrapper.getContentType() != null && (wrapper.getContentType().equals(MIME_JS) 
|| wrapper.getContentType().equals(MIME_JSON)))) {
    JavaScriptCompressor compressor = new JavaScriptCompressor(sr, new WUErrorReporter());
    LOGGER.trace("Compressing JS/JSON type");
    compressor.compress(outWriter, this.lineBreak, !this.noMunge, false, this.preserveSemi, this.disableOptimizations);
} else if (lowerUrl.endsWith(EXT_CSS) || (wrapper.getContentType() != null && 
(wrapper.getContentType().equals(MIME_CSS)))) {
    CssCompressor compressor = new CssCompressor(sr);
    LOGGER.trace("Compressing CSS type");
    compressor.compress(outWriter, this.lineBreak);
} else {
    LOGGER.trace("Not Compressing anything.");
    out.write(wrapper.getContents());
}

if(skipMinifying) {
    out.write(wrapper.getContents());
    nullOutputStream.close();
    outWriter.close();
} 

out.flush();
...

Original comment by i.fer...@gmail.com on 20 Jan 2012 at 10:52

GoogleCodeExporter commented 9 years ago
Moving to 0.0.7

Original comment by rr.patil...@gmail.com on 28 Mar 2013 at 8:44

GoogleCodeExporter commented 9 years ago
ignoreQueryStringPattern and acceptQueryStringPattern can be used to by pass 
the filter(s). 
https://code.google.com/p/webutilities/wiki/CommonFilterParameters

Original comment by rr.patil...@gmail.com on 10 May 2014 at 9:02