Class ThemeFilesProcessor
- Direct Known Subclasses:
ThemeCssFilesProcessor,ThemeJsFilesProcessor
The post processing of JS and CSS files is orchestrated in this base class with the specific configuration
for each provided through abstract methods. This process() method performs the major calls of
the process
- Author:
- Kuali Rice Team (rice.collab@kuali.org)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionThemeFilesProcessor(String themeName, File themeDirectory, Properties themeProperties, Map<String, File> themePluginDirsMap, File workingDir, String projectVersion) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidaddAdditionalFiles(List<File> themeFiles) Invoked during the collection of files to allow additional files to be added to the theme's listCollects the file names to include for the theme, separated by whether they come from a plugin directory or the theme directoryprotected FilecreateMergedFile(boolean minified) Creates a new file that will hold the merged or minified contentsprotected abstract StringKey for the property within the theme's properties file that can be configured to exlcude files of the type being processedprotected String[]Builds array of patterns used to exclude files to include for the typeprotected String[]Builds array of patterns used to find files to include for the type, by default picks up all files that have the extension for the type being processedprotected abstract StringKey for the property that will be written to the theme derived properties to list the included files for the file typeprotected abstract StringName of the directory relative to the theme directory which contains files for the typeprotected abstract StringExtension (ex.protected FileReturns the File object that points to the theme subdirectory that contains files for the file typegetThemePropertyValue(String propertyKey) Helper method that retrieves the value for the given property from the theme's properties as a list of stringsprotected voidmergeFiles(List<File> filesToMerge, File mergedFile) Merges the content from the list of files into the given merge fileprotected abstract voidInvoked after the merged file has been created to create the minified versionvoidprocess()Carries out the theme files post processprotected abstract StringprocessMergeFileContents(String fileContents, File fileToMerge, File mergedFile) Invoked during the merge process to alter the given file contents before they are appended to the merge filesortThemeFiles(List<File> pluginFiles, List<File> subDirFiles) Invoked to build the final sorted list of files for the type, files from plugins and from the theme's sub directory are passed separately so special treatment can be given to those for sorting
-
Field Details
-
PLUGIN_FILES_KEY
- See Also:
-
SUBDIR_FILES_KEY
- See Also:
-
themeName
-
themeDirectory
-
themeProperties
-
themePluginDirsMap
-
workingDir
-
projectVersion
-
-
Constructor Details
-
ThemeFilesProcessor
-
-
Method Details
-
process
public void process()Carries out the theme files post processProcessing of each file type includes the following:
- Collect the theme files for each type
- Perform a sorting process on the files to form the correct order of sourcing or merging
- Merge all the files for the type into a single file. Here subclasses can perform alterations on the merged contents
- Minifiy the merged file using a compressor that is appropriate for the file type
- Write out the listing of files for the type to the theme's properties file
Any
IOExceptionthat occur are caught and thrown as runtime exceptions -
collectThemeFiles
Collects the file names to include for the theme, separated by whether they come from a plugin directory or the theme directoryFirst all plugin directories that are included for the theme are listed based on the include for that file type
getFileIncludes(). Individual plugin files can be excluded with the propertypluginFileExcludes, or the global excludes for the file typegetFileExcludes()Next the subdirectory of the theme that holds the file type, given bygetFileTypeSubDirectory(), is listed to pick up include files. Again the global file includes and excludes for the type is used Finally, subclasses can add additional files by implementingaddAdditionalFiles(java.util.List)- Returns:
- map containing an entry for plugin file names, and theme file names. Keys are given by
PLUGIN_FILES_KEYandSUBDIR_FILES_KEY - See Also:
-
getFileIncludes
Builds array of patterns used to find files to include for the type, by default picks up all files that have the extension for the type being processed- Returns:
- array of string patterns to include
- See Also:
-
getFileExcludes
Builds array of patterns used to exclude files to include for the typeEach file type has a configuration property where exclude patterns can be listed. This property key is retrieved by
getExcludesConfigKey(), and then split by the comma to get the array of patterns- Returns:
- array of string patterns to exclude
-
getFileTypeSubDirectory
Returns the File object that points to the theme subdirectory that contains files for the file typeSub directory is formed by finding the directory with name
getFileTypeDirectoryName()within the theme directory- Returns:
- sub directory for the file type
- See Also:
-
createMergedFile
Creates a new file that will hold the merged or minified contentsThe merged file name is constructed by taking the theme name, concatenated with "." and the project version. To form the minified file name, the min suffix ".min" is appended to the merged file name
- Parameters:
minified- indicates whether to add the minified suffix- Returns:
- file object pointing to the merged or minified file
-
mergeFiles
Merges the content from the list of files into the given merge fileContents are read for each file in the order they appear in the files list. Before adding the contents to the merged file, the method
processMergeFileContents(java.lang.String, java.io.File, java.io.File)is invoked to allow subclasses to alter the contents- Parameters:
filesToMerge- list of files whose content should be mergedmergedFile- file that should receive the merged content- Throws:
IOException
-
getFileTypeExtension
Extension (ex. 'css') for the file type being processed- Returns:
- file type extension
-
getFileTypeDirectoryName
Name of the directory relative to the theme directory which contains files for the type- Returns:
- directory name
-
getExcludesConfigKey
Key for the property within the theme's properties file that can be configured to exlcude files of the type being processed- Returns:
- property key for file type excludes
-
getFileListingConfigKey
Key for the property that will be written to the theme derived properties to list the included files for the file type- Returns:
- property key for file type listing
-
addAdditionalFiles
Invoked during the collection of files to allow additional files to be added to the theme's list- Parameters:
themeFiles- list of additional files to included for the theme
-
sortThemeFiles
Invoked to build the final sorted list of files for the type, files from plugins and from the theme's sub directory are passed separately so special treatment can be given to those for sorting- 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
-
processMergeFileContents
protected abstract String processMergeFileContents(String fileContents, File fileToMerge, File mergedFile) throws IOException Invoked during the merge process to alter the given file contents before they are appended to the merge file- 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
-
minify
Invoked after the merged file has been created to create the minified version- Parameters:
mergedFile- file containing the merged contentsminifiedFile- file created to receive the minified contents- Throws:
IOException
-
getThemePropertyValue
Helper method that retrieves the value for the given property from the theme's properties as a list of strings- Parameters:
propertyKey- key for the property to retrieve the value for- Returns:
- list of string values parsed from the property value
-