Package de.xima.fc.helper
Class CssUrlReplacer
java.lang.Object
de.xima.fc.helper.CssUrlReplacer
Helper for replacing URLs in CSS files.
- Since:
- 8.0.0
- Author:
- XIMA MEDIA GmbH
-
Method Summary
Modifier and TypeMethodDescriptionstatic UnaryOperator<String>
pluginServletTransformer
(String baseUrl, Mandant client, String pluginName) Creates a transformer, compatible with the replace* methods.static String
replaceIgnoreErrors
(String css, UnaryOperator<String> transformer) Processes a CSS file.static String
replaceUriIgnoreErrors
(String css, UnaryOperator<URI> transformer) Processes a CSS file.
-
Method Details
-
pluginServletTransformer
public static UnaryOperator<String> pluginServletTransformer(String baseUrl, Mandant client, String pluginName) Creates a transformer, compatible with the replace* methods. When an URI has the schemeplugin-resource
, the URI is transformed to a URI for a action servlet plugin. The path of the URI is added as a query parameter to the URI. Query parameters are preserved as-is. URIs with other schemes and opaque URIs are not changed.- Parameters:
baseUrl
- Base URL for the formcycle app.client
- Optional client for client scoped servlet action plugins. Whennull
, generates an URL for a system scoped servlet action plugin.pluginName
- Name of the servlet action plugin.- Returns:
- A transformer that transforms
plugin-resource:
URIs to action servlet plugin URIs.
-
replaceIgnoreErrors
Processes a CSS file. Passes all URLs in the CSS file to the given transformer, and replaces the URL with the result of the transformer. If the transformer returnsnull
, no replacement is made. If any error occurs, the original CSS is returned.- Parameters:
css
- CSS to process.transformer
- Transformer for the URLs.- Returns:
- The CSS with the transformed URLs.
-
replaceUriIgnoreErrors
Processes a CSS file. Passes all URLs in the CSS file to the given transformer, and replaces the URL with the result of the transformer. If the transformer returnsnull
, no replacement is made. If any error occurs, the original CSS is returned.- Parameters:
css
- CSS to process.transformer
- Transformer for the URLs.- Returns:
- The CSS with the transformed URLs.
-