// Wiki // // Douglas Thrift // // $Id$ #include #include #include #include "Wiki.hpp" Wiki::Wiki(const cse::String &sitemap, const cse::String &base, ext::Queue &queue, api::ThreadMutex &queueLock, const _R &command) : CommandRunner(sitemap, queue, queueLock) { api::Cout << _B("Wiki") << ios::NewLine; Entries(command->root, _S() << base << command->path); } void Wiki::Entries(const api::Path &directory, const cse::String &base) { cse::String wiki(client.GetProperty(_B("GoogleTron:Wiki"), directory.GetPath())); if (wiki != _B("PmWiki")) throw ext::NotImplementedException(wiki); api::Path wikiDirectory(directory.GetChild(_B("wiki.d"))); ext::RedBlackSet excludes(GetProperties >(_B("GoogleTron:Exclude"), wikiDirectory.GetPath())); ext::RedBlackSet sections(GetProperties >(_B("GoogleTron:Section"), wikiDirectory.GetPath())); api::Pcre::RegEx wikiEntry(_B("^([^a-z].*)\\.([^a-z].*)$")); _foreach (const _L, entry, client.GetEntries(wikiDirectory.GetPath())) { api::Pcre::RegEx::Match match; if (!entry->GetName().StartsWith('.') && !excludes.Contains(entry->GetName()) && (match = wikiEntry(entry->GetName())) && sections.Contains(match[1])) Entry(wikiDirectory.GetChild(entry->GetName()), base, *entry, match[1], match[2]); } } void Wiki::Entry(const api::Path &file, const cse::String &base, const Subversion::Entry &entry, const cse::String §ion, const cse::String &page) { std::time_t modified(entry.GetModified()); try { _S reader(file.GetPath()); ext::Buffer key, value; while (key = ios::ReadUntil(reader, '='), ios::ReadLine(reader, value)) if (key == _B("time")) { modified = lexical_cast(cse::String(value)); break; } } catch (ext::EosException) {} Url url(_S() << base << section << _B("/") << page, modified, always, GetPriority(client.GetProperty(_B("GoogleTron:Priority"), file.GetPath()))); _synchronized (queueLock) queue.Push(url); }