13 |
|
#include "Page.hpp" |
14 |
|
|
15 |
|
string program; |
16 |
< |
bool debug = false; |
16 |
> |
bool debug(false); |
17 |
|
|
18 |
|
int main(int argc, char* argv[]) |
19 |
|
{ |
21 |
|
|
22 |
|
string siteIndex, siteMap; |
23 |
|
|
24 |
< |
for (int index = 1; index < argc; index++) |
24 |
> |
for (int index(1); index < argc; index++) |
25 |
|
{ |
26 |
|
string arg(argv[index]); |
27 |
|
Matcher matcher; |
40 |
|
} |
41 |
|
} |
42 |
|
|
43 |
< |
if (siteIndex != "" && siteMap != "") |
43 |
> |
if (!siteIndex.empty() && !siteMap.empty()) |
44 |
|
{ |
45 |
|
XMLPlatformUtils::Initialize(); |
46 |
|
XPathEvaluator::initialize(); |
81 |
|
|
82 |
|
if (list == 0) return; |
83 |
|
|
84 |
+ |
comment << evaluator.evaluate(support, document, |
85 |
+ |
XalanDOMString("comment()").c_str())->str(); |
86 |
+ |
|
87 |
|
item = evaluator.createXPath(XalanDOMString("item").c_str()); |
88 |
|
address = evaluator.createXPath(XalanDOMString("link/@address").c_str()); |
89 |
|
link = evaluator.createXPath(XalanDOMString("link").c_str()); |
101 |
|
{ |
102 |
|
NodeRefList nodes = evaluator.selectNodeList(support, list, *item); |
103 |
|
|
104 |
< |
for (int index = 0; index < nodes.getLength(); index++) |
104 |
> |
for (int index(0); index < nodes.getLength(); ++index) |
105 |
|
{ |
106 |
|
XalanNode* node = nodes.item(index); |
107 |
|
ostringstream url, title; |
136 |
|
NodeRefList nodes = evaluator.selectNodeList(support, document, |
137 |
|
XalanDOMString("/index/page").c_str()); |
138 |
|
|
139 |
< |
for (int index = 0; index < nodes.getLength(); index++) |
139 |
> |
for (int index(0); index < nodes.getLength(); ++index) |
140 |
|
{ |
141 |
|
XalanNode* node = nodes.item(index); |
142 |
|
ostringstream address; |
161 |
|
if (page == matcher(string("^Douglas\\sThrift's\\sWebsite\\s\\|\\sDou") |
162 |
|
+ "glas\\sThrift's\\sBlog:\\s(.+)$")) |
163 |
|
{ |
164 |
< |
if (Matcher("^\\w+\\s\\d\\d\\d\\d\\sArchives$") == matcher[1]) |
164 |
> |
if (Matcher("^\\w+\\s\\d{4}\\sArchives$") == matcher[1]) |
165 |
|
{ |
166 |
|
page.setTitle(matcher[1]); |
167 |
|
|
192 |
|
|
193 |
|
bool SiteMapper::newIndex(vector<Page>& pages, Page& page) |
194 |
|
{ |
195 |
< |
for (unsigned index = 0; index < pages.size(); index++) |
195 |
> |
for (unsigned index(0); index < pages.size(); ++index) |
196 |
|
{ |
197 |
|
if (pages[index] == page.getAddress()) |
198 |
|
{ |
204 |
|
|
205 |
|
pages[index] = page; |
206 |
|
|
207 |
+ |
cout << "Updated: " << page.getUrl() << '\n'; |
208 |
+ |
|
209 |
|
return true; |
210 |
|
} |
211 |
|
else if (matcher('^' + pages[index].getPath()) == page) |
234 |
|
<< "<?xml-stylesheet type=\"text/xsl\" href=\"stylesheets/sitemap.xsl" |
235 |
|
<< "\"?>\n" |
236 |
|
<< "<!DOCTYPE page SYSTEM \"stylesheets/page.dtd\">\n" |
237 |
< |
<< "<!-- /sitemap.xml -->\n" |
237 |
> |
<< "<!--" << comment.str() << "-->\n" |
238 |
|
<< "<page>\n" |
239 |
|
<< "\t<title>Sitemap</title>\n" |
240 |
|
<< "\t<section>\n" |
241 |
|
<< "\t\t<list>\n"; |
242 |
|
|
243 |
< |
for (unsigned index = 0; index < pages.size(); index++) |
243 |
> |
for (unsigned index(0); index < pages.size(); ++index) |
244 |
|
{ |
245 |
|
if (newPages.find(pages[index].getAddress()) != newPages.end()) |
246 |
|
{ |
261 |
|
void SiteMapper::newMap(vector<Page>& pages, const string& childOf, |
262 |
|
multimap<string, Page>& newPages) |
263 |
|
{ |
264 |
< |
for (unsigned index = 0; index < pages.size(); index++) |
264 |
> |
for (unsigned index(0); index < pages.size(); ++index) |
265 |
|
{ |
266 |
|
newMap(pages[index].getChildren(), pages[index].getPath(), newPages); |
267 |
|
} |
268 |
|
|
269 |
< |
for (multimap<string, Page>::iterator itor = newPages.lower_bound(childOf); |
269 |
> |
for (multimap<string, Page>::iterator itor(newPages.lower_bound(childOf)); |
270 |
|
itor != newPages.upper_bound(childOf); itor++) |
271 |
|
{ |
272 |
+ |
cout << "Added: " << itor->second.getUrl() << '\n'; |
273 |
+ |
|
274 |
|
pages.push_back(itor->second); |
275 |
|
} |
276 |
|
|