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
public abstract class AbstractMinimizeManager extends AbstractLogEnabled implements Serviceable
Abstract minimize manager for js and css
-
-
Field Summary
Fields Modifier and Type Field Description protected ProxiedContextPathProvider
_proxiedContextPathProvider
The proxied context path providerprotected SourceResolver
_resolver
Ametys source resolverprotected SourceMapCache
_sourceMapCache
The source map cache component
-
Constructor Summary
Constructors Constructor Description AbstractMinimizeManager()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description 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 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 URLString
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 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 Detail
-
_sourceMapCache
protected SourceMapCache _sourceMapCache
The source map cache component
-
_proxiedContextPathProvider
protected ProxiedContextPathProvider _proxiedContextPathProvider
The proxied context path provider
-
_resolver
protected SourceResolver _resolver
Ametys source resolver
-
-
Constructor Detail
-
AbstractMinimizeManager
public AbstractMinimizeManager()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- 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
protected String applyMediaToContent(String content, String media)
Defaut implementation to apply a media to a content.- Parameters:
content
- The contentmedia
- The media- Returns:
- The content with the media
-
convertSourceMapURIs
protected String convertSourceMapURIs(String content, String uri) throws URISyntaxException
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
protected abstract boolean isSourceMappingURLLine(String line)
Test if the line contains a source mapping URL- Parameters:
line
- The line- Returns:
- True if a source mapping url is found
-
getSourceMappingURL
protected abstract String getSourceMappingURL(String line)
Get the source mapping URL value from the line- Parameters:
line
- The line- Returns:
- The source mapping URL
-
removeSourceMappingURLLine
protected abstract String removeSourceMappingURLLine(String content)
Remove the source mapping url from the content- Parameters:
content
- The content- Returns:
- The content without the mention of the source mapping URL
-
formatSourceMappingURL
protected abstract String formatSourceMappingURL(String sourceMapName)
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
protected abstract String getMinimizedContent(String uri, String nestedParentFilesName)
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
-
-