Class HtmlUtils

java.lang.Object
org.forgerock.doc.maven.utils.HtmlUtils

public final class HtmlUtils extends Object
Utility methods to prepare built HTML docs for publication.
  • Method Details

    • addHtaccess

      public static void addHtaccess(String baseDir, File htaccess) throws IOException
      Add a .htaccess file to the base directory, for publication on an Apache HTTPD server.

      According to Apache documentation on How directives are applied, "The configuration directives found in a .htaccess file are applied to the directory in which the .htaccess file is found, and to all subdirectories thereof." So there is no need to copy the file recursively to all directories.

      Parameters:
      baseDir - Base directory under which to add the file
      htaccess - .htaccess file to copy
      Throws:
      IOException - Something went wrong during copy procedure.
    • addCustomCss

      public static void addCustomCss(File cssFile, File srcDir, String documentSrcName) throws IOException
      Add custom CSS with XML wrapper to document source directories.

      See custom.css.source for details.

      Parameters:
      cssFile - The CSS file to wrap in XML.
      srcDir - The source directory for DocBook XML documents.
      documentSrcName - The top-level entry file to DocBook XML documents.
      Throws:
      IOException - Something went wrong adding CSS.
    • updateHtml

      public static List<File> updateHtml(String baseDir, Map<String,String> replacements) throws IOException
      Replace HTML tags with additional content.
      Parameters:
      baseDir - Base directory under which to find HTML files recursively
      replacements - Keys are tags to replace. Values are replacements, including the original tag.
      Returns:
      List of files updated
      Throws:
      IOException - Something went wrong reading or writing files.
    • fixResourceLinks

      public static void fixResourceLinks(String htmlDir, String resourcesDirBaseName) throws IOException
      Fix links to arbitrary resources in HTML files.

      Chunked HTML and webhelp have extra directories in the path. Links like ../resources/file.txt that work in the source do not work as is in these formats. Instead the links need an extra .. as in ../../resources/file.txt.

      Parameters:
      htmlDir - Path to a directory containing HTML.
      resourcesDirBaseName - Base name of the resources directory.
      Throws:
      IOException - Something went wrong updating links.