1 |
Douglas Thrift |
196 |
// Feeping Creaturism |
2 |
|
|
// |
3 |
|
|
// Douglas Thrift |
4 |
|
|
// |
5 |
|
|
// $Id$ |
6 |
|
|
|
7 |
|
|
#include "Jargon.hpp" |
8 |
|
|
|
9 |
Douglas Thrift |
203 |
Jargon::Jargon(const ext::String& path, bool include) : include(include) |
10 |
Douglas Thrift |
196 |
{ |
11 |
Douglas Thrift |
201 |
std::vector<std::string> args(1, FeepingCreaturism::program); |
12 |
Douglas Thrift |
196 |
|
13 |
|
|
args.push_back(path); |
14 |
Douglas Thrift |
201 |
args.push_back("jargon.xsl"); |
15 |
Douglas Thrift |
196 |
|
16 |
|
|
redi::pstreambuf pin("/usr/local/bin/Xalan", args, std::ios_base::in); |
17 |
Douglas Thrift |
203 |
ios::FromStreamBuf adaptor(pin); |
18 |
Douglas Thrift |
208 |
|
19 |
Douglas Thrift |
196 |
ext::Handle<xml::Document> document(xml::Parse(adaptor)); |
20 |
Douglas Thrift |
202 |
ext::Handle<xml::Node> jargon(*document/"jargon"); |
21 |
Douglas Thrift |
196 |
|
22 |
Douglas Thrift |
202 |
word = *jargon/"word"; |
23 |
|
|
pronunciation = *jargon/"pronunciation"; |
24 |
|
|
grammar = *jargon/"grammar"; |
25 |
|
|
definition = *jargon/"definition"; |
26 |
Douglas Thrift |
196 |
} |
27 |
|
|
|
28 |
Douglas Thrift |
208 |
void Jargon::display(ios::PrintWriter& pout, xml::TextWriter& xhtml) const |
29 |
|
|
{ |
30 |
|
|
{ |
31 |
|
|
xml::ScopeElement p(xhtml, "p"); |
32 |
|
|
|
33 |
|
|
xhtml.OpenElement("strong"); |
34 |
|
|
xhtml.OutputText(word + ":"); |
35 |
|
|
xhtml.CloseElement(); |
36 |
|
|
xhtml.OutputText(" " + pronunciation); |
37 |
|
|
|
38 |
|
|
if (!grammar.IsEmpty()) xhtml.OutputText(", " + grammar); |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
for (xml::NodeSet::ConstIterator node(definition.Begin()); |
42 |
|
|
node != definition.End(); ++node) |
43 |
|
|
{ |
44 |
|
|
xml::ScopeElement p(xhtml, "p"); |
45 |
|
|
|
46 |
|
|
xhtml.OutputText(**node/"p"); |
47 |
|
|
} |
48 |
|
|
} |
49 |
|
|
|
50 |
Douglas Thrift |
203 |
struct Section |
51 |
Douglas Thrift |
196 |
{ |
52 |
Douglas Thrift |
203 |
Section(const ext::String& name, const ext::String& path, |
53 |
|
|
const ext::String& subdomain = "www") : name(name), url("http://" |
54 |
|
|
+ subdomain + ".douglasthrift.net" + path) {} |
55 |
|
|
ext::String name, url; |
56 |
|
|
}; |
57 |
Douglas Thrift |
196 |
|
58 |
Douglas Thrift |
203 |
ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon) |
59 |
|
|
{ |
60 |
|
|
if (jargon.include) |
61 |
|
|
{ |
62 |
Douglas Thrift |
208 |
xml::TextWriter xhtml(pout); |
63 |
Douglas Thrift |
196 |
|
64 |
Douglas Thrift |
208 |
jargon.display(pout, xhtml); |
65 |
|
|
|
66 |
Douglas Thrift |
203 |
return pout; |
67 |
|
|
} |
68 |
Douglas Thrift |
196 |
|
69 |
Douglas Thrift |
207 |
pout << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n" |
70 |
Douglas Thrift |
203 |
<< "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n"; |
71 |
|
|
|
72 |
Douglas Thrift |
207 |
xml::TextWriter xhtml(pout); |
73 |
Douglas Thrift |
203 |
xml::ScopeElement html(xhtml, "html"); |
74 |
|
|
|
75 |
|
|
xhtml.SetAttribute("xmlns", "http://www.w3.org/1999/xhtml"); |
76 |
|
|
|
77 |
|
|
{ |
78 |
|
|
xml::ScopeElement head(xhtml, "head"); |
79 |
|
|
|
80 |
|
|
xhtml.OpenElement("title"); |
81 |
Douglas Thrift |
208 |
xhtml.OutputText("Douglas Thrift"); |
82 |
|
|
|
83 |
|
|
pout << "'"; |
84 |
|
|
|
85 |
|
|
xhtml.OutputText("s Computers Website | Jargon: " + jargon.word); |
86 |
Douglas Thrift |
203 |
xhtml.CloseElement(); |
87 |
|
|
xhtml.OpenElement("link"); |
88 |
|
|
xhtml.SetAttribute("rel", "stylesheet"); |
89 |
|
|
xhtml.SetAttribute("href", "../../stylesheets/regular.css"); |
90 |
|
|
xhtml.SetAttribute("type", "text/css"); |
91 |
|
|
xhtml.CloseElement(); |
92 |
|
|
xhtml.OpenElement("link"); |
93 |
|
|
xhtml.SetAttribute("rel", "Icon"); |
94 |
|
|
xhtml.SetAttribute("href", "../../favicon.ico"); |
95 |
|
|
xhtml.SetAttribute("type", "image/ico"); |
96 |
|
|
xhtml.CloseElement(); |
97 |
|
|
xhtml.OpenElement("script"); |
98 |
|
|
xhtml.SetAttribute("src", "../../nav/functions.js"); |
99 |
|
|
xhtml.SetAttribute("type", "text/javascript"); |
100 |
|
|
xhtml.OutputText(""); |
101 |
|
|
xhtml.CloseElement(); |
102 |
|
|
} |
103 |
|
|
|
104 |
|
|
{ |
105 |
|
|
xml::ScopeElement body(xhtml, "body"); |
106 |
|
|
|
107 |
|
|
{ |
108 |
|
|
xml::ScopeElement div(xhtml, "div"); |
109 |
|
|
|
110 |
|
|
xhtml.OpenElement("p"); |
111 |
|
|
xhtml.SetAttribute("class", "center"); |
112 |
|
|
xhtml.OpenElement("a"); |
113 |
|
|
xhtml.SetAttribute("href", Section("", "/", "computers").url); |
114 |
|
|
xhtml.OpenElement("img"); |
115 |
|
|
xhtml.SetAttribute("src", "../../masthead.png"); |
116 |
|
|
xhtml.SetAttribute("alt", "Douglas Thrift's Computers Website"); |
117 |
|
|
xhtml.SetAttribute("title", "Douglas Thrift's Computers Website"); |
118 |
|
|
xhtml.CloseElement(); |
119 |
|
|
xhtml.CloseElement(); |
120 |
|
|
xhtml.CloseElement(); |
121 |
|
|
xhtml.OpenElement("p"); |
122 |
|
|
xhtml.SetAttribute("class", "center nav"); |
123 |
|
|
|
124 |
|
|
std::vector<Section> sections; |
125 |
|
|
|
126 |
|
|
sections.push_back(Section("Home", "/")); |
127 |
|
|
sections.push_back(Section("Blog", "/blog/")); |
128 |
|
|
sections.push_back(Section("Computers", "/", "computers")); |
129 |
|
|
sections.push_back(Section("Movies", "/", "movies")); |
130 |
|
|
sections.push_back(Section("Music", "/", "music")); |
131 |
|
|
sections.push_back(Section("TV Shows", "/", "tvshows")); |
132 |
|
|
sections.push_back(Section("Sitemap", "/sitemap.xml")); |
133 |
|
|
sections.push_back(Section("Contact", "/contact.php")); |
134 |
|
|
sections.push_back(Section("Linking", "/linking.xml")); |
135 |
|
|
sections.push_back(Section("Search", "/search.cgi")); |
136 |
|
|
|
137 |
|
|
for (std::vector<Section>::size_type index(0); |
138 |
|
|
index < sections.size(); ++index) |
139 |
|
|
{ |
140 |
|
|
if (index > 0) xhtml.OutputText(" | "); |
141 |
|
|
|
142 |
|
|
xhtml.OpenElement("a"); |
143 |
|
|
xhtml.SetAttribute("href", sections[index].url); |
144 |
|
|
|
145 |
|
|
if (index != 2) |
146 |
|
|
{ |
147 |
|
|
xhtml.SetAttribute("onmouseout", "deselect(" |
148 |
|
|
+ lexical_cast<ext::String>(index + 1) + ")"); |
149 |
|
|
xhtml.SetAttribute("onmouseover", "select(" |
150 |
|
|
+ lexical_cast<ext::String>(index + 1) + ")"); |
151 |
|
|
xhtml.SetAttribute("class", "nav"); |
152 |
|
|
} |
153 |
|
|
else xhtml.SetAttribute("class", "nav select"); |
154 |
|
|
|
155 |
|
|
xhtml.OutputText(sections[index].name); |
156 |
|
|
xhtml.CloseElement(); |
157 |
|
|
} |
158 |
|
|
|
159 |
|
|
xhtml.CloseElement(); |
160 |
|
|
} |
161 |
|
|
|
162 |
|
|
{ |
163 |
|
|
xml::ScopeElement div(xhtml, "div"); |
164 |
|
|
|
165 |
|
|
xhtml.SetAttribute("class", "hr"); |
166 |
|
|
xhtml.OpenElement("h1"); |
167 |
|
|
xhtml.SetAttribute("id", "title"); |
168 |
|
|
xhtml.SetAttribute("class", "center"); |
169 |
Douglas Thrift |
208 |
xhtml.OutputText("Jargon: " + jargon.word); |
170 |
Douglas Thrift |
203 |
xhtml.CloseElement(); |
171 |
|
|
} |
172 |
|
|
|
173 |
|
|
{ |
174 |
|
|
xml::ScopeElement div(xhtml, "div"); |
175 |
|
|
|
176 |
|
|
xhtml.SetAttribute("class", "hr"); |
177 |
Douglas Thrift |
208 |
jargon.display(pout, xhtml); |
178 |
Douglas Thrift |
203 |
} |
179 |
|
|
|
180 |
|
|
{ |
181 |
|
|
xml::ScopeElement div(xhtml, "div"); |
182 |
|
|
|
183 |
|
|
xhtml.SetAttribute("class", "hr"); |
184 |
|
|
xhtml.OpenElement("p"); |
185 |
|
|
xhtml.SetAttribute("class", "center"); |
186 |
|
|
xhtml.OutputText("Copyright "); pout << "©"; // XXX hmm? |
187 |
|
|
xhtml.OutputText(" 2002-2004, "); |
188 |
|
|
xhtml.OpenElement("a"); |
189 |
|
|
xhtml.SetAttribute("href", Section("", "/contact.php").url); |
190 |
|
|
xhtml.OutputText("Douglas Thrift"); |
191 |
|
|
xhtml.CloseElement(); |
192 |
|
|
xhtml.OutputText(". All Rights Reserved."); |
193 |
|
|
xhtml.CloseElement(); |
194 |
|
|
xhtml.OpenElement("p"); |
195 |
|
|
xhtml.SetAttribute("class", "center"); |
196 |
|
|
xhtml.OutputText(""); |
197 |
|
|
|
198 |
|
|
pout << "<a href=\"http://validator.w3.org/check/referer\">"; |
199 |
|
|
|
200 |
|
|
{ |
201 |
|
|
xml::ScopeElement img(xhtml, "img"); |
202 |
|
|
|
203 |
|
|
xhtml.SetAttribute("src", "../../w3c_images/vxh10.png"); |
204 |
|
|
xhtml.SetAttribute("alt", "Valid XHTML 1.0!"); |
205 |
|
|
xhtml.SetAttribute("title", "Valid XHTML 1.0!"); |
206 |
|
|
} |
207 |
|
|
|
208 |
|
|
pout << "</a> <a href=\"http://jigsaw.w3.org/css-validator/check" |
209 |
|
|
<< "/referer\">"; |
210 |
|
|
|
211 |
|
|
{ |
212 |
|
|
xml::ScopeElement img(xhtml, "img"); |
213 |
|
|
|
214 |
|
|
xhtml.SetAttribute("src", "../../w3c_images/vcss.png"); |
215 |
|
|
xhtml.SetAttribute("alt", "Valid CSS!"); |
216 |
|
|
xhtml.SetAttribute("title", "Valid CSS!"); |
217 |
|
|
} |
218 |
|
|
|
219 |
|
|
pout << "</a>"; |
220 |
|
|
|
221 |
|
|
xhtml.CloseElement(); |
222 |
|
|
} |
223 |
|
|
} |
224 |
|
|
|
225 |
|
|
return pout; |
226 |
Douglas Thrift |
196 |
} |