ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/zoe/trunk/Atom.cpp
Revision: 46
Committed: 2004-08-16T18:52:59-07:00 (20 years, 10 months ago) by douglas
File size: 2489 byte(s)
Log Message:
Made some drastic changes! Maybe not so drastic.

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 douglas 46 atom.OpenElement("link");
27     atom.SetAttribute("rel", "alternate");
28     atom.SetAttribute("type", "application/rss+xml");
29     atom.SetAttribute("href", buddy.getRssLink());
30     atom.CloseElement();
31 douglas 35 atom.OpenElement("author");
32     atom.OpenElement("name");
33     atom.OutputText(buddy);
34     atom.CloseElement();
35     atom.CloseElement();
36     atom.OpenElement("tagline");
37     atom.SetAttribute("mode", "escaped");
38 douglas 39 atom.OutputText(ext::String(buddy) + "'s AIM Away Messages from the past 30"
39     " days.");
40 douglas 35 atom.CloseElement();
41     atom.OpenElement("generator");
42 douglas 36 atom.SetAttribute("url", Zoe::generator(Zoe::url));
43     atom.SetAttribute("version", Zoe::generator(Zoe::version));
44     atom.OutputText(Zoe::generator(Zoe::agent));
45 douglas 35 atom.CloseElement();
46 douglas 36 atom.OpenElement("modified");
47     atom.OutputText(stamp.getW3());
48     atom.CloseElement();
49    
50     for (std::vector<AwayMessage>::const_iterator message(messages.begin());
51     message != messages.end(); ++message)
52     {
53     xml::ScopeElement entry(atom, "entry");
54    
55     atom.OpenElement("title");
56     atom.CloseElement();
57     atom.OpenElement("link");
58     atom.SetAttribute("rel", "alternate");
59 douglas 39 atom.SetAttribute("type", "text/html");
60 douglas 46 atom.SetAttribute("href", message->getLink(buddy));
61 douglas 36 atom.CloseElement();
62     atom.OpenElement("id");
63 douglas 46 atom.OutputText(message->getTag(buddy));
64 douglas 36 atom.CloseElement();
65     atom.OpenElement("modified");
66     atom.OutputText(message->getStamp().getW3());
67     atom.CloseElement();
68     atom.OpenElement("issued");
69     atom.OutputText(message->getStamp().getW3());
70     atom.CloseElement();
71     atom.OpenElement("content");
72     atom.SetAttribute("type", "text/html");
73     atom.SetAttribute("mode", "escaped");
74     atom.OutputText(*message);
75     atom.CloseElement();
76     }
77 douglas 35 }

Properties

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