forked from sr/atom-tools
-
Notifications
You must be signed in to change notification settings - Fork 4
ExampleCode
bct edited this page Sep 13, 2010
·
3 revisions
Building entries and feeds is simple:
#!ruby
require "atom/feed"
e = Atom::Entry.new
e.title = "a new entry"
e.content = "some <em>boring</em> HTML"
e.content.type = "html"
e.categories.new :term => "Test Entry"
feed = Atom::Feed.new
feed << e
feed.to_s
# => "<feed xmlns='http://www.w3.org/2005/Atom'><entry><title>a new entry</title><content type='html'>some <em>boring</em> HTML</content><category term='Test Entry'/></entry></feed>"
atom-tools won’t complain if you’ve forgotten to include all the bits you need, so you should run the final product through the Feed Validator before you publish.
#!ruby
require "atom/feed"
f = Atom::Feed.new("http://www.tbray.org/ongoing/ongoing.atom")
f.entries
# => []
f.update!
f.entries
# => [#<Atom::Entry>, ...]
f.entries.first.title.to_s
# => "Tag Scheme?"
- Simon Rozet has written several simple Atom Publishing Protocol servers
- atom-tools/bin/atom-cp — an Atom Publishing Protocol client that can copy entries from one feed to another
- VoxApi — faking the Atom API
- HtmlToXhtml — convert @type=‘html’ to @type=‘xhtml’