Class ThemeCssFilesProcessor

java.lang.Object
org.kuali.rice.krad.theme.postprocessor.ThemeFilesProcessor
org.kuali.rice.krad.theme.postprocessor.ThemeCssFilesProcessor

public class ThemeCssFilesProcessor extends ThemeFilesProcessor
Theme files processor for CSS files

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 Details

    • linebreak

      protected int linebreak
  • Constructor Details

  • Method Details

    • getFileTypeExtension

      protected String getFileTypeExtension()
      Description copied from class: ThemeFilesProcessor
      Extension (ex. 'css') for the file type being processed
      Specified by:
      getFileTypeExtension in class ThemeFilesProcessor
      Returns:
      file type extension
      See Also:
    • getExcludesConfigKey

      protected String getExcludesConfigKey()
      Description copied from class: ThemeFilesProcessor
      Key for the property within the theme's properties file that can be configured to exlcude files of the type being processed
      Specified by:
      getExcludesConfigKey in class ThemeFilesProcessor
      Returns:
      property key for file type excludes
      See Also:
    • getFileTypeDirectoryName

      protected String getFileTypeDirectoryName()
      Description copied from class: ThemeFilesProcessor
      Name of the directory relative to the theme directory which contains files for the type
      Specified by:
      getFileTypeDirectoryName in class ThemeFilesProcessor
      Returns:
      directory name
      See Also:
    • getFileListingConfigKey

      protected String getFileListingConfigKey()
      Description copied from class: ThemeFilesProcessor
      Key for the property that will be written to the theme derived properties to list the included files for the file type
      Specified by:
      getFileListingConfigKey in class ThemeFilesProcessor
      Returns:
      property key for file type listing
      See Also:
    • addAdditionalFiles

      protected void addAdditionalFiles(List<File> themeFiles)
      Description copied from class: ThemeFilesProcessor
      Invoked during the collection of files to allow additional files to be added to the theme's list
      Specified by:
      addAdditionalFiles in class ThemeFilesProcessor
      Parameters:
      themeFiles - list of additional files to included for the theme
      See Also:
    • sortThemeFiles

      protected List<File> sortThemeFiles(List<File> pluginFiles, List<File> subDirFiles)
      Sorts the list of CSS files from the plugin and sub directories

      The sorting algorithm is as follows:

      1. Any files which match patterns configured by the property cssLoadFirst
      2. CSS files from plugin directories, first ordered by any files that match patterns configured with pluginCssLoadOrder, followed by all remaining plugin files
      3. CSS files from the theme subdirectory, first ordered by any files that match patterns configured with themeCssLoadOrder, then any remaining theme files
      4. 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:
      sortThemeFiles in class ThemeFilesProcessor
      Parameters:
      pluginFiles - list of files that will be included and come from a plugin directory
      subDirFiles - 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:
    • 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:
      processMergeFileContents in class ThemeFilesProcessor
      Parameters:
      fileContents - contents of the file that will be added
      fileToMerge - file the contents were pulled from
      mergedFile - file receiving the merged contents
      Returns:
      file contents to merge (possibly altered)
      Throws:
      IOException
      See Also:
    • rewriteCssUrls

      protected String rewriteCssUrls(String css, File mergeFile, File mergedFile) throws IOException
      Performs URL rewriting within the given CSS contents

      The 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 for
      mergeFile - file that provided the merge contents
      mergedFile - file the contents will be going to
      Returns:
      css contents, with possible adjusted URLs
      Throws:
      IOException
    • minify

      protected void minify(File mergedFile, File minifiedFile) throws IOException
      Minifies the CSS contents from the given merged file into the minified file

      Minification is performed using the YUI Compressor compiler with no line break

      Specified by:
      minify in class ThemeFilesProcessor
      Parameters:
      mergedFile - file containing the merged contents
      minifiedFile - file created to receive the minified contents
      Throws:
      IOException
      See Also: