58 public static void generate(HtmlConfiguration configuration, DocPath fileName, DocPath target) 59 throws DocFileIOException { 60 IndexRedirectWriter indexRedirect = new IndexRedirectWriter(configuration, fileName, target); 61 indexRedirect.generateIndexFile(); 62 } 63 64 private DocPath target; 65 66 private IndexRedirectWriter(HtmlConfiguration configuration, DocPath filename, DocPath target) { 67 super(configuration, filename); 68 this.target = target; 69 } 70 71 /** 72 * Generate an index file that redirects to an alternate file. 73 * @throws DocFileIOException if there is a problem generating the file 74 */ 75 private void generateIndexFile() throws DocFileIOException { 76 Content htmlComment = contents.newPage; 77 Head head = new Head(path, configuration.docletVersion, configuration.startTime) 78 .setTimestamp(!configuration.notimestamp) 79 .setDescription("index redirect") 80 .setGenerator(getGenerator(getClass())) 81 .setStylesheets(configuration.getMainStylesheet(), Collections.emptyList()) // avoid reference to default stylesheet 82 .addDefaultScript(false); 83 84 String title = (configuration.windowtitle.length() > 0) 85 ? configuration.windowtitle 86 : resources.getText("doclet.Generated_Docs_Untitled"); 87 88 head.setTitle(title) 89 .setCharset(configuration.charset) 90 .setCanonicalLink(target); 91 92 String targetPath = target.getPath(); 93 Script script = new Script("window.location.replace(") 94 .appendStringLiteral(targetPath, '\'') 95 .append(")"); 96 HtmlTree metaRefresh = new HtmlTree(HtmlTag.META) 97 .put(HtmlAttr.HTTP_EQUIV, "Refresh") 98 .put(HtmlAttr.CONTENT, "0;" + targetPath); 99 head.addContent(script.asContent(), HtmlTree.NOSCRIPT(metaRefresh)); 100 101 ContentBuilder bodyContent = new ContentBuilder(); 102 bodyContent.add(HtmlTree.NOSCRIPT( 103 HtmlTree.P(contents.getContent("doclet.No_Script_Message")))); 104 105 bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath)))); 106 107 Content body = new HtmlTree(HtmlTag.BODY) 108 .put(HtmlAttr.CLASS, "index-redirect"); 109 HtmlTree main = HtmlTree.MAIN(bodyContent); | 58 public static void generate(HtmlConfiguration configuration, DocPath fileName, DocPath target) 59 throws DocFileIOException { 60 IndexRedirectWriter indexRedirect = new IndexRedirectWriter(configuration, fileName, target); 61 indexRedirect.generateIndexFile(); 62 } 63 64 private DocPath target; 65 66 private IndexRedirectWriter(HtmlConfiguration configuration, DocPath filename, DocPath target) { 67 super(configuration, filename); 68 this.target = target; 69 } 70 71 /** 72 * Generate an index file that redirects to an alternate file. 73 * @throws DocFileIOException if there is a problem generating the file 74 */ 75 private void generateIndexFile() throws DocFileIOException { 76 Content htmlComment = contents.newPage; 77 Head head = new Head(path, configuration.docletVersion, configuration.startTime) 78 .setTimestamp(!options.noTimestamp) 79 .setDescription("index redirect") 80 .setGenerator(getGenerator(getClass())) 81 .setStylesheets(configuration.getMainStylesheet(), Collections.emptyList()) // avoid reference to default stylesheet 82 .addDefaultScript(false); 83 84 String title = (options.windowTitle.length() > 0) 85 ? options.windowTitle 86 : resources.getText("doclet.Generated_Docs_Untitled"); 87 88 head.setTitle(title) 89 .setCharset(options.charset) 90 .setCanonicalLink(target); 91 92 String targetPath = target.getPath(); 93 Script script = new Script("window.location.replace(") 94 .appendStringLiteral(targetPath, '\'') 95 .append(")"); 96 HtmlTree metaRefresh = new HtmlTree(HtmlTag.META) 97 .put(HtmlAttr.HTTP_EQUIV, "Refresh") 98 .put(HtmlAttr.CONTENT, "0;" + targetPath); 99 head.addContent(script.asContent(), HtmlTree.NOSCRIPT(metaRefresh)); 100 101 ContentBuilder bodyContent = new ContentBuilder(); 102 bodyContent.add(HtmlTree.NOSCRIPT( 103 HtmlTree.P(contents.getContent("doclet.No_Script_Message")))); 104 105 bodyContent.add(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath)))); 106 107 Content body = new HtmlTree(HtmlTag.BODY) 108 .put(HtmlAttr.CLASS, "index-redirect"); 109 HtmlTree main = HtmlTree.MAIN(bodyContent); |