01: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
02: // Released under the terms of the GNU General Public License version 2 or later.
03: package fitnesse.html;
04:
05: public class HtmlPage extends HtmlTag {
06: public static final String DTD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.DTD\">";
07: public static final String BreakPoint = "<!--BREAKPOINT-->";
08:
09: public HtmlTag head;
10: public HtmlTag title;
11: public HtmlTag body;
12: public HtmlTag header;
13: public HtmlTag sidebar;
14: public HtmlTag mainbar;
15: public HtmlTag artNiche;
16: public HtmlTag actions;
17: public HtmlTag main;
18: public String preDivision;
19: public String postDivision;
20:
21: protected HtmlPage() {
22: super ("html");
23:
24: add(makeHead());
25: add(makeBody());
26: }
27:
28: public String html() throws Exception {
29: String html = DTD + endl + super .html();
30: return html;
31: }
32:
33: protected HtmlTag makeBody() {
34: body = new HtmlTag("body");
35: mainbar = HtmlUtil.makeDivTag("mainbar");
36: header = HtmlUtil.makeDivTag("header");
37: sidebar = HtmlUtil.makeDivTag("sidebar");
38: actions = HtmlUtil.makeDivTag("actions");
39: main = HtmlUtil.makeDivTag("main");
40: makeArtNiche();
41:
42: mainbar.add(header);
43: mainbar.add(main);
44:
45: sidebar.add(artNiche);
46: sidebar.add(actions);
47:
48: body.add(sidebar);
49: body.add(mainbar);
50:
51: return body;
52: }
53:
54: protected void makeArtNiche() {
55: artNiche = HtmlUtil.makeDivTag("art_niche");
56: artNiche.addAttribute("onclick", "document.location='/'");
57: }
58:
59: protected HtmlTag makeHead() {
60: head = new HtmlTag("head");
61: title = new HtmlTag("title");
62: title.add("FitNesse");
63: head.add(title);
64: head.add(makeCssLink("/files/css/fitnesse.css", "screen"));
65: head.add(makeCssLink("/files/css/fitnesse_print.css", "print"));
66: head.add(HtmlUtil
67: .makeJavascriptLink("/files/javascript/fitnesse.js"));
68: return head;
69: }
70:
71: public HtmlTag makeCssLink(String link, String media) {
72: HtmlTag css = new HtmlTag("link");
73: css.addAttribute("rel", "stylesheet");
74: css.addAttribute("type", "text/css");
75: css.addAttribute("href", link);
76: css.addAttribute("media", media);
77: return css;
78: }
79:
80: public void divide() throws Exception {
81: String html = html();
82: int breakIndex = html.indexOf(BreakPoint);
83: preDivision = html.substring(0, breakIndex);
84: postDivision = html.substring(breakIndex + BreakPoint.length());
85: }
86: }
|