ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/FeepingCreaturism/Jargon.cpp
(Generate patch)

Comparing FeepingCreaturism/Jargon.cpp (file contents):
Revision 222 by Douglas Thrift, 2004-09-05T22:52:35-07:00 vs.
Revision 223 by Douglas Thrift, 2004-09-06T01:58:43-07:00

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines