Building Applications with RSS, Atom, and the Atom API Ben Hammersley 1
Jan 14, 2015
Building Applications with RSS, Atom, and the Atom API
Ben Hammersley
1
Today’s topics•Atom and RSS in the structure of the web
•The Philosophy behind Atom•The Atom Document model and syntax
•The architecture of the Atom API
•Elemental - a simple CMS using Atom and RSS
2
1:30 - 3:15
3:45 - 5:00
Version WarningDo Not Deploy!
oh, all right
<entry version="draft-ietf-atompub-format-05: do not deploy"xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-05">
3
The context of RSS and Atom
• Syndication formats - describing documents
• RSS 0.9 ➡ 0.91 ➡ 1.0 ➡ 0.92 ➡ 2.0
• RDF
• Separate and parallel development
4
5
The Simplest Possible RSS 2.0 Feed<?xml version="1.0" encoding="utf-8"?><rss version="2.0">
<channel><title>The Simplest Feed</title><link>http://example.org/index.html</link><description>The Simplest Possible RSS 2.0 Feed</description>
<item><description>Simple Simple Simple</description></item>
</channel></rss>
The Simplest Possible RSS 1.0 Feed
6
<?xml version="1.0" encoding="UTF-8"?><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <channel rdf:about="http://example.org/index.html"> <title>The Simplest Feed</title> <link>http://example.org/index.html</link> <description>The Simplest Possible RSS 1.0 Feed</description> <items> <rdf:Seq> <rdf:li rdf:resource="http://example.org/example_entry" /> </rdf:Seq> </items>
</channel>
<item rdf:about="http://example.org/example_entry"> <title></title> <link>http://example.org/example_entry</link> </item> </rdf:RDF>
The Simplest Possible Atom Feed<?xml version="1.0" encoding="utf-8"?><feed version="draft-ietf-atompub-format-03: do not deploy" xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-03">
<head> <title>The Simplest Feed</title> <link rel="alternate" type="text/html" href="http://example.org/index.html"/> <author><name>Ben Hammersley</name></author> <updated>2004-10-25T15:07:02Z</updated></head>
<entry> <title>The Simplest Entry Document</title> <link rel="alternate" type="text/html" href="http://example.org/example_entry"/> <author><name>Ben Hammersley</name></author> <id>http://example.org/2004/12345679</id> <updated>2004-10-25T15:07:02Z</updated> <content type="TEXT">Simple Simple Simple</content></entry>
</feed>
7
8
RSS 2.0 RSS 1.0 AtomSimple, adhoc,
temporary, loosely defined data, very loosely defined
standard, many many uses
Fantastic for machine readable lists. Useless for anything else.
Complex, strict, pre-planned, strongly
defined data, strongly defined standard,
burdened with evil buzzword. Fantastic
for complex document mining. A nightmare for tiny
ad-hoc apps.
Simple, strictly defined data,
strictly defined standard, with
extra architectural
loving
Current Atom Users
• Lots of weblogs - Blogger especially
• Flickr
Back to the Greeks
Democritus - 460BC
“Nothing exists except atoms and empty space - everything else is
opinion.”
10
Wittgenstein
11
The world consists of independent atomic facts out of which
larger facts are built
12
• What it is called
• Who created it
• When it was created
• What it contains
• Where it is
All the machine can know about a resource
All other metadata is secondary, subjective and human added
• What it is called
• Who created it
• When it was created
• What it contains
• Where it is
CategoryLocationLanguage
Referencesetc.
13
Key Concept
14
An Atom Document explicitly states the minimum we can know about the resource and no less.
Principle of the
conservation of metadata
The Simplest Possible Atom Feed<?xml version="1.0" encoding="utf-8"?><feed version="draft-ietf-atompub-format-03: do not deploy" xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-03">
<head> <title>The Simplest Feed</title> <link rel="alternate" type="text/html" href="http://example.org/index.html"/> <author><name>Ben Hammersley</name></author> <updated>2004-10-25T15:07:02Z</updated></head>
<entry> <title>The Simplest Entry Document</title> <link rel="alternate" type="text/html" href="http://example.org/example_entry"/> <author><name>Ben Hammersley</name></author> <id>http://example.org/2004/12345679</id> <updated>2004-10-25T15:07:02Z</updated> <content type="TEXT">Simple Simple Simple</content></entry>
</feed>
15
Lost once, lost forever
You can’t bring metadata back, once it’s gone, without introducing doubt.
16
17
RSS 2.0 Lost Data<?xml version="1.0" encoding="utf-8"?><rss version="2.0">
<channel><title>The Simplest Feed</title><link>http://example.org/index.html</link><description>The Simplest Possible RSS 2.0 Feed</description>
<item><description>Simple Simple Simple</description></item>
</channel></rss>
Date?
Author?
URI?
Key Concept
It’s ok to have a lossy representation - RSS, HTML, whatever - but the resource itself must conserve the data.
Data Entropy Cannot Be Reversed.
18
Nothing lost in Atom<?xml version="1.0" encoding="utf-8"?><feed version="draft-ietf-atompub-format-03: do not deploy" xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-03">
<head> <title>The Simplest Feed</title> <link rel="alternate" type="text/html" href="http://example.org/index.html"/> <author><name>Ben Hammersley</name></author> <updated>2004-10-25T15:07:02Z</updated></head>
<entry> <title>The Simplest Entry Document</title> <link rel="alternate" type="text/html" href="http://example.org/example_entry"/> <author><name>Ben Hammersley</name></author> <id>http://example.org/2004/12345679</id> <updated>2004-10-25T15:07:02Z</updated> <content type="TEXT">Simple Simple Simple</content></entry>
</feed>
19
• Atom Entry Document
• Atom Feed Document
Two types of Atom document
20
An Atom Entry Document<entry version="draft-ietf-atompub-format-05: do not deploy"xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-05">
<title>First entry document</title><link rel="alternate" type="text/html" href="http://ben-hammersleys-computer.local./~ben/Etech%202005/Elemental/atom2html.cgi?atom=1110228064.atom"/><author><name>Ben Hammersley</name></author><id>http://ben-hammersleys-computer.local./~ben/Etech%202005/Elemental/1110228064.atom</id><updated>2005-03-07T20:41:04Z</updated><content type="TEXT">This is the content of the first entry document.</content>
</entry>
21
Reusable Syntax of Constructs
• Text
• Person
• Date
• Link
• Category
• Identity
• Service
22
Links, Content
23
• link rels
• content payloads
• content pointers
Atom Feeds
24
The Elegant Feed
• An Atom feed is a collection of documents, topped with its own metadata.
25
Atom Feed - Who, what, where, when, and what again.
<?xml version="1.0" encoding="utf-8"?><feed version="draft-ietf-atompub-format-03: do not deploy" xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-03">
<head> <title>The Simplest Feed</title> <link rel="alternate" type="text/html" href="http://example.org/index.html"/> <author><name>Ben Hammersley</name></author> <updated>2004-10-25T15:07:02Z</updated></head>
<entry> <title>The Simplest Entry Document</title> <link rel="alternate" type="text/html" href="http://example.org/example_entry"/> <author><name>Ben Hammersley</name></author> <id>http://example.org/2004/12345679</id> <updated>2004-10-25T15:07:02Z</updated> <content type="TEXT">Simple Simple Simple</content></entry>
</feed>
26
Creating a feed
• Slice - choose a view
• Dice - take the namespaces out
• Mash - Stick them together
27
Key Concept
A Feed is the representation of a Query over Resources
28
Atom Documents, Revision.
• An Atom Document contains at least the minimum that can be said about a resource, whether an Entry or a Feed.
• An Atom Feed contains the Atom Entry documents resulting from a Query over resources. It’s a type of resource in itself.
29
The Atom API
30
APIs through the ages
• BloggerAPI, Metaweblog API
• XML-RPC or SOAP
• For the manipulation of resources: REST
31
First Principles • HTTP has verbs - GET POST PUT DELETE
• Representations of Resources
• GET the HTML representation of the resource
Erk!
32
GET
Application CONTENT
Ask for content from the
application, by asking for a
specific URI over a specific Encoding.
33
POST
ApplicationCONTENT
Send content to a listening
application, which creates the
resources, and returns the one thing we don’t know already.
34
PUT
ApplicationCONTENT
Send content to a listening
application, which REPLACES a
resource.
35
DELETE
ApplicationDIE! KILL! DIE!
Tells the listening application, to destroy the resource.
36
Manipulating a resource
• Full control means stating all of the data we know
• Hence, we’re stating (most) of an Atom Entry document
• Anything we don’t know is returned to us, along with the result code.
37
Key Concept
An Atom API call is an Atom Entry Document over an HTTP verb.
38
• Endpoints
• Authentication
So what else do we need to know?
39
• PostURI - one per system
• EditURI - one per resource
• FeedURI - one per query
• ResourcePostURI - one per system
Endpoints
40
PostURI<link rel="service.post" type="application/atom+xml" href="PostURI" title="The sitename." />
POST an Atom Entry to it.
One or more representations are created. Atom, HTML, etc.
41
EditURI<link rel="service.edit" type="application/atom+xml " href="EditURI" title="Readable desc of the entry." />
The client GETs the representation which is formatted as an Atom entry. The client may then update the entry and then PUT it back to the same URI. The PUT will cause all the related resources to be updated, for example, the HTML representation.
A client will send a DELETE to the EditURI to delete an entry.
The EditURI is unique to the resource.
42
FeedURI<link rel="service.feed" type="application/atom+xml" href="URI goes here" title="The name of the query." />
The Client GETs a FeedURI to receive an Atom feed of the representation of the query.
You’ve already built this loads of times. Nice.
43
ResourcePostURI
For posting of binary data.
<link rel="resource.post" href="URI for Resource Posting goes here" title="The name of the site.">
44
Other features• Features defer to their elders
• Security, Caching, Encryption
45
After the break
• Documentcentrism
• Using the Atom API to create an application
46
47
Documentcentrism
ContentStored
asAtomEntries
Input View
48
The System of the World
Atom Entry Document
Atom Feed XHTML RSS PDF
Atom API File creation Other interfaces
49
Why represent in Atom
• Because it’s a demo :-)
• Because Atom itself is just a representation
50
Elemental
• Input as an HTML Form
• Store as Atom Entry Documents
• Two outputs - Atom Feed, HTML document
51
Download Elemental
http://benhammersley.com/speaking/EmergingTech2005/Elemental.tgz
Stepping through the code
Extending Elemental
• More inputs
• More outputs
• Use Apache and Content Negotiation
54
Using Atom yourself
• http://atomenabled.org
• http://www.intertwingly.net/wiki/pie/FrontPage
• “Developing feeds with RSS and Atom”
Thank you