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 202 by Douglas Thrift, 2004-08-30T23:18:58-07:00 vs.
Revision 207 by Douglas Thrift, 2004-09-02T00:09:24-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          ext::Handle<xml::Document> document(xml::Parse(adaptor));
19          ext::Handle<xml::Node> jargon(*document/"jargon");
20  
# Line 24 | Line 24 | Jargon::Jargon(const std::string& path)
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 >        pout << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
45 >                << "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
46 >
47 >        xml::TextWriter xhtml(pout);
48 >        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 sout;
196 >        return pout;
197   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines