001: // Copyright (C) 2003,2004,2005 by Object Mentor, Inc. All rights reserved.
002: // Released under the terms of the GNU General Public License version 2 or later.
003: package fitnesse.html;
004:
005: public class HtmlPage extends HtmlTag {
006: // public static final String DTD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD
007: // HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.DTD\">";
008: // We need to declare that we're using the Transitional DTD, and not include
009: // the URL, or the frames in the STIQ test page will
010: // sometimes resize themselves to maximum width (after a certain
011: // indeterminate but generally >10 minutes delay, or when the
012: // browser font size is changed).
013: public static final String DTD = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">";
014:
015: public static final String BreakPoint = "<!--BREAKPOINT-->";
016:
017: public HtmlTag head;
018:
019: public HtmlTag title;
020:
021: public HtmlTag body;
022:
023: public HtmlTag header;
024:
025: public HtmlTag sidebar;
026:
027: public HtmlTag mainbar;
028:
029: public HtmlTag artNiche;
030:
031: public HtmlTag actions;
032:
033: public HtmlTag main;
034:
035: public String preDivision;
036:
037: public String postDivision;
038:
039: protected HtmlPage() {
040: super ("html");
041:
042: add(makeHead());
043: add(makeBody());
044: }
045:
046: public String html() throws Exception {
047: String html = DTD + endl + super .html();
048: return html;
049: }
050:
051: protected HtmlTag makeBody() {
052: body = new HtmlTag("body");
053: mainbar = HtmlUtil.makeDivTag("mainbar");
054: mainbar.addAttribute("id", "mainbar");
055: header = HtmlUtil.makeDivTag("header");
056: header.addAttribute("id", "header");
057: sidebar = HtmlUtil.makeDivTag("sidebar");
058: sidebar.addAttribute("id", "sidebar");
059: actions = HtmlUtil.makeDivTag("actions");
060: actions.addAttribute("id", "actions");
061: main = HtmlUtil.makeDivTag("main");
062: main.addAttribute("id", "mainDiv");
063: makeArtNiche();
064:
065: mainbar.add(header);
066: mainbar.add(main);
067:
068: // sidebar.add(artNiche);
069: // sidebar.add(actions);
070:
071: body.add(actions);
072: // body.add(sidebar);
073: body.add(mainbar);
074:
075: return body;
076: }
077:
078: protected void makeArtNiche() {
079: artNiche = HtmlUtil.makeDivTag("art_niche");
080: artNiche.addAttribute("onclick", "document.location='/'");
081: }
082:
083: protected HtmlTag makeHead() {
084: head = new HtmlTag("head");
085: title = new HtmlTag("title");
086: title.add("FitNesse");
087: head.add(title);
088: head.add(makeCssLink("/files/css/fitnesse.css", "screen"));
089: head.add(makeCssLink("/files/css/fitnesse_print.css", "print"));
090: head.add(HtmlUtil
091: .makeJavascriptLink("/files/javascript/fitnesse.js"));
092: head
093: .add(HtmlUtil
094: .makeJavascriptLink("/files/javascript/fitnesse_bonus.js"));
095: return head;
096: }
097:
098: public HtmlTag makeCssLink(String link, String media) {
099: HtmlTag css = new HtmlTag("link");
100: css.addAttribute("rel", "stylesheet");
101: css.addAttribute("type", "text/css");
102: css.addAttribute("href", link);
103: css.addAttribute("media", media);
104: return css;
105: }
106:
107: public void divide() throws Exception {
108: String html = html();
109: int breakIndex = html.indexOf(BreakPoint);
110: preDivision = html.substring(0, breakIndex);
111: postDivision = html.substring(breakIndex + BreakPoint.length());
112: }
113:
114: }
|