001: /*
002: * Copyright (c) 1998-2000 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Emil Ong
028: */
029:
030: package com.caucho.xtpdoc;
031:
032: import javax.xml.stream.XMLStreamException;
033: import javax.xml.stream.XMLStreamWriter;
034: import java.io.IOException;
035: import java.io.PrintWriter;
036:
037: public class Header {
038: private Document _document;
039: private String _product;
040: private String _version;
041: private String _title;
042: private String _browserTitle;
043: private String _author;
044: private String _date;
045: private Section _description;
046: private Keywords _keywords;
047: private String _tutorial;
048:
049: public Header(Document document) {
050: _document = document;
051: }
052:
053: public void setProduct(String product) {
054: _product = product;
055: }
056:
057: public void setVersion(String version) {
058: _version = version;
059: }
060:
061: public void setTitle(String title) {
062: _title = title;
063: }
064:
065: public void setBrowserTitle(String title) {
066: _browserTitle = title;
067: }
068:
069: public String getTitle() {
070: return _title;
071: }
072:
073: public void setDate(String date) {
074: _date = date;
075: }
076:
077: public void setAuthor(String author) {
078: _author = author;
079: }
080:
081: public void setResin2_0(String resin2_0) {
082: }
083:
084: public void setType(String type) {
085: }
086:
087: public void setTutorialStartpage(String startPage) {
088: _tutorial = startPage;
089: }
090:
091: public String getTutorialStartPage() {
092: return _tutorial;
093: }
094:
095: public void setLevel(String level) {
096: }
097:
098: public void setKeywords(Keywords keywords) {
099: _keywords = keywords;
100: }
101:
102: public ContentItem getDescription() {
103: return _description;
104: }
105:
106: public Section createDescription() {
107: _description = new S1(_document);
108: return _description;
109: }
110:
111: public void writeHtml(XMLStreamWriter out)
112: throws XMLStreamException {
113: out.writeStartElement("head");
114:
115: out.writeEmptyElement("meta");
116: out.writeAttribute("http-equiv", "Content-Type");
117: out.writeAttribute("content", "text/html; charset=utf-8");
118:
119: if (_product != null) {
120: out.writeEmptyElement("meta");
121: out.writeAttribute("name", "product");
122: out.writeAttribute("content", _product);
123: }
124:
125: if (_version != null) {
126: out.writeEmptyElement("meta");
127: out.writeAttribute("name", "version");
128: out.writeAttribute("content", _version);
129: }
130:
131: if (_keywords != null) {
132: out.writeEmptyElement("meta");
133: out.writeAttribute("name", "keywords");
134: out.writeAttribute("content", _keywords.toString());
135: }
136:
137: out.writeEmptyElement("link");
138: out.writeAttribute("rel", "STYLESHEET");
139: out.writeAttribute("type", "text/css");
140: out.writeAttribute("href", _document.getContextPath()
141: + "/css/default.css");
142:
143: out.writeEmptyElement("link");
144: out.writeAttribute("rel", "shortcut icon");
145: out.writeAttribute("href", _document.getContextPath()
146: + "/images/favicon.ico");
147:
148: out.writeStartElement("title");
149:
150: NavigationItem nav = _document.getNavigation();
151:
152: if (nav != null && nav.getNavigation() != null
153: && nav.getNavigation().getSection() != null)
154: out.writeCharacters(nav.getNavigation().getSection());
155:
156: out.writeCharacters(_title);
157: out.writeEndElement(); // title
158:
159: out.writeEndElement(); // head
160: }
161:
162: public void writeLaTeXTop(PrintWriter out) throws IOException {
163: out.println("\\usepackage[margin=1in]{geometry}");
164: out.println("\\usepackage{url}");
165: out.println("\\usepackage{hyperref}");
166: out.println("\\usepackage{graphicx}");
167: out.println("\\usepackage{color}");
168: out.println("\\usepackage{colortbl}");
169: out.println("\\usepackage{fancyvrb}");
170: out.println("\\usepackage{listings}");
171: out.println();
172: out.println("\\definecolor{example-gray}{gray}{0.8}");
173: out.println("\\definecolor{results-gray}{gray}{0.6}");
174: out.println();
175: out.println("\\title{" + _title + "}");
176: //XXX: product & version
177: }
178:
179: public void writeLaTeX(PrintWriter out) throws IOException {
180: out.println("\\section{" + _title + "}");
181:
182: out.println("\\label{" + _document.getName() + "}");
183: out.println("\\hypertarget{" + _document.getName() + "}{}");
184: }
185:
186: public void writeLaTeXEnclosed(PrintWriter out) throws IOException {
187: out.println("\\subsection{" + _title + "}");
188:
189: out.println("\\label{" + _document.getName() + "}");
190: out.println("\\hypertarget{" + _document.getName() + "}{}");
191: }
192: }
|