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 207 by Douglas Thrift, 2004-09-02T00:09:24-07:00 vs.
Revision 265 by Douglas Thrift, 2004-10-27T01:50:34-07:00

# Line 5 | Line 5
5   // $Id$
6  
7   #include "Jargon.hpp"
8 + #include "Matcher.hpp"
9  
10 < Jargon::Jargon(const ext::String& path, bool include) : include(include)
10 > Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include,
11 >        const ext::String& relative) : include(include), args(1, "jargon.xsl")
12   {
13 <        std::vector<std::string> args(1, FeepingCreaturism::program);
13 >        args.InsertLast(ios::String() << path << "/" << jargon);
14 >        args.InsertLast(ios::String() << "$jargon=" << jargon);
15  
16 <        args.push_back(path);
14 <        args.push_back("jargon.xsl");
16 >        if (include) args.InsertLast("$include=true()");
17  
18 <        redi::pstreambuf pin("/usr/local/bin/Xalan", args, std::ios_base::in);
19 <        ios::FromStreamBuf adaptor(pin);
20 <        ext::Handle<xml::Document> document(xml::Parse(adaptor));
21 <        ext::Handle<xml::Node> jargon(*document/"jargon");
20 <
21 <        word = *jargon/"word";
22 <        pronunciation = *jargon/"pronunciation";
23 <        grammar = *jargon/"grammar";
24 <        definition = *jargon/"definition";
18 >        if (!relative.IsEmpty())
19 >        {
20 >                args.InsertLast(ios::String() << "$relative=" << relative);
21 >        }
22   }
23  
27 struct Section
28 {
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
24   ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
25   {
26 <        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");
26 >        _S<api::Process> xslt("/usr/local/bin/sabcmd", jargon.args);
27  
28 <        xhtml.SetAttribute("xmlns", "http://www.w3.org/1999/xhtml");
28 >        if (jargon.include) ios::ReadLine(*xslt.GetReader());
29  
30 <        {
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 <        }
30 >        ios::ReadToWrite(*xslt.GetReader(), pout);
31  
32          return pout;
33   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines