ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/GoogleTron/Wiki.cpp
Revision: 714
Committed: 2006-03-27T01:56:17-08:00 (19 years, 2 months ago) by douglas
File size: 2166 byte(s)
Log Message:
Woo! Wiki worky!

File Contents

# Content
1 // Wiki
2 //
3 // Douglas Thrift
4 //
5 // $Id$
6
7 #include <cxx/standard.hh>
8
9 #include <api/files.hpp>
10 #include <api/pcre/regex.hpp>
11
12 #include "Wiki.hpp"
13
14 Wiki::Wiki(const cse::String &sitemap, const cse::String &base, ext::Queue<Url> &queue, api::ThreadMutex &queueLock, const _R<WikiCommand> &command) : CommandRunner(sitemap, queue, queueLock)
15 {
16 api::Cout << _B("Wiki") << ios::NewLine;
17
18 Entries(command->root, _S<ios::String>() << base << command->path);
19 }
20
21 void Wiki::Entries(const api::Path &directory, const cse::String &base)
22 {
23 cse::String wiki(client.GetProperty(_B("GoogleTron:Wiki"), directory.GetPath()));
24
25 if (wiki != _B("PmWiki"))
26 throw ext::NotImplementedException(wiki);
27
28 api::Path wikiDirectory(directory.GetChild(_B("wiki.d")));
29 ext::RedBlackSet<cse::String> excludes(GetProperties<ext::RedBlackSet<cse::String> >(_B("GoogleTron:Exclude"), wikiDirectory.GetPath()));
30 ext::RedBlackSet<cse::String> sections(GetProperties<ext::RedBlackSet<cse::String> >(_B("GoogleTron:Section"), wikiDirectory.GetPath()));
31 api::Pcre::RegEx wikiEntry(_B("^([^a-z].*)\\.([^a-z].*)$"));
32
33 _foreach (const _L<Subversion::Entry>, entry, client.GetEntries(wikiDirectory.GetPath()))
34 {
35 api::Pcre::RegEx::Match match;
36
37 if (!entry->GetName().StartsWith('.') && !excludes.Contains(entry->GetName()) && (match = wikiEntry(entry->GetName())) && sections.Contains(match[1]))
38 Entry(wikiDirectory.GetChild(entry->GetName()), base, *entry, match[1], match[2]);
39 }
40 }
41
42 void Wiki::Entry(const api::Path &file, const cse::String &base, const Subversion::Entry &entry, const cse::String &section, const cse::String &page)
43 {
44 std::time_t modified(entry.GetModified());
45
46 try
47 {
48 _S<api::FileReader> reader(file.GetPath());
49 ext::Buffer key, value;
50
51 while (key = ios::ReadUntil(reader, '='), ios::ReadLine(reader, value))
52 if (key == _B("time"))
53 {
54 modified = lexical_cast<std::time_t>(cse::String(value));
55
56 break;
57 }
58 }
59 catch (ext::EosException) {}
60
61 Url url(_S<ios::String>() << base << section << _B("/") << page, modified, always, GetPriority(client.GetProperty(_B("GoogleTron:Priority"), file.GetPath())));
62
63 _synchronized (queueLock)
64 queue.Push(url);
65 }

Properties

Name Value
svn:eol-style native
svn:keywords Id