ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Atom.cpp
Revision: 39
Committed: 2004-07-23T17:52:53-07:00 (20 years, 11 months ago) by douglas
File size: 2337 byte(s)
Log Message:
Watch out for feeping creaturism!

File Contents

# User Rev Content
1 douglas 35 // Zoe AIM Away Message RSS Feed Generator
2     //
3     // Seth King and Douglas Thrift
4     //
5     // $Id$
6    
7     #include "Atom.hpp"
8    
9     Atom::Atom(const Buddy& buddy, const std::vector<AwayMessage>& messages, const Stamp& stamp)
10     {
11     api::FileOutputStream fout(buddy.getAtom() != "-" ? buddy.getAtom() : "/dev/null");
12     xml::TextWriter atom(buddy.getAtom() != "-" ? fout : api::Cout.GetStream());
13     xml::ScopeElement feed(atom, "feed");
14    
15     atom.SetAttribute("version", "0.3");
16 douglas 36 atom.SetAttribute("xmlns", "http://purl.org/atom/ns#");
17 douglas 35 atom.OpenElement("title");
18     atom.SetAttribute("mode", "escaped");
19     atom.OutputText(ext::String(buddy) + "'s Away Messages");
20     atom.CloseElement();
21     atom.OpenElement("link");
22     atom.SetAttribute("rel", "alternate");
23 douglas 39 atom.SetAttribute("type", "text/html");
24     atom.SetAttribute("href", buddy.getLink());
25 douglas 35 atom.CloseElement();
26     atom.OpenElement("author");
27     atom.OpenElement("name");
28     atom.OutputText(buddy);
29     atom.CloseElement();
30     atom.CloseElement();
31     atom.OpenElement("tagline");
32     atom.SetAttribute("mode", "escaped");
33 douglas 39 atom.OutputText(ext::String(buddy) + "'s AIM Away Messages from the past 30"
34     " days.");
35 douglas 35 atom.CloseElement();
36     atom.OpenElement("generator");
37 douglas 36 atom.SetAttribute("url", Zoe::generator(Zoe::url));
38     atom.SetAttribute("version", Zoe::generator(Zoe::version));
39     atom.OutputText(Zoe::generator(Zoe::agent));
40 douglas 35 atom.CloseElement();
41 douglas 36 atom.OpenElement("modified");
42     atom.OutputText(stamp.getW3());
43     atom.CloseElement();
44    
45     for (std::vector<AwayMessage>::const_iterator message(messages.begin());
46     message != messages.end(); ++message)
47     {
48     xml::ScopeElement entry(atom, "entry");
49    
50     atom.OpenElement("title");
51     atom.CloseElement();
52     atom.OpenElement("link");
53     atom.SetAttribute("rel", "alternate");
54 douglas 39 atom.SetAttribute("type", "text/html");
55     atom.SetAttribute("href", buddy.getLink());
56 douglas 36 atom.CloseElement();
57     atom.OpenElement("id");
58 douglas 39 atom.OutputText("zoe:" + ext::String(buddy) + ":"
59     + message->getStamp().getW3());
60 douglas 36 atom.CloseElement();
61     atom.OpenElement("modified");
62     atom.OutputText(message->getStamp().getW3());
63     atom.CloseElement();
64     atom.OpenElement("issued");
65     atom.OutputText(message->getStamp().getW3());
66     atom.CloseElement();
67     atom.OpenElement("content");
68     atom.SetAttribute("type", "text/html");
69     atom.SetAttribute("mode", "escaped");
70     atom.OutputText(*message);
71     atom.CloseElement();
72     }
73 douglas 35 }

Properties

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