Class ThemeCssFilesProcessor
Merge contents are processed to rewrite any URLs (to images) for the changed path. CSS includes are not rewritten and will not work correctly in the merged file. For minification, the YUI compressor is used: YUI Compressor
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
- See Also:
-
Field Summary
FieldsFields inherited from class org.kuali.rice.krad.theme.postprocessor.ThemeFilesProcessor
PLUGIN_FILES_KEY, projectVersion, SUBDIR_FILES_KEY, themeDirectory, themeName, themePluginDirsMap, themeProperties, workingDir -
Constructor Summary
ConstructorsConstructorDescriptionThemeCssFilesProcessor(String themeName, File themeDirectory, Properties themeProperties, Map<String, File> themePluginDirsMap, File workingDir, String projectVersion) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddAdditionalFiles(List<File> themeFiles) Invoked during the collection of files to allow additional files to be added to the theme's listprotected StringKey for the property within the theme's properties file that can be configured to exlcude files of the type being processedprotected StringKey for the property that will be written to the theme derived properties to list the included files for the file typeprotected StringName of the directory relative to the theme directory which contains files for the typeprotected StringExtension (ex.protected voidMinifies the CSS contents from the given merged file into the minified fileprotected StringprocessMergeFileContents(String fileContents, File fileToMerge, File mergedFile) Processes the merge contents to rewrite any URLs necessary for the directory changeprotected StringrewriteCssUrls(String css, File mergeFile, File mergedFile) Performs URL rewriting within the given CSS contentssortThemeFiles(List<File> pluginFiles, List<File> subDirFiles) Sorts the list of CSS files from the plugin and sub directoriesMethods inherited from class org.kuali.rice.krad.theme.postprocessor.ThemeFilesProcessor
collectThemeFiles, createMergedFile, getFileExcludes, getFileIncludes, getFileTypeSubDirectory, getThemePropertyValue, mergeFiles, process
-
Field Details
-
linebreak
protected int linebreak
-
-
Constructor Details
-
ThemeCssFilesProcessor
-
-
Method Details
-
getFileTypeExtension
Description copied from class:ThemeFilesProcessorExtension (ex. 'css') for the file type being processed- Specified by:
getFileTypeExtensionin classThemeFilesProcessor- Returns:
- file type extension
- See Also:
-
getExcludesConfigKey
Description copied from class:ThemeFilesProcessorKey for the property within the theme's properties file that can be configured to exlcude files of the type being processed- Specified by:
getExcludesConfigKeyin classThemeFilesProcessor- Returns:
- property key for file type excludes
- See Also:
-
getFileTypeDirectoryName
Description copied from class:ThemeFilesProcessorName of the directory relative to the theme directory which contains files for the type- Specified by:
getFileTypeDirectoryNamein classThemeFilesProcessor- Returns:
- directory name
- See Also:
-
getFileListingConfigKey
Description copied from class:ThemeFilesProcessorKey for the property that will be written to the theme derived properties to list the included files for the file type- Specified by:
getFileListingConfigKeyin classThemeFilesProcessor- Returns:
- property key for file type listing
- See Also:
-
addAdditionalFiles
Description copied from class:ThemeFilesProcessorInvoked during the collection of files to allow additional files to be added to the theme's list- Specified by:
addAdditionalFilesin classThemeFilesProcessor- Parameters:
themeFiles- list of additional files to included for the theme- See Also:
-
sortThemeFiles
Sorts the list of CSS files from the plugin and sub directoriesThe sorting algorithm is as follows:
- Any files which match patterns configured by the property
cssLoadFirst - CSS files from plugin directories, first ordered by any files that match patterns configured with
pluginCssLoadOrder, followed by all remaining plugin files - CSS files from the theme subdirectory, first ordered by any files that match patterns configured
with
themeCssLoadOrder, then any remaining theme files - Files that match patterns configured by the property
cssLoadLast. Note any files that match here will be excluded from any of the previous steps
- Specified by:
sortThemeFilesin classThemeFilesProcessor- Parameters:
pluginFiles- list of files that will be included and come from a plugin directorysubDirFiles- list of files that will be included and come from the theme subdirectory- Returns:
- list of all files to include for the theme in the correct source order
- See Also:
- Any files which match patterns configured by the property
-
processMergeFileContents
protected String processMergeFileContents(String fileContents, File fileToMerge, File mergedFile) throws IOException Processes the merge contents to rewrite any URLs necessary for the directory change- Specified by:
processMergeFileContentsin classThemeFilesProcessor- Parameters:
fileContents- contents of the file that will be addedfileToMerge- file the contents were pulled frommergedFile- file receiving the merged contents- Returns:
- file contents to merge (possibly altered)
- Throws:
IOException- See Also:
-
rewriteCssUrls
Performs URL rewriting within the given CSS contentsThe given merge file (where the merge contents come from) and the merged file (where they are going to) is used to determine the path difference. Once that path difference is found, the contents are then matched to find any URLs. For each relative URL (absolute URLs are not modified), the path is adjusted and replaced into the contents. ex. suppose the merged file is /plugins/foo/plugin.css, and the merged file is /themes/mytheme/stylesheets/merged.css, the path difference will then be '../../../plugins/foo/'. So a URL in the CSS contents of 'images/image.png' will get rewritten to '../../../plugins/foo/images/image.png'
- Parameters:
css- contents to adjust URLs formergeFile- file that provided the merge contentsmergedFile- file the contents will be going to- Returns:
- css contents, with possible adjusted URLs
- Throws:
IOException
-
minify
Minifies the CSS contents from the given merged file into the minified fileMinification is performed using the YUI Compressor compiler with no line break
- Specified by:
minifyin classThemeFilesProcessor- Parameters:
mergedFile- file containing the merged contentsminifiedFile- file created to receive the minified contents- Throws:
IOException- See Also:
-