mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 23:34:52 +02:00
8204303: Add redirect for overview-summary.html
Reviewed-by: sundar, hannesw
This commit is contained in:
parent
bb4b387398
commit
d59da4a4b7
4 changed files with 65 additions and 38 deletions
|
@ -172,8 +172,12 @@ public class HtmlDoclet extends AbstractDoclet {
|
|||
}
|
||||
}
|
||||
|
||||
if (!configuration.frames && !configuration.createoverview) {
|
||||
IndexRedirectWriter.generate(configuration);
|
||||
if (!configuration.frames) {
|
||||
if (configuration.createoverview) {
|
||||
IndexRedirectWriter.generate(configuration, DocPaths.OVERVIEW_SUMMARY, DocPaths.INDEX);
|
||||
} else {
|
||||
IndexRedirectWriter.generate(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
if (configuration.helpfile.isEmpty() && !configuration.nohelp) {
|
||||
|
@ -201,7 +205,7 @@ public class HtmlDoclet extends AbstractDoclet {
|
|||
}
|
||||
}
|
||||
|
||||
protected void copyJqueryFiles() throws DocletException {
|
||||
private void copyJqueryFiles() throws DocletException {
|
||||
List<String> files = Arrays.asList(
|
||||
"jquery-1.12.4.js",
|
||||
"jquery-ui.js",
|
||||
|
@ -245,7 +249,6 @@ public class HtmlDoclet extends AbstractDoclet {
|
|||
protected void generateClassFiles(SortedSet<TypeElement> arr, ClassTree classtree)
|
||||
throws DocletException {
|
||||
List<TypeElement> list = new ArrayList<>(arr);
|
||||
ListIterator<TypeElement> iterator = list.listIterator();
|
||||
for (TypeElement klass : list) {
|
||||
if (utils.hasHiddenTag(klass) ||
|
||||
!(configuration.isGeneratedDoc(klass) && utils.isIncluded(klass))) {
|
||||
|
@ -274,7 +277,6 @@ public class HtmlDoclet extends AbstractDoclet {
|
|||
ModuleIndexFrameWriter.generate(configuration);
|
||||
}
|
||||
List<ModuleElement> mdles = new ArrayList<>(configuration.modulePackages.keySet());
|
||||
int i = 0;
|
||||
for (ModuleElement mdle : mdles) {
|
||||
if (configuration.frames && configuration.modules.size() > 1) {
|
||||
ModulePackageIndexFrameWriter.generate(configuration, mdle);
|
||||
|
@ -283,21 +285,10 @@ public class HtmlDoclet extends AbstractDoclet {
|
|||
AbstractBuilder moduleSummaryBuilder =
|
||||
configuration.getBuilderFactory().getModuleSummaryBuilder(mdle);
|
||||
moduleSummaryBuilder.build();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PackageElement getNamedPackage(List<PackageElement> list, int idx) {
|
||||
if (idx < list.size()) {
|
||||
PackageElement pkg = list.get(idx);
|
||||
if (pkg != null && !pkg.isUnnamed()) {
|
||||
return pkg;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -308,11 +299,10 @@ public class HtmlDoclet extends AbstractDoclet {
|
|||
PackageIndexFrameWriter.generate(configuration);
|
||||
}
|
||||
List<PackageElement> pList = new ArrayList<>(packages);
|
||||
for (int i = 0 ; i < pList.size() ; i++) {
|
||||
for (PackageElement pkg : pList) {
|
||||
// if -nodeprecated option is set and the package is marked as
|
||||
// deprecated, do not generate the package-summary.html, package-frame.html
|
||||
// and package-tree.html pages for that package.
|
||||
PackageElement pkg = pList.get(i);
|
||||
if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) {
|
||||
if (configuration.frames) {
|
||||
PackageFrameWriter.generate(configuration, pkg);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -41,8 +41,8 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocPath;
|
|||
import jdk.javadoc.internal.doclets.toolkit.util.DocPaths;
|
||||
|
||||
/**
|
||||
* Writes an index.html file that tries to redirect to an alternate page.
|
||||
* The redirect uses JavaSCript, if enabled, falling back on
|
||||
* Writes a file that tries to redirect to an alternate page.
|
||||
* The redirect uses JavaScript, if enabled, falling back on
|
||||
* {@code <meta http-eqiv=refresh content="0,<uri>">}.
|
||||
* If neither are supported/enabled in a browser, the page displays the
|
||||
* standard "JavaScipt not enabled" message, and a link to the alternate page.
|
||||
|
@ -51,21 +51,27 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
|
|||
|
||||
public static void generate(HtmlConfiguration configuration)
|
||||
throws DocFileIOException {
|
||||
IndexRedirectWriter indexRedirect;
|
||||
DocPath filename = DocPaths.INDEX;
|
||||
indexRedirect = new IndexRedirectWriter(configuration, filename);
|
||||
indexRedirect.generateIndexFile();
|
||||
generate(configuration, DocPaths.INDEX, configuration.topFile);
|
||||
}
|
||||
|
||||
IndexRedirectWriter(HtmlConfiguration configuration, DocPath filename) {
|
||||
public static void generate(HtmlConfiguration configuration, DocPath fileName, DocPath target)
|
||||
throws DocFileIOException {
|
||||
IndexRedirectWriter indexRedirect = new IndexRedirectWriter(configuration, fileName, target);
|
||||
indexRedirect.generateIndexFile();
|
||||
}
|
||||
|
||||
private DocPath target;
|
||||
|
||||
private IndexRedirectWriter(HtmlConfiguration configuration, DocPath filename, DocPath target) {
|
||||
super(configuration, filename);
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an index file that redirects to an alternate file.
|
||||
* @throws DocFileIOException if there is a problem generating the file
|
||||
*/
|
||||
void generateIndexFile() throws DocFileIOException {
|
||||
private void generateIndexFile() throws DocFileIOException {
|
||||
DocType htmlDocType = DocType.forVersion(configuration.htmlVersion);
|
||||
Content htmlComment = contents.newPage;
|
||||
Head head = new Head(path, configuration.htmlVersion, configuration.docletVersion)
|
||||
|
@ -77,15 +83,16 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
|
|||
: resources.getText("doclet.Generated_Docs_Untitled");
|
||||
|
||||
head.setTitle(title)
|
||||
.setCharset(configuration.charset);
|
||||
.setCharset(configuration.charset)
|
||||
.setCanonicalLink(target);
|
||||
|
||||
String topFilePath = configuration.topFile.getPath();
|
||||
String targetPath = target.getPath();
|
||||
Script script = new Script("window.location.replace(")
|
||||
.appendStringLiteral(topFilePath, '\'')
|
||||
.appendStringLiteral(targetPath, '\'')
|
||||
.append(")");
|
||||
HtmlTree metaRefresh = new HtmlTree(HtmlTag.META)
|
||||
.addAttr(HtmlAttr.HTTP_EQUIV, "Refresh")
|
||||
.addAttr(HtmlAttr.CONTENT, "0;" + topFilePath);
|
||||
.addAttr(HtmlAttr.CONTENT, "0;" + targetPath);
|
||||
head.addContent(
|
||||
script.asContent(),
|
||||
configuration.isOutputHtml5() ? HtmlTree.NOSCRIPT(metaRefresh) : metaRefresh);
|
||||
|
@ -94,7 +101,7 @@ public class IndexRedirectWriter extends HtmlDocletWriter {
|
|||
bodyContent.addContent(HtmlTree.NOSCRIPT(
|
||||
HtmlTree.P(contents.getContent("doclet.No_Script_Message"))));
|
||||
|
||||
bodyContent.addContent(HtmlTree.P(HtmlTree.A(topFilePath, new StringContent(topFilePath))));
|
||||
bodyContent.addContent(HtmlTree.P(HtmlTree.A(targetPath, new StringContent(targetPath))));
|
||||
|
||||
Content body = new HtmlTree(HtmlTag.BODY);
|
||||
if (configuration.allowTag(HtmlTag.MAIN)) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -67,7 +67,8 @@ public class Head {
|
|||
private Script mainBodyScript;
|
||||
private final List<Script> scripts;
|
||||
private final List<Content> extraContent;
|
||||
boolean addDefaultScript = true;
|
||||
private boolean addDefaultScript = true;
|
||||
private DocPath canonicalLink;
|
||||
|
||||
private static final Calendar calendar = new GregorianCalendar(TimeZone.getDefault());
|
||||
|
||||
|
@ -227,6 +228,16 @@ public class Head {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies a value for a
|
||||
* <a href="https://en.wikipedia.org/wiki/Canonical_link_element">canonical link</a>
|
||||
* in the {@code <head>} element.
|
||||
* @param link
|
||||
*/
|
||||
public void setCanonicalLink(DocPath link) {
|
||||
this.canonicalLink = link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds additional content to be included in the HEAD element.
|
||||
*
|
||||
|
@ -271,6 +282,13 @@ public class Head {
|
|||
tree.addContent(c);
|
||||
}
|
||||
|
||||
if (canonicalLink != null) {
|
||||
HtmlTree link = new HtmlTree(HtmlTag.LINK);
|
||||
link.addAttr(HtmlAttr.REL, "canonical");
|
||||
link.addAttr(HtmlAttr.HREF, canonicalLink.getPath());
|
||||
tree.addContent(link);
|
||||
}
|
||||
|
||||
addStylesheets(tree);
|
||||
addScripts(tree);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue