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 256 by Douglas Thrift, 2004-09-17T16:37:49-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 < {
11 <        std::vector<std::string> args(1, FeepingCreaturism::program);
12 <
13 <        args.push_back(path);
14 <        args.push_back("jargon.xsl");
10 > #include <menes-ios/stdadapters.hpp>
11  
12 <        redi::pstreambuf pin("/usr/local/bin/Xalan", args, std::ios_base::in);
13 <        ios::FromStreamBuf adaptor(pin);
14 <        ext::Handle<xml::Document> document(xml::Parse(adaptor));
19 <        ext::Handle<xml::Node> jargon(*document/"jargon");
20 <
21 <        word = *jargon/"word";
22 <        pronunciation = *jargon/"pronunciation";
23 <        grammar = *jargon/"grammar";
24 <        definition = *jargon/"definition";
25 < }
26 <
27 < struct Section
12 > Jargon::Jargon(const ext::String& path, const ext::String& jargon, bool include,
13 >        const ext::String& relative) : include(include),
14 >        args(1, FeepingCreaturism::program)
15   {
16 <        Section(const ext::String& name, const ext::String& path,
17 <                const ext::String& subdomain = "www") : name(name), url("http://"
18 <                + subdomain + ".douglasthrift.net" + path) {}
19 <        ext::String name, url;
20 < };
16 >        args.push_back("-m");
17 >        args.push_back("-p");
18 >        args.push_back("jargon");
19 >        args.push_back("\"" + jargon + "\"");
20 >        args.push_back("-p");
21 >        args.push_back("include");
22 >        args.push_back(lexical_cast<ext::String>(include) + "()");
23  
24 < ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
36 < {
37 <        if (jargon.include)
24 >        if (!relative.IsEmpty())
25          {
26 <                //
27 <
28 <                return pout;
26 >                args.push_back("-p");
27 >                args.push_back("relative");
28 >                args.push_back("\"" + relative + "\"");
29          }
30  
31 <        pout << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n"
32 <                << "\t\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
33 <
47 <        xml::TextWriter xhtml(pout);
48 <        xml::ScopeElement html(xhtml, "html");
31 >        args.push_back(path + "/" + jargon);
32 >        args.push_back("jargon.xsl");
33 > }
34  
35 <        xhtml.SetAttribute("xmlns", "http://www.w3.org/1999/xhtml");
35 > ios::PrintWriter& operator<<(ios::PrintWriter& pout, const Jargon& jargon)
36 > {
37 >        redi::ipstream pin("/usr/local/bin/Xalan", jargon.args);
38  
39 +        if (jargon.include)
40          {
41 <                xml::ScopeElement head(xhtml, "head");
41 >                std::string ignore;
42  
43 <                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();
43 >                std::getline(pin, ignore);
44          }
45  
46 +        do
47          {
48 <                xml::ScopeElement body(xhtml, "body");
78 <                
79 <                {
80 <                        xml::ScopeElement div(xhtml, "div");
48 >                std::string line;
49  
50 <                        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 <                }
50 >                std::getline(pin, line);
51  
52 +                while (jargon.include && line.find(" xmlns=") != std::string::npos)
53                  {
54 <                        xml::ScopeElement div(xhtml, "div");
54 >                        std::string::size_type position(line.find(" xmlns="));
55  
56 <                        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();
56 >                        line.replace(position, 37, "");
57                  }
58  
59 <                {
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 <                }
59 >                pout << line << "\n";
60          }
61 +        while (pin.good());
62  
63          return pout;
64   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines