コード例 #1
0
  /**
   * Prepare single and chunked HTML for publication.
   *
   * <p>The HTML built by docbkx-tools does not currently include the following, which this method
   * adds.
   *
   * <ul>
   *   <li>A DOCTYPE declaration (needed to get Internet Explorer to interpret CSS correctly
   *   <li>JavaScript to workaround a long-standing Firefox issue, and the fold/unfold long lines in
   *       Screen elements
   *   <li>A favicon link
   *   <li>JavaScript used by Google Analytics
   *   <li>CSS to style the HTML
   * </ul>
   *
   * @param htmlDir Directory under which to find HTML output
   * @throws MojoExecutionException Something went wrong when updating HTML.
   */
  final void postProcessHTML(final String htmlDir) throws MojoExecutionException {
    try {
      getLog().info("Editing built HTML...");
      HashMap<String, String> replacements = new HashMap<String, String>();

      String doctype =
          IOUtils.toString(getClass().getResourceAsStream("/starthtml-doctype.txt"), "UTF-8");
      replacements.put("<html>", doctype);

      String javascript =
          IOUtils.toString(getClass().getResourceAsStream("/endhead-js-favicon.txt"), "UTF-8");
      replacements.put("</head>", javascript);

      String linkToJira = getLinkToJira();
      String gascript =
          IOUtils.toString(getClass().getResourceAsStream("/endbody-ga.txt"), "UTF-8");
      gascript = gascript.replace("ANALYTICS-ID", getGoogleAnalyticsId());
      replacements.put("</body>", linkToJira + "\n" + gascript);

      HTMLUtils.updateHTML(htmlDir, replacements);

      getLog().info("Adding CSS...");
      File css = new File(getBuildDirectory().getPath() + File.separator + "coredoc.css");
      FileUtils.deleteQuietly(css);
      FileUtils.copyURLToFile(getClass().getResource("/coredoc.css"), css);
      HTMLUtils.addCss(htmlDir, css, FilenameUtils.getBaseName(getDocumentSrcName()) + ".html");
    } catch (IOException e) {
      throw new MojoExecutionException("Failed to update output HTML correctly: " + e.getMessage());
    }
  }
コード例 #2
0
ファイル: HTMLIndexFactory.java プロジェクト: vb7484/sveditor
 public String build(DocModel model) {
   fLog.debug(
       ILogLevel.LEVEL_MIN, String.format("Building index for topic(%s)", docTopicType.getName()));
   String res = HTMLUtils.STR_DOCTYPE;
   res += HTMLUtils.genHTMLHeadStart("..", fIndexNameCapitalized);
   res += HTMLUtils.genBodyBegin("IndexPage");
   res += genIndex("..", model);
   res += HTMLUtils.genFooter();
   res +=
       HTMLUtils.genMenu(
           cfg, "..", fIndexNameCapitalized, model.getDocTopics().getAllTopicTypes());
   res += HTMLUtils.genBodyHTMLEnd();
   return res;
 }