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