5 |
|
// $Id$ |
6 |
|
|
7 |
|
#include "SiteMapper.hpp" |
8 |
< |
#include "Matcher.hpp" |
9 |
< |
#include "Page.hpp" |
8 |
> |
#include "Matcher/Matcher.hpp" |
9 |
|
|
10 |
|
#include <menes-api/exename.hpp> |
11 |
|
#include <menes-app/application.hpp> |
12 |
|
|
14 |
– |
ext::String program; |
15 |
– |
bool debug(false); |
16 |
– |
|
13 |
|
struct SiteMapperCommand : public app::Application |
14 |
|
{ |
15 |
|
virtual int Run(const app::ArgumentList& args) |
16 |
|
{ |
17 |
< |
program = api::GetExecutablePath().GetName(); |
17 |
> |
SiteMapper::program = api::GetExecutablePath().GetName(); |
18 |
|
|
19 |
|
ext::String siteIndex, siteMap; |
20 |
|
|
21 |
< |
_foreach (app::ArgumentList, arg, args) |
21 |
> |
_foreach (const app::ArgumentList, arg, args) |
22 |
|
{ |
23 |
|
Matcher matcher; |
24 |
|
|
32 |
|
} |
33 |
|
else if (*arg == "-D") |
34 |
|
{ |
35 |
< |
if (!debug) debug = true; |
35 |
> |
if (!SiteMapper::debug) SiteMapper::debug = true; |
36 |
|
} |
37 |
|
} |
38 |
|
|
42 |
|
} |
43 |
|
else |
44 |
|
{ |
45 |
< |
api::Cout << "Usage: " << program << " -index=index -map=map [-D]\n"; |
45 |
> |
api::Cout << "Usage: " << SiteMapper::program << " -index=index -map=map [-D]\n"; |
46 |
|
} |
47 |
|
|
48 |
|
return 0; |
56 |
|
newMap(siteMap); |
57 |
|
} |
58 |
|
|
59 |
+ |
ext::String SiteMapper::program; |
60 |
+ |
bool SiteMapper::debug(false); |
61 |
+ |
|
62 |
|
void SiteMapper::oldMap(const ext::String& siteMap) |
63 |
|
{ |
64 |
|
ext::Handle<xml::Document> document(xml::Parse(siteMap)); |
129 |
|
|
130 |
|
bool SiteMapper::newIndex(ext::Vector<Page>& pages, Page& page) |
131 |
|
{ |
132 |
< |
_mforeach (ext::Vector<Page>, page_, pages) |
132 |
> |
_foreach (ext::Vector<Page>, page_, pages) |
133 |
|
{ |
134 |
|
if (*page_ == page.getAddress()) |
135 |
|
{ |
177 |
|
|
178 |
|
xml::ScopeElement section(xml, "section"), list(xml, "list"); |
179 |
|
|
180 |
< |
_mforeach (ext::Vector<Page>, page, pages) |
180 |
> |
_foreach (ext::Vector<Page>, page, pages) |
181 |
|
{ |
182 |
|
if (newPages.find(page->getAddress()) != newPages.end()) newMap(page->getChildren(), page->getPath(), newPages.find(page->getAddress())->second); |
183 |
|
|
187 |
|
|
188 |
|
void SiteMapper::newMap(ext::Vector<Page>& pages, const ext::String& childOf, std::multimap<std::string, Page>& newPages) |
189 |
|
{ |
190 |
< |
_mforeach (ext::Vector<Page>, page, pages) newMap(page->getChildren(), page->getPath(), newPages); |
190 |
> |
_foreach (ext::Vector<Page>, page, pages) newMap(page->getChildren(), page->getPath(), newPages); |
191 |
|
|
192 |
|
typedef std::multimap<std::string, Page> MultiMap; |
193 |
|
|