Package com.jalios.jcms.tools
Class CssPacker
- java.lang.Object
-
- com.jalios.jcms.tools.AbstractFilePacker
-
- com.jalios.jcms.tools.CssPacker
-
public class CssPacker extends AbstractFilePacker
-
-
Field Summary
-
Fields inherited from class com.jalios.jcms.tools.AbstractFilePacker
channel, CHANNEL_PACKER_MINIFY_EXCLUSION_REGEX
-
-
Constructor Summary
Constructors Constructor Description CssPacker(java.lang.String packerDirectory)
Creates a new CSS packer.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static java.util.Set<java.lang.String>
getCSSFilesInPack(java.util.Collection<java.lang.String> cssFiles, java.lang.String browserName)
Returns the set of the URLs created with the CSS packer, respecting the constraints of the browser.protected org.apache.log4j.Logger
getLogger()
Returns the logger to be used for log messages.static void
minifyCSS(boolean force)
Create a minified version of all CSS found in JCMS.protected boolean
perFileMinificationEnabled()
Check if minification should be performed on each file as opposed to the whole pack.protected java.lang.String
processFileContent(java.lang.String cssRelativeFilePath, java.io.File cssFile, java.lang.String cssFileContent)
Process CSS files' contentprotected java.lang.String
processPackContent(java.lang.String packContent)
Process CSS pack's content-
Methods inherited from class com.jalios.jcms.tools.AbstractFilePacker
getFilePack, getFilesInPack, getMinifiedFile, isExcludedFromMinification, minifyFile
-
-
-
-
Constructor Detail
-
CssPacker
public CssPacker(java.lang.String packerDirectory) throws java.lang.Exception
Creates a new CSS packer.- Parameters:
packerDirectory
- the relative path of the servlet/jsp that will be outputing the packed css. MUST be specified.- Throws:
java.lang.IllegalArgumentException
- if packerDirectory is nulljava.lang.Exception
- on initialization error
-
-
Method Detail
-
processFileContent
protected java.lang.String processFileContent(java.lang.String cssRelativeFilePath, java.io.File cssFile, java.lang.String cssFileContent)
Process CSS files' content- Specified by:
processFileContent
in classAbstractFilePacker
- Parameters:
cssRelativeFilePath
- the relative path of the file being processedcssFile
- the file being processedcssFileContent
- the fileContent as read by the AbstractFilePacker- Returns:
- the processed file content, must not return null.
-
processPackContent
protected java.lang.String processPackContent(java.lang.String packContent)
Process CSS pack's content- Specified by:
processPackContent
in classAbstractFilePacker
- Parameters:
packContent
- the whole pack content as computed by the AbstractFilePacker- Returns:
- the processed pack content, must not return null.
-
perFileMinificationEnabled
protected boolean perFileMinificationEnabled()
Description copied from class:AbstractFilePacker
Check if minification should be performed on each file as opposed to the whole pack.- Specified by:
perFileMinificationEnabled
in classAbstractFilePacker
- Returns:
- true to use minified version of individual file, false if minification is disabled or enabled on whole pack
-
getLogger
protected org.apache.log4j.Logger getLogger()
Description copied from class:AbstractFilePacker
Returns the logger to be used for log messages. This methods must be implemented by the file packer.- Specified by:
getLogger
in classAbstractFilePacker
- Returns:
Logger
of this packer, must not return null.
-
minifyCSS
public static void minifyCSS(boolean force)
Create a minified version of all CSS found in JCMS.This method only process css file if minification is enabled through property
"channel.css-packer.compressor.enabled"
.
Only files contained in directories css, plugins and js are processed- Parameters:
force
- set to true to force generation of minified file even if an up to date apparently exists
-
getCSSFilesInPack
public static java.util.Set<java.lang.String> getCSSFilesInPack(java.util.Collection<java.lang.String> cssFiles, java.lang.String browserName)
Returns the set of the URLs created with the CSS packer, respecting the constraints of the browser.- Parameters:
cssFiles
- collection of CSS files to packbrowserName
- name of the browser used to find the properties 'channel.packer.xxx' defining the limit values. Ifnull
, use 'IE' because it's the most constraining.- Returns:
- Set of the CSS Packer URLs
-
-