1 package net.sf.statcvs.pages;
2
3 import net.sf.statcvs.Messages;
4 import net.sf.statcvs.output.ConfigurationOptions;
5 import net.sf.statcvs.util.FileUtils;
6
7 /**
8 * @author Richard Cyganiak (richard@cyganiak.de)
9 * @version $Id: MarkupHTML.java,v 1.7 2009/08/19 22:11:15 benoitx Exp $
10 */
11 public class MarkupHTML extends AbstractMarkup implements MarkupSyntax {
12 private final static MarkupSyntax instance = new MarkupHTML();
13
14 public static MarkupSyntax getInstance() {
15 return instance;
16 }
17
18 private MarkupHTML() {
19
20 }
21
22 public String getExtension() {
23 return "html";
24 }
25
26 public String getHeader(final String pageName, final String stylesheetURL, final String charSet) {
27 final StringBuffer b = new StringBuffer();
28 b.append("<?xml version=\"1.0\"?>\n");
29 b.append("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" ");
30 b.append("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n");
31 b.append("<html xmlns=\"http://www.w3.org/1999/xhtml\">\n");
32 b.append("<head>\n <title>");
33 b.append(Messages.getString("PROJECT_SHORTNAME"));
34 b.append(" - ");
35 b.append(pageName);
36 b.append("</title>\n");
37 b.append(" <meta http-equiv=\"Content-Type\" content=\"text/html; charset=");
38 b.append(charSet);
39 b.append("\"/>\n");
40 b.append(" <meta name=\"Generator\" content=\"");
41 b.append(Messages.getString("PROJECT_SHORTNAME"));
42 b.append(" ");
43 b.append(Messages.getString("PROJECT_VERSION"));
44 b.append("\"/>\n");
45 b.append("<link rel=\"stylesheet\" href=\"");
46 b.append(HTML.escape(stylesheetURL));
47 b.append("\" type=\"text/css\"/>\n");
48 if (ConfigurationOptions.isEnableTwitterButton()) {
49 addTwitterScript(b);
50 }
51 b.append(" </head>\n\n<body>\n");
52
53 if (ConfigurationOptions.getHeaderUrl() != null) {
54 b.append(FileUtils.readTextFromURL(ConfigurationOptions.getHeaderUrl()));
55 }
56 return b.toString();
57 }
58
59 public String getEndOfPage() {
60 final StringBuffer b = new StringBuffer();
61 if (ConfigurationOptions.getFooterUrl() != null) {
62 b.append(FileUtils.readTextFromURL(ConfigurationOptions.getFooterUrl()));
63 }
64 b.append("</body>\n</html>");
65 return b.toString();
66 }
67
68 public String startSection1(final String title) {
69 return "\n<h1>" + title + "</h1>\n";
70 }
71
72 public String endSection1() {
73 return "";
74 }
75
76 public String startSection2(final String title) {
77 return "\n<div class=\"section\">\n<h2>" + title + "</h2>\n";
78 }
79
80 public String startSection2(final String title, final String id) {
81 return "\n<div id=\"" + HTML.escape(id) + "\" class=\"section\">\n<h2>" + title + "</h2>\n";
82 }
83
84 public String endSection2() {
85 return "</div>";
86 }
87
88 public String getTableFormat() {
89 return "";
90 }
91
92 public String toString() {
93 return "HTML";
94 }
95 }