52 |
private PrintWriter out; |
private PrintWriter out; |
53 |
private String pathToRoot; |
private String pathToRoot; |
54 |
private String docType; |
private String docType; |
55 |
|
private String baseUrl; |
56 |
|
private File rootDir; |
57 |
|
|
58 |
public static final String DOCTYPE_FRAMESET = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"; |
public static final String DOCTYPE_FRAMESET = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">"; |
59 |
|
|
60 |
public HtmlPage(File file, String pathToRoot, String encoding) |
public HtmlPage(File file, String pathToRoot, String encoding, String baseUrl, File rootDir) |
61 |
throws IOException |
throws IOException |
62 |
{ |
{ |
63 |
this(file, pathToRoot, encoding, "<!DOCTYPE html PUBLIC \"-//gnu.org///DTD XHTML 1.1 plus Target 1.0//EN\" \"" + pathToRoot + "/resources/xhtml11-target10.dtd\">"); |
this(file, pathToRoot, encoding, baseUrl, rootDir, "<!DOCTYPE html PUBLIC \"-//gnu.org///DTD XHTML 1.1 plus Target 1.0//EN\" \"" + pathToRoot + "/resources/xhtml11-target10.dtd\">"); |
64 |
} |
} |
65 |
|
|
66 |
public HtmlPage(File file, String pathToRoot, String encoding, String docType) |
public HtmlPage(File file, String pathToRoot, String encoding, String baseUrl, File rootDir, String docType) |
67 |
throws IOException |
throws IOException |
68 |
{ |
{ |
69 |
this.file = file; |
this.file = file; |
79 |
this.out = new PrintWriter(new BufferedWriter(writer)); |
this.out = new PrintWriter(new BufferedWriter(writer)); |
80 |
this.pathToRoot = pathToRoot; |
this.pathToRoot = pathToRoot; |
81 |
this.docType = docType; |
this.docType = docType; |
82 |
|
this.baseUrl = baseUrl; |
83 |
|
this.rootDir = rootDir; |
84 |
} |
} |
85 |
|
|
86 |
public void beginElement(String elementName) |
public void beginElement(String elementName) |
270 |
} |
} |
271 |
|
|
272 |
public void beginPage(String title, String charset, Map stylesheets) |
public void beginPage(String title, String charset, Map stylesheets) |
273 |
|
throws IOException |
274 |
{ |
{ |
275 |
beginPage(title, charset, Collections.EMPTY_SET, stylesheets); |
beginPage(title, charset, Collections.EMPTY_SET, stylesheets); |
276 |
} |
} |
277 |
|
|
278 |
public void beginPage(String title, String charset, |
public void beginPage(String title, String charset, |
279 |
Collection keywords, Map stylesheets) |
Collection keywords, Map stylesheets) |
280 |
|
throws IOException |
281 |
{ |
{ |
282 |
print("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\n"); |
print("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\n"); |
283 |
print(docType); |
print(docType); |
286 |
beginElement("title"); |
beginElement("title"); |
287 |
print(title); |
print(title); |
288 |
endElement("title"); |
endElement("title"); |
289 |
|
if (null != baseUrl && baseUrl.length() > 0) { |
290 |
|
StringBuffer url = new StringBuffer(); |
291 |
|
url.append(baseUrl); |
292 |
|
if ('/' == url.charAt(url.length() - 1)) { |
293 |
|
url.delete(url.length() - 1, url.length()); |
294 |
|
} |
295 |
|
url.append(file.getCanonicalPath().substring(rootDir.getCanonicalPath().length())); |
296 |
|
atomicElement("base", |
297 |
|
new String[] { "href" }, |
298 |
|
new String[] { url.toString() }); |
299 |
|
} |
300 |
beginElement("script", |
beginElement("script", |
301 |
new String[] { "src", "type" }, |
new String[] { "src", "type" }, |
302 |
new String[] { pathToRoot + "/resources/gjdoc.js", "text/javascript" }); |
new String[] { pathToRoot + "/resources/gjdoc.js", "text/javascript" }); |