ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/FeepingCreaturism/Jargon.cpp
Revision: 207
Committed: 2004-09-02T00:09:24-07:00 (20 years, 9 months ago) by Douglas Thrift
File size: 5481 byte(s)
Log Message:
Put doctype earlier to make IE happy. Now why the hell would I want to do that?!

File Contents

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

Properties

Name Value
svn:eol-style native
svn:keywords Id