Package org.ametys.core.minimize
Class AbstractMinimizeManager
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.core.minimize.AbstractMinimizeManager
- All Implemented Interfaces:
LogEnabled
,Serviceable
- Direct Known Subclasses:
MinimizeCSSManager
,MinimizeJSManager
Abstract minimize manager for js and css
-
Field Summary
Modifier and TypeFieldDescriptionprotected ProxiedContextPathProvider
The proxied context path providerprotected SourceResolver
Ametys source resolverprotected SourceMapCache
The source map cache component -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected abstract void
addSourceMap
(com.google.debugging.sourcemap.SourceMapGeneratorV3 sourceMapGenerator, int lineCount, String fileContent, String fileUri, String sourceMapUri) Aggregate the source map of the single file with the othersprotected String
applyMediaToContent
(String content, String media) Defaut implementation to apply a media to a content.protected String
convertSourceMapURIs
(String content, String uri) Convert the source map "sources" attribute by correcting the path of those valuesprotected abstract String
formatSourceMappingURL
(String sourceMapName) Format a source mapping URL to be added at the end of a minimized fileprotected abstract String
getMinimizedContent
(String uri, String nestedParentFilesName) Get the minimized content at the specified URIprotected abstract String
getSourceMappingURL
(String line) Get the source mapping URL value from the lineprotected abstract boolean
isSourceMappingURLLine
(String line) Test if the line contains a source mapping URLminimizeAndAggregateURIs
(List<HashCache.UriData> uris, String fileName, boolean generateSourceMap) Compile a list of css URI, store the generated source map and returns the minimized concatenated resultprotected abstract String
removeSourceMappingURLLine
(String content) Remove the source mapping url from the contentvoid
service
(ServiceManager smanager) void
validateAndOutputMinimizedFile
(Source source, OutputStream out, String sourceUri) Validate a source, fix it if required, and output the result to the output stream.Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
_sourceMapCache
The source map cache component -
_proxiedContextPathProvider
The proxied context path provider -
_resolver
Ametys source resolver
-
-
Constructor Details
-
AbstractMinimizeManager
public AbstractMinimizeManager()
-
-
Method Details
-
service
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
minimizeAndAggregateURIs
public String minimizeAndAggregateURIs(List<HashCache.UriData> uris, String fileName, boolean generateSourceMap) Compile a list of css URI, store the generated source map and returns the minimized concatenated result- Parameters:
uris
- The URIs to compile, e.g a list of mixed .min.css and .css URIsfileName
- The name of the result without extension, e.g. HASHgenerateSourceMap
- True to generate the source map- Returns:
- The minimized file
-
applyMediaToContent
Defaut implementation to apply a media to a content.- Parameters:
content
- The contentmedia
- The media- Returns:
- The content with the media
-
convertSourceMapURIs
Convert the source map "sources" attribute by correcting the path of those values- Parameters:
content
- The source map contenturi
- The URI (without context path)- Returns:
- The converted source map
- Throws:
URISyntaxException
- If an error occurred
-
validateAndOutputMinimizedFile
public void validateAndOutputMinimizedFile(Source source, OutputStream out, String sourceUri) throws IOException Validate a source, fix it if required, and output the result to the output stream.- Parameters:
source
- The sourceout
- The outputsourceUri
- The source uri- Throws:
IOException
- If an error occurred while reading the source
-
isSourceMappingURLLine
Test if the line contains a source mapping URL- Parameters:
line
- The line- Returns:
- True if a source mapping url is found
-
getSourceMappingURL
Get the source mapping URL value from the line- Parameters:
line
- The line- Returns:
- The source mapping URL
-
removeSourceMappingURLLine
Remove the source mapping url from the content- Parameters:
content
- The content- Returns:
- The content without the mention of the source mapping URL
-
formatSourceMappingURL
Format a source mapping URL to be added at the end of a minimized file- Parameters:
sourceMapName
- The map name- Returns:
- The source mapping URL line
-
getMinimizedContent
Get the minimized content at the specified URI- Parameters:
uri
- The urinestedParentFilesName
- The parents file name, can be an empty string if there are no parents- Returns:
- The minimized content of the specified URI
-
addSourceMap
protected abstract void addSourceMap(com.google.debugging.sourcemap.SourceMapGeneratorV3 sourceMapGenerator, int lineCount, String fileContent, String fileUri, String sourceMapUri) Aggregate the source map of the single file with the others- Parameters:
sourceMapGenerator
- The aggregator helperlineCount
- The current line countfileContent
- The content of the filefileUri
- The uri of the filesourceMapUri
- The sourceMappingURL found at the end of the file content
-