|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectro.isdc.wro.model.resource.processor.impl.css.AbstractCssUrlRewritingProcessor
ro.isdc.wro.model.resource.processor.impl.css.CssUrlRewritingProcessor
public class CssUrlRewritingProcessor
Note: When used together with CssImportPreProcessor, the CssUrlRewritingProcessor should come first,
otherwise it will produce wrong results.
Rewrites background images url of the provided css content. This implementation takes care of most common cases such as those described bellow:
| Css resource URI | Image URL | Computed Image URL |
|---|---|---|
| ANY | [URL]/1.jpg | [URL]/1.jpg |
| /1.css | /a/1.jpg | /a/1.jpg |
| /1.jpg | /1.jpg | |
| 1.jpg | ../1.jpg | |
| ../1.jpg | ../../1.jpg | |
| /WEB-INF/1.css | /a/1.jpg | /a/1.jpg |
| /1.jpg | /1.jpg | |
| 1.jpg | [WRO-PREFIX]?id=/WEB-INF/1.jpg | |
| ../1.jpg | [WRO-PREFIX]?id=/WEB-INF/../1.jpg | |
| [X]/1.css where [X] is URL or a classpath resource where [WRO-PREFIX] is a servletContext prefix which will map WRO filter to the result url. |
/a/1.jpg | [WRO-PREFIX]?id=[X]/a/1.jpg |
| /1.jpg | [WRO-PREFIX]?id=[X]/1.jpg | |
| 1.jpg | [WRO-PREFIX]?id=[X]/1.jpg | |
| ../1.jpg | [WRO-PREFIX]?id=[X]/../1.jpg |
UriLocator objects, one for resolving url resources & one for classpath
resources. Both need to be injected using IoC when creating the instance of CssUrlRewritingProcessor class.
| Field Summary | |
|---|---|
static String |
ALIAS
|
| Constructor Summary | |
|---|---|
CssUrlRewritingProcessor()
|
|
| Method Summary | |
|---|---|
boolean |
isUriAllowed(String uri)
|
protected void |
onProcessCompleted()
Invoked when the process operation is completed. |
protected void |
onUrlReplaced(String replacedUrl)
Invoked when an url is replaced. |
protected String |
replaceImageUrl(String cssUri,
String imageUrl)
Replace provided url with the new url if needed. |
| Methods inherited from class ro.isdc.wro.model.resource.processor.impl.css.AbstractCssUrlRewritingProcessor |
|---|
cleanImageUrl, getUrlPrefix, isImportAware, isReplaceNeeded, newCssUrlInspector, process, process, replaceDeclaration |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String ALIAS
| Constructor Detail |
|---|
public CssUrlRewritingProcessor()
| Method Detail |
|---|
protected void onProcessCompleted()
onProcessCompleted in class AbstractCssUrlRewritingProcessorprotected void onUrlReplaced(String replacedUrl)
onUrlReplaced in class AbstractCssUrlRewritingProcessorreplacedUrl - the newly computed url created as a result of url rewriting.
protected String replaceImageUrl(String cssUri,
String imageUrl)
replaceImageUrl in class AbstractCssUrlRewritingProcessorcssUri - Uri of the parsed css.imageUrl - to replace.
public final boolean isUriAllowed(String uri)
uri - to check if is allowed.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||