Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions grails-demo/web-app/WEB-INF/granule.properties
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,8 @@ closure-compiler.add-path=js/closure-samples/

keepfirstcommentpath=js/dojo/*,js/superslider/slider.js,js/jquery*.js

#If set to true, JS and CSS files are returned after gzip compression
#By default, this is set to true.
#If server is already configured to gzip response for some reasons, then set this flag to false to avoid double gzip compression.
gzip.output=true

7 changes: 6 additions & 1 deletion jsp-demo/web/WEB-INF/granule.properties
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ keepfirstcommentpath=js/dojo/*,js/superslider/slider.js,js/jquery*.js

# contextroot - the constant context root of web-applications.
# It need to be setup right for ant cache precompiling if there are hard-coded URLs in the pages
contextroot=web
contextroot=web

#If set to true, JS and CSS files are returned after gzip compression
#By default, this is set to true.
#If server is already configured to gzip response for some reasons, then set this flag to false to avoid double gzip compression.
gzip.output=true
2 changes: 1 addition & 1 deletion tag-main/src/com/granule/CompressorHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void handle(HttpServletRequest request, HttpServletResponse response, Str

OutputStream os = response.getOutputStream();
try {
if (gzipSupported(request)) {
if (settings.isGzipOutput() && gzipSupported(request)) {
response.setHeader("Content-Encoding", "gzip");
os.write(bundle.getBundleValue());
} else
Expand Down
20 changes: 20 additions & 0 deletions tag-main/src/com/granule/CompressorSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public class CompressorSettings {
private String tagName = DEFAULT_TAG_NAME;
private String contextRoot = null;
private String basePath = null;
private boolean gzipOutput = true;

public static final String NONE_VALUE = "none";
public static final String CLOSURE_COMPILER_VALUE = "closure-compiler";
Expand Down Expand Up @@ -88,6 +89,7 @@ public class CompressorSettings {
public static final String DEFAULT_TAG_NAME = "g:compress";
public static final String CONTEXTROOT_KEY = "contextroot";
public static final String BASEPATH_KEY = "basepath";
public static final String GZIP_OUTPUT_KEY = "gzip.output";

public String getJsCompressMethod() {
return jsCompressMethod;
Expand Down Expand Up @@ -131,6 +133,20 @@ public String getOutputWrapperMarker() {

public String getTagName() {
return tagName;
}

/**
* @return Returns the gzipOutput.
*/
public boolean isGzipOutput() {
return gzipOutput;
}

/**
* @param gzipOutput The gzipOutput to set.
*/
public void setGzipOutput(boolean gzipOutput) {
this.gzipOutput = gzipOutput;
}

public void load(Utf8Properties props) throws IOException {
Expand Down Expand Up @@ -229,6 +245,10 @@ public void load(Utf8Properties props) throws IOException {

if (props.containsKey(CONTEXTROOT_KEY))
contextRoot = props.getProperty(CONTEXTROOT_KEY);

if(props.containsKey(GZIP_OUTPUT_KEY)){
gzipOutput = getBoolean(props.getProperty(GZIP_OUTPUT_KEY), gzipOutput);
}
}

private void readFileListProperty(Utf8Properties props, String settingName, List<String> list) throws IOException {
Expand Down
2 changes: 1 addition & 1 deletion tag-main/src/com/granule/utils/CSSHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public final class CSSHandler {
private static final String stringLiteralRegex = "(\"(?:\\.|[^\\\"])*\"|'(?:\\.|[^\\'])*')";
private static final String urlRegex = String.format(
"(?:url\\(\\s*(%s|[^)]*)\\s*\\))", stringLiteralRegex);
"(?:url\\(\\s*(?!\\s*\\'\\/)(?!\\s*\\\"\\/)(?!\\s*\\/)(%s|[^)]*)\\s*\\))", stringLiteralRegex);
private static final String importRegex = String.format(
"(?:@import\\s+(%s|%s))", urlRegex, stringLiteralRegex);

Expand Down