Author: mgrigorov
Date: Fri May 6 13:33:53 2011
New Revision: 1100209
URL: http://svn.apache.org/viewvc?rev=1100209&view=rev
Log:
WICKET-3675 Usage of JavaScriptCompressor by resources other than
PackageTextTemplates is lost!
WICKET-3674 Provide an interface to allow css resources to be compressed like
javascript resources
Introduce JavaScriptPackageResource and CssPackageResource which use the
configured IJavaScriptCompressor and ICssCompressor.
Added:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/css/
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/css/ICssCompressor.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/ITextResourceCompressor.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/NoOpTextCompressor.java
Removed:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/javascript/NoOpJavaScriptCompressor.java
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/javascript/IJavaScriptCompressor.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/CssTemplate.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/JavaScriptTemplate.java
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java
Added:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/css/ICssCompressor.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/css/ICssCompressor.java?rev=1100209&view=auto
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/css/ICssCompressor.java
(added)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/css/ICssCompressor.java
Fri May 6 13:33:53 2011
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.css;
+
+import org.apache.wicket.resource.ITextResourceCompressor;
+
+/**
+ * Allow for different implementations of a css compressor
+ */
+public interface ICssCompressor extends ITextResourceCompressor
+{
+
+}
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/javascript/IJavaScriptCompressor.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/javascript/IJavaScriptCompressor.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/javascript/IJavaScriptCompressor.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/javascript/IJavaScriptCompressor.java
Fri May 6 13:33:53 2011
@@ -16,18 +16,13 @@
*/
package org.apache.wicket.javascript;
+import org.apache.wicket.resource.ITextResourceCompressor;
+
/**
* Allow for different implementation of a javascript compressor
*
* @author Juergen Donnerstag
*/
-public interface IJavaScriptCompressor
+public interface IJavaScriptCompressor extends ITextResourceCompressor
{
- /**
- * Remove comments and whitespaces from the javascript
- *
- * @param original
- * @return compressed JavaScript
- */
- public String compress(String original);
}
Added:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java?rev=1100209&view=auto
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java
(added)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssPackageResource.java
Fri May 6 13:33:53 2011
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.resource;
+
+import java.util.Locale;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.css.ICssCompressor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Package resource for css files. It strips comments and whitespace from css.
+ */
+public class CssPackageResource extends PackageResource
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log =
LoggerFactory.getLogger(CssPackageResource.class);
+
+ /**
+ * Construct.
+ *
+ * @param scope
+ * @param name
+ * @param locale
+ * @param style
+ * @param variation
+ */
+ public CssPackageResource(Class<?> scope, String name, Locale locale,
String style,
+ String variation)
+ {
+ super(scope, name, locale, style, variation);
+ }
+
+ @Override
+ protected byte[] processResponse(byte[] bytes)
+ {
+ final byte[] processedResponse = super.processResponse(bytes);
+
+ ICssCompressor compressor =
Application.get().getResourceSettings().getCssCompressor();
+
+ if (compressor != null)
+ {
+ try
+ {
+ String nonCompressed = new
String(processedResponse, "UTF-8");
+ return
compressor.compress(nonCompressed).getBytes();
+ }
+ catch (Exception e)
+ {
+ log.error("Error while filtering content", e);
+ return processedResponse;
+ }
+ }
+ else
+ {
+ // don't strip the comments
+ return processedResponse;
+ }
+ }
+
+}
Added:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java?rev=1100209&view=auto
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java
(added)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/CssResourceReference.java
Fri May 6 13:33:53 2011
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.resource;
+
+import java.util.Locale;
+
+import org.apache.wicket.settings.IResourceSettings;
+
+/**
+ * Static resource reference for css resources. The resources are filtered
(stripped comments and
+ * whitespace) if there is registered compressor.
+ *
+ * @see IResourceSettings#getCssCompressor()
+ */
+public class CssResourceReference extends PackageResourceReference
+{
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * Construct.
+ *
+ * @param scope
+ * mandatory parameter
+ * @param name
+ * mandatory parameter
+ * @param locale
+ * resource locale
+ * @param style
+ * resource style
+ * @param variation
+ * resource variation
+ */
+ public CssResourceReference(Class<?> scope, String name, Locale locale,
String style,
+ String variation)
+ {
+ super(scope, name, locale, style, variation);
+ }
+
+ /**
+ * Construct.
+ *
+ * @param scope
+ * mandatory parameter
+ * @param name
+ * mandatory parameter
+ */
+ public CssResourceReference(Class<?> scope, String name)
+ {
+ super(scope, name);
+ }
+
+ @Override
+ public IResource getResource()
+ {
+ return new CssPackageResource(getScope(), getName(),
getLocale(), getStyle(),
+ getVariation());
+ }
+
+}
Added:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java?rev=1100209&view=auto
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java
(added)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptPackageResource.java
Fri May 6 13:33:53 2011
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.request.resource;
+
+import java.util.Locale;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.resource.ITextResourceCompressor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Package resource for javascript files. It strips comments and whitespace
from javascript.
+ */
+public class JavaScriptPackageResource extends PackageResource
+{
+ private static final long serialVersionUID = 1L;
+
+ private static final Logger log =
LoggerFactory.getLogger(JavaScriptPackageResource.class);
+
+ /**
+ * Construct.
+ *
+ * @param scope
+ * @param name
+ * @param locale
+ * @param style
+ * @param variation
+ */
+ public JavaScriptPackageResource(Class<?> scope, String name, Locale
locale, String style,
+ String variation)
+ {
+ super(scope, name, locale, style, variation);
+ }
+
+ @Override
+ protected byte[] processResponse(byte[] bytes)
+ {
+ final byte[] processedResponse = super.processResponse(bytes);
+
+ ITextResourceCompressor compressor = Application.get()
+ .getResourceSettings()
+ .getJavaScriptCompressor();
+
+ if (compressor != null)
+ {
+ try
+ {
+ String nonCompressed = new
String(processedResponse, "UTF-8");
+ return
compressor.compress(nonCompressed).getBytes();
+ }
+ catch (Exception e)
+ {
+ log.error("Error while filtering content", e);
+ return processedResponse;
+ }
+ }
+ else
+ {
+ // don't strip the comments
+ return processedResponse;
+ }
+ }
+
+
+}
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/JavaScriptResourceReference.java
Fri May 6 13:33:53 2011
@@ -18,9 +18,13 @@ package org.apache.wicket.request.resour
import java.util.Locale;
+import org.apache.wicket.settings.IResourceSettings;
+
/**
- * TODO NG
+ * Static resource reference for javascript resources. The resources are
filtered (stripped comments
+ * and whitespace) if there is a registered compressor.
*
+ * @see IResourceSettings#getJavaScriptCompressor()
* @author Matej
*/
public class JavaScriptResourceReference extends PackageResourceReference
@@ -59,4 +63,11 @@ public class JavaScriptResourceReference
{
super(scope, name);
}
+
+ @Override
+ public IResource getResource()
+ {
+ return new JavaScriptPackageResource(getScope(), getName(),
getLocale(), getStyle(),
+ getVariation());
+ }
}
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/request/resource/PackageResource.java
Fri May 6 13:33:53 2011
@@ -234,6 +234,7 @@ public class PackageResource extends Abs
@Override
public void writeData(Attributes
attributes)
{
+ byte[] processed =
processResponse(bytes);
attributes.getResponse().write(bytes);
}
});
@@ -260,6 +261,18 @@ public class PackageResource extends Abs
}
/**
+ * Gives a chance to modify the resource going to be written in the
response
+ *
+ * @param original
+ * the original response
+ * @return the processed response
+ */
+ protected byte[] processResponse(byte[] original)
+ {
+ return original;
+ }
+
+ /**
* send resource specific error message and write log entry
*
* @param resourceResponse
Added:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/ITextResourceCompressor.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/ITextResourceCompressor.java?rev=1100209&view=auto
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/ITextResourceCompressor.java
(added)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/ITextResourceCompressor.java
Fri May 6 13:33:53 2011
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource;
+
+/**
+ * Allow for different implementations of a text compressor
+ */
+public interface ITextResourceCompressor
+{
+ /**
+ * Remove comments and white spaces from the text resource
+ *
+ * @param original
+ * @return compressed text resource
+ */
+ public String compress(String original);
+}
Added:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/NoOpTextCompressor.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/NoOpTextCompressor.java?rev=1100209&view=auto
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/NoOpTextCompressor.java
(added)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/resource/NoOpTextCompressor.java
Fri May 6 13:33:53 2011
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.resource;
+
+import org.apache.wicket.css.ICssCompressor;
+import org.apache.wicket.javascript.IJavaScriptCompressor;
+
+
+/**
+ * A no-op text compressor
+ *
+ * @author Juergen Donnerstag
+ */
+public class NoOpTextCompressor implements IJavaScriptCompressor,
ICssCompressor
+{
+ public String compress(String original)
+ {
+ return original;
+ }
+}
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/IResourceSettings.java
Fri May 6 13:33:53 2011
@@ -16,8 +16,11 @@
*/
package org.apache.wicket.settings;
+import java.util.List;
+
import org.apache.wicket.IResourceFactory;
import org.apache.wicket.Localizer;
+import org.apache.wicket.css.ICssCompressor;
import org.apache.wicket.javascript.IJavaScriptCompressor;
import org.apache.wicket.markup.html.IPackageResourceGuard;
import org.apache.wicket.markup.html.PackageResourceGuard;
@@ -31,8 +34,6 @@ import org.apache.wicket.util.resource.l
import org.apache.wicket.util.time.Duration;
import org.apache.wicket.util.watch.IModificationWatcher;
-import java.util.List;
-
/**
* Interface for resource related settings
@@ -315,8 +316,8 @@ public interface IResourceSettings
/**
* Placeholder string for '..' within resource urls (which will be
crippled by the browser and
- * not work anymore). Note that by default the placeholder string is
<code>null</code> and thus will not
- * allow to access parent folders. That is by purpose and for security
reasons (see
+ * not work anymore). Note that by default the placeholder string is
<code>null</code> and thus
+ * will not allow to access parent folders. That is by purpose and for
security reasons (see
* Wicket-1992). In case you really need it, a good value for
placeholder would e.g. be "$up$".
* Resources additionally are protected by a
* {@link org.apache.wicket.markup.html.IPackageResourceGuard
IPackageResourceGuard}
@@ -346,4 +347,23 @@ public interface IResourceSettings
* @see IResourceCachingStrategy
*/
void setCachingStrategy(IResourceCachingStrategy strategy);
+
+ /**
+ * Set the Css compressor implemententation use e.g. by {@link
CssPackageResource} . A typical
+ * implementation will remove comments and whitespace. But a no-op
implementation is available
+ * as well.
+ *
+ * @param compressor
+ * The implementation to be used
+ * @return The old value
+ */
+ ICssCompressor setCssCompressor(ICssCompressor compressor);
+
+ /**
+ * Get the Css compressor to remove comments and whitespace characters
from css resources
+ *
+ * @return whether the comments and whitespace characters will be
stripped from resources served
+ * through {@link CssPackageResource}. Null is a valid value.
+ */
+ ICssCompressor getCssCompressor();
}
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/settings/def/ResourceSettings.java
Fri May 6 13:33:53 2011
@@ -22,6 +22,7 @@ import java.util.Map;
import org.apache.wicket.Application;
import org.apache.wicket.IResourceFactory;
import org.apache.wicket.Localizer;
+import org.apache.wicket.css.ICssCompressor;
import org.apache.wicket.javascript.IJavaScriptCompressor;
import org.apache.wicket.markup.html.IPackageResourceGuard;
import org.apache.wicket.markup.html.PackageResourceGuard;
@@ -103,6 +104,9 @@ public class ResourceSettings implements
/** The JavaScript compressor */
private IJavaScriptCompressor javascriptCompressor;
+ /** The Css compressor */
+ private ICssCompressor cssCompressor;
+
/** escape string for '..' within resource keys */
private String parentFolderPlaceholder = null;
@@ -378,17 +382,11 @@ public class ResourceSettings implements
defaultCacheDuration = duration;
}
- /**
- * @see
org.apache.wicket.settings.IResourceSettings#getJavaScriptCompressor()
- */
public IJavaScriptCompressor getJavaScriptCompressor()
{
return javascriptCompressor;
}
- /**
- * @see
org.apache.wicket.settings.IResourceSettings#setJavaScriptCompressor(org.apache.wicket.javascript.IJavaScriptCompressor)
- */
public IJavaScriptCompressor
setJavaScriptCompressor(IJavaScriptCompressor compressor)
{
IJavaScriptCompressor old = javascriptCompressor;
@@ -396,6 +394,19 @@ public class ResourceSettings implements
return old;
}
+ public ICssCompressor getCssCompressor()
+ {
+ return cssCompressor;
+ }
+
+ public ICssCompressor setCssCompressor(ICssCompressor compressor)
+ {
+ ICssCompressor old = cssCompressor;
+ cssCompressor = compressor;
+ return old;
+ }
+
+
/**
* @see
org.apache.wicket.settings.IResourceSettings#getParentFolderPlaceholder()
*/
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/CssTemplate.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/CssTemplate.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/CssTemplate.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/CssTemplate.java
Fri May 6 13:33:53 2011
@@ -18,6 +18,8 @@ package org.apache.wicket.util.template;
import java.util.Map;
+import org.apache.wicket.Application;
+import org.apache.wicket.resource.ITextResourceCompressor;
import org.apache.wicket.util.string.CssUtils;
@@ -73,4 +75,24 @@ public final class CssTemplate extends T
{
return this;
}
+
+ @Override
+ public String getString()
+ {
+ String nonCompressed = super.getString();
+
+ ITextResourceCompressor compressor = Application.get()
+ .getResourceSettings()
+ .getCssCompressor();
+
+ if (compressor != null)
+ {
+ return compressor.compress(nonCompressed);
+ }
+ else
+ {
+ // don't strip the comments
+ return nonCompressed;
+ }
+ }
}
\ No newline at end of file
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/JavaScriptTemplate.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/JavaScriptTemplate.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/JavaScriptTemplate.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/JavaScriptTemplate.java
Fri May 6 13:33:53 2011
@@ -18,6 +18,8 @@ package org.apache.wicket.util.template;
import java.util.Map;
+import org.apache.wicket.Application;
+import org.apache.wicket.resource.ITextResourceCompressor;
import org.apache.wicket.util.string.JavaScriptUtils;
@@ -73,4 +75,24 @@ public final class JavaScriptTemplate ex
{
return this;
}
+
+ @Override
+ public String getString()
+ {
+ String nonCompressed = super.getString();
+
+ ITextResourceCompressor compressor = Application.get()
+ .getResourceSettings()
+ .getJavaScriptCompressor();
+
+ if (compressor != null)
+ {
+ return compressor.compress(nonCompressed);
+ }
+ else
+ {
+ // don't strip the comments
+ return nonCompressed;
+ }
+ }
}
\ No newline at end of file
Modified:
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java?rev=1100209&r1=1100208&r2=1100209&view=diff
==============================================================================
---
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java
(original)
+++
wicket/trunk/wicket-core/src/main/java/org/apache/wicket/util/template/PackageTextTemplate.java
Fri May 6 13:33:53 2011
@@ -20,7 +20,6 @@ import java.io.IOException;
import java.util.Map;
import org.apache.wicket.Application;
-import org.apache.wicket.javascript.IJavaScriptCompressor;
import org.apache.wicket.util.io.Streams;
import org.apache.wicket.util.lang.Packages;
import org.apache.wicket.util.resource.IResourceStream;
@@ -164,19 +163,7 @@ public class PackageTextTemplate extends
@Override
public String getString()
{
- IJavaScriptCompressor compressor = Application.get()
- .getResourceSettings()
- .getJavaScriptCompressor();
-
- if (compressor != null)
- {
- return compressor.compress(buffer.toString());
- }
- else
- {
- // don't strip the comments
- return buffer.toString();
- }
+ return buffer.toString();
}
/**