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