56
Building Applications with RSS, Atom, and the Atom API Ben Hammersley 1

Etech2005 Atom Tutorial

Embed Size (px)

DESCRIPTION

Tutorial on Atom given at the Emerging Technology conference 2005

Citation preview

Page 1: Etech2005 Atom Tutorial

Building Applications with RSS, Atom, and the Atom API

Ben Hammersley

1

Page 2: Etech2005 Atom Tutorial

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

Page 3: Etech2005 Atom Tutorial

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

Page 4: Etech2005 Atom Tutorial

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

Page 5: Etech2005 Atom Tutorial

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>

Page 6: Etech2005 Atom Tutorial

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>

Page 7: Etech2005 Atom Tutorial

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

Page 8: Etech2005 Atom Tutorial

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

Page 9: Etech2005 Atom Tutorial

Current Atom Users

• Lots of weblogs - Blogger especially

• Flickr

Page 10: Etech2005 Atom Tutorial

Back to the Greeks

Democritus - 460BC

“Nothing exists except atoms and empty space - everything else is

opinion.”

10

Page 11: Etech2005 Atom Tutorial

Wittgenstein

11

The world consists of independent atomic facts out of which

larger facts are built

Page 12: Etech2005 Atom Tutorial

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

Page 13: Etech2005 Atom Tutorial

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

Page 14: Etech2005 Atom Tutorial

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

Page 15: Etech2005 Atom Tutorial

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

Page 16: Etech2005 Atom Tutorial

Lost once, lost forever

You can’t bring metadata back, once it’s gone, without introducing doubt.

16

Page 17: Etech2005 Atom Tutorial

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?

Page 18: Etech2005 Atom Tutorial

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

Page 19: Etech2005 Atom Tutorial

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

Page 20: Etech2005 Atom Tutorial

• Atom Entry Document

• Atom Feed Document

Two types of Atom document

20

Page 21: Etech2005 Atom Tutorial

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

Page 22: Etech2005 Atom Tutorial

Reusable Syntax of Constructs

• Text

• Person

• Date

• Link

• Category

• Identity

• Service

22

Page 23: Etech2005 Atom Tutorial

Links, Content

23

• link rels

• content payloads

• content pointers

Page 24: Etech2005 Atom Tutorial

Atom Feeds

24

Page 25: Etech2005 Atom Tutorial

The Elegant Feed

• An Atom feed is a collection of documents, topped with its own metadata.

25

Page 26: Etech2005 Atom Tutorial

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

Page 27: Etech2005 Atom Tutorial

Creating a feed

• Slice - choose a view

• Dice - take the namespaces out

• Mash - Stick them together

27

Page 28: Etech2005 Atom Tutorial

Key Concept

A Feed is the representation of a Query over Resources

28

Page 29: Etech2005 Atom Tutorial

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

Page 30: Etech2005 Atom Tutorial

The Atom API

30

Page 31: Etech2005 Atom Tutorial

APIs through the ages

• BloggerAPI, Metaweblog API

• XML-RPC or SOAP

• For the manipulation of resources: REST

31

Page 32: Etech2005 Atom Tutorial

First Principles • HTTP has verbs - GET POST PUT DELETE

• Representations of Resources

• GET the HTML representation of the resource

Erk!

32

Page 33: Etech2005 Atom Tutorial

GET

Application CONTENT

Ask for content from the

application, by asking for a

specific URI over a specific Encoding.

33

Page 34: Etech2005 Atom Tutorial

POST

ApplicationCONTENT

Send content to a listening

application, which creates the

resources, and returns the one thing we don’t know already.

34

Page 35: Etech2005 Atom Tutorial

PUT

ApplicationCONTENT

Send content to a listening

application, which REPLACES a

resource.

35

Page 36: Etech2005 Atom Tutorial

DELETE

ApplicationDIE! KILL! DIE!

Tells the listening application, to destroy the resource.

36

Page 37: Etech2005 Atom Tutorial

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

Page 38: Etech2005 Atom Tutorial

Key Concept

An Atom API call is an Atom Entry Document over an HTTP verb.

38

Page 39: Etech2005 Atom Tutorial

• Endpoints

• Authentication

So what else do we need to know?

39

Page 40: Etech2005 Atom Tutorial

• PostURI - one per system

• EditURI - one per resource

• FeedURI - one per query

• ResourcePostURI - one per system

Endpoints

40

Page 41: Etech2005 Atom Tutorial

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

Page 42: Etech2005 Atom Tutorial

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

Page 43: Etech2005 Atom Tutorial

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

Page 44: Etech2005 Atom Tutorial

ResourcePostURI

For posting of binary data.

<link rel="resource.post" href="URI for Resource Posting goes here" title="The name of the site.">

44

Page 45: Etech2005 Atom Tutorial

Other features• Features defer to their elders

• Security, Caching, Encryption

45

Page 46: Etech2005 Atom Tutorial

After the break

• Documentcentrism

• Using the Atom API to create an application

46

Page 47: Etech2005 Atom Tutorial

47

Page 48: Etech2005 Atom Tutorial

Documentcentrism

ContentStored

asAtomEntries

Input View

48

Page 49: Etech2005 Atom Tutorial

The System of the World

Atom Entry Document

Atom Feed XHTML RSS PDF

Atom API File creation Other interfaces

49

Page 50: Etech2005 Atom Tutorial

Why represent in Atom

• Because it’s a demo :-)

• Because Atom itself is just a representation

50

Page 51: Etech2005 Atom Tutorial

Elemental

• Input as an HTML Form

• Store as Atom Entry Documents

• Two outputs - Atom Feed, HTML document

51

Page 52: Etech2005 Atom Tutorial

Download Elemental

http://benhammersley.com/speaking/EmergingTech2005/Elemental.tgz

Page 53: Etech2005 Atom Tutorial

Stepping through the code

Page 54: Etech2005 Atom Tutorial

Extending Elemental

• More inputs

• More outputs

• Use Apache and Content Negotiation

54

Page 55: Etech2005 Atom Tutorial

Using Atom yourself

• http://atomenabled.org

• http://www.intertwingly.net/wiki/pie/FrontPage

• “Developing feeds with RSS and Atom”

Page 56: Etech2005 Atom Tutorial

Thank you