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 201 by Douglas Thrift, 2004-08-30T19:24:40-07:00 vs.
Revision 208 by Douglas Thrift, 2004-09-02T03:31:43-07:00

# Line 6 | Line 6
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  
# Line 14 | Line 14 | Jargon::Jargon(const std::string& path)
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 >        
19          ext::Handle<xml::Document> document(xml::Parse(adaptor));
20 <        ext::Handle<xml::Node> jargon(*document/"Jargon");
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";
22 >        word = *jargon/"word";
23 >        pronunciation = *jargon/"pronunciation";
24 >        grammar = *jargon/"grammar";
25 >        definition = *jargon/"definition";
26   }
27  
28 < std::ostream& operator<<(std::ostream& sout, const Jargon& jargon)
28 > void Jargon::display(ios::PrintWriter& pout, xml::TextWriter& xhtml) const
29   {
30 <        ios::StreamBufOutputAdapter adaptor(*sout.rdbuf());
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 <        sout << jargon.word << '\n' << jargon.pronunciation << '\n'
47 <                << jargon.grammar << '\n' << jargon.definition.GetSize() << '\n';
46 >                xhtml.OutputText(**node/"p");
47 >        }
48 > }
49  
50 < /*      ios::PrintWriter writer(adaptor);
50 > struct Section
51 > {
52 >        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  
58 <        writer << jargon.definition << '\n';*/
58 > ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
59 > {
60 >        if (jargon.include)
61 >        {
62 >                xml::TextWriter xhtml(pout);
63 >
64 >                jargon.display(pout, xhtml);
65 >
66 >                return pout;
67 >        }
68 >
69 >        pout << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
70 >                << "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
71 >
72 >        xml::TextWriter xhtml(pout);
73 >        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 >                xhtml.OutputText("Douglas Thrift");
82 >
83 >                pout << "'";
84 >
85 >                xhtml.OutputText("s Computers Website | Jargon: " + jargon.word);
86 >                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 >                        xhtml.OutputText("Jargon: " + jargon.word);
170 >                        xhtml.CloseElement();
171 >                }
172 >
173 >                {
174 >                        xml::ScopeElement div(xhtml, "div");
175 >
176 >                        xhtml.SetAttribute("class", "hr");
177 >                        jargon.display(pout, xhtml);
178 >                }
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 << "&copy;"; // 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 sout;
225 >        return pout;
226   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines