|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.riotfamily.cachius.spring.AbstractCacheableController
org.riotfamily.website.css.CssTemplateController
public class CssTemplateController
Controller that serves dynamic CSS files.
It's sometimes desirable to use constants in CSS files or to perform arithmetic operations. This controller allows you to do so, by using FreeMarker to process the stylesheets.
You can place a css.ini file in the same directory where your
stylesheets are located. All properties defined in that file will be
available within the FreeMarker template.
Additionally the controller allows you to create styles that look different
in various contexts. A good example would be a website that uses multiple
color schemes. Therefore you can add named sections to your your ini file
and request <file>_<section-name>.css instead of
<file>.css. This will cause the controller to expose the
properties of the requested section, possibly overriding any default
values with the same name.
You can access the properties from all sections at any time by using
<section_name>.<property_name> in the FreeMarker template.
If a default value has been overridden by a section value you can still
access the original default, by using global.<property_name>.
| Nested Class Summary | |
|---|---|
protected class |
CssTemplateController.DynamicStylesheet
|
| Field Summary | |
|---|---|
static String |
CONTEXT_PATH_PROPERTY
|
static String |
KEY_PROPERTY
|
| Fields inherited from interface org.riotfamily.cachius.spring.CacheableController |
|---|
CACHE_ETERNALLY |
| Constructor Summary | |
|---|---|
CssTemplateController()
|
|
| Method Summary | |
|---|---|
void |
afterPropertiesSet()
|
long |
getLastModified(HttpServletRequest request)
The default implementation returns System.currentTimeMillis() so that the item is
refreshed as soon as it expires. |
boolean |
gzipResponse(HttpServletRequest request)
Returns whether the response should be gzipped. |
ModelAndView |
handleRequest(HttpServletRequest request,
HttpServletResponse response)
|
protected CssTemplateController.DynamicStylesheet |
lookup(HttpServletRequest request)
|
void |
setAddContextPathToUrls(boolean addContextPathToUrls)
Sets whether the contextPath should be added to absolute URLs specified within the template. |
void |
setCompressor(YUICssCompressor compressor)
|
void |
setFreeMarkerConfig(freemarker.template.Configuration configuration)
|
void |
setIniFileLocation(Resource resource)
|
void |
setServletContext(ServletContext servletContext)
|
void |
setStamper(ResourceStamper stamper)
Sets the ResourceStamper that should be used to add timestamps to URLs specified within the template. |
| Methods inherited from class org.riotfamily.cachius.spring.AbstractCacheableController |
|---|
appendCacheKey, bypassCache, getBeanName, getCacheKey, getCacheKeyInternal, getTimeToLive, setAddUriToCacheKey, setBeanName |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String KEY_PROPERTY
public static final String CONTEXT_PATH_PROPERTY
| Constructor Detail |
|---|
public CssTemplateController()
| Method Detail |
|---|
public void setCompressor(YUICssCompressor compressor)
compressor - the compressor to setpublic void setServletContext(ServletContext servletContext)
setServletContext in interface ServletContextAwarepublic void setFreeMarkerConfig(freemarker.template.Configuration configuration)
public void setStamper(ResourceStamper stamper)
ResourceStamperpublic void setAddContextPathToUrls(boolean addContextPathToUrls)
false.
public void setIniFileLocation(Resource resource)
throws IOException
IOException
public void afterPropertiesSet()
throws Exception
afterPropertiesSet in interface InitializingBeanExceptionpublic boolean gzipResponse(HttpServletRequest request)
Compressibletrue, unless they serve multiple content
types which and not all of them are eligible for compression. They
don't have to check whether the client supports gzip
compression as all compatibility checks are done by Cachius
internally.
gzipResponse in interface Compressiblepublic long getLastModified(HttpServletRequest request)
AbstractCacheableControllerSystem.currentTimeMillis() so that the item is
refreshed as soon as it expires. Subclasses should override this
method to return something reasonable.
getLastModified in interface CacheableControllergetLastModified in interface LastModifiedgetLastModified in class AbstractCacheableController
public ModelAndView handleRequest(HttpServletRequest request,
HttpServletResponse response)
throws Exception
handleRequest in interface ControllerExceptionprotected CssTemplateController.DynamicStylesheet lookup(HttpServletRequest request)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||