// Zoe AIM Away Message RSS Feed Generator // // Seth King and Douglas Thrift // // $Id$ #ifndef _Atom_hpp_ #define _Atom_hpp_ #include "AwayMessage.hpp" struct Atom { template Atom(const Buddy& buddy, const ext::String& display, const Iterator& messagesBegin, const Iterator& messagesEnd, const Stamp& stamp); }; template Atom::Atom(const Buddy& buddy, const ext::String& display, const Iterator& messagesBegin, const Iterator& messagesEnd, const Stamp& stamp) { api::FileWriter fout(buddy.getAtom() != "-" ? buddy.getAtom() : "/dev/null"); xml::TextWriter atom(buddy.getAtom() != "-" ? fout : api::Cout.GetStream()); xml::ScopeElement feed(atom, "feed"); atom.SetAttribute("version", "0.3"); atom.SetAttribute("xmlns", "http://purl.org/atom/ns#"); atom.OpenElement("title"); atom.SetAttribute("mode", "escaped"); atom.OutputText(display + "'s Away Messages"); atom.CloseElement(); atom.OpenElement("link"); atom.SetAttribute("rel", "alternate"); atom.SetAttribute("type", "text/html"); atom.SetAttribute("href", buddy.getLink()); atom.CloseElement(); atom.OpenElement("link"); atom.SetAttribute("rel", "alternate"); atom.SetAttribute("type", "application/rss+xml"); atom.SetAttribute("href", buddy.getRssLink()); atom.CloseElement(); atom.OpenElement("author"); atom.OpenElement("name"); atom.OutputText(buddy); atom.CloseElement(); atom.CloseElement(); atom.OpenElement("tagline"); atom.SetAttribute("mode", "escaped"); atom.OutputText(display + "'s AIM Away Messages from the past 30 days."); atom.CloseElement(); atom.OpenElement("generator"); atom.SetAttribute("url", Zoe::generator(Zoe::url)); atom.SetAttribute("version", Zoe::generator(Zoe::version)); atom.OutputText(Zoe::generator(Zoe::agent)); atom.CloseElement(); atom.OpenElement("modified"); atom.OutputText(stamp.getW3()); atom.CloseElement(); for (Iterator message(messagesBegin); message != messagesEnd; ++message) { xml::ScopeElement entry(atom, "entry"); atom.OpenElement("title"); atom.CloseElement(); atom.OpenElement("link"); atom.SetAttribute("rel", "alternate"); atom.SetAttribute("type", "text/html"); atom.SetAttribute("href", message->getLink(buddy)); atom.CloseElement(); atom.OpenElement("id"); atom.OutputText(message->getTag(buddy)); atom.CloseElement(); atom.OpenElement("modified"); atom.OutputText(message->getStamp().getW3()); atom.CloseElement(); atom.OpenElement("issued"); atom.OutputText(message->getStamp().getW3()); atom.CloseElement(); atom.OpenElement("content"); atom.SetAttribute("type", "text/html"); atom.SetAttribute("mode", "escaped"); atom.OutputText(*message); atom.CloseElement(); } } #endif // _Atom_hpp_