Etech2005 Atom Tutorial

1,191 views

Published on

Tutorial on Atom given at the Emerging Technology conference 2005

Published in: Technology
  • Be the first to comment

Etech2005 Atom Tutorial

  1. 1. Building Applications with RSS, Atom, and the Atom API Ben Hammersley 1
  2. 2. Today’s topics •Atom and RSS in the 1:30 - 3:15 structure of the web • The Philosophy behind Atom • The Atom Document model 3:45 - 5:00 and syntax • The architecture of the Atom API • Elemental - a simple CMS using Atom and RSS 2
  3. 3. Version Warning Do Not Deploy! <entry version="draft-ietf-atompub-format-05: do not deploy" xmlns="http://purl.org/atom/ns#draft-ietf-atompub-format-05"> oh, all right 3
  4. 4. 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. 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> 5
  6. 6. The Simplest Possible RSS 1.0 Feed <?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> 6
  7. 7. 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. 8. RSS 2.0 RSS 1.0 Atom Simple, adhoc, Complex, strict, pre- temporary, loosely planned, strongly Simple, strictly defined data, very defined data, strongly defined data, loosely defined defined standard, strictly defined standard, many many burdened with evil uses buzzword. Fantastic standard, with Fantastic for for complex extra machine readable document mining. A architectural lists. Useless for nightmare for tiny anything else. ad-hoc apps. loving 8
  9. 9. Current Atom Users • Lots of weblogs - Blogger especially • Flickr
  10. 10. Back to the Greeks Democritus - 460BC “Nothing exists except atoms and empty space - everything else is opinion.” 10
  11. 11. Wittgenstein The world consists of independent atomic facts out of which larger facts are built 11
  12. 12. All the machine can know about a resource • What it is called • Who created it • When it was created • What it contains • Where it is 12
  13. 13. All other metadata is secondary, subjective and human added • What it is called • Who created it Category • When it was created Location Language • What it contains References etc. • Where it is 13
  14. 14. Key Concept An Atom Document explicitly states the minimum we can know about the resource and no less. Principle of the conservation of metadata 14
  15. 15. 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
  16. 16. Lost once, lost forever You can’t bring metadata back, once it’s gone, without introducing doubt. 16
  17. 17. RSS 2.0 Lost Data <?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> <title>The Simplest Feed</title> Date? <link>http://example.org/index.html</link> <description> The Simplest Possible RSS 2.0 Feed </description> Author? <item> <description> Simple Simple Simple URI? </description> </item> </channel> </rss> 17
  18. 18. 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
  19. 19. 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
  20. 20. Two types of Atom document • Atom Entry Document • Atom Feed Document 20
  21. 21. 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
  22. 22. Reusable Syntax of Constructs • Text • Person • Date • Link • Category • Identity • Service 22
  23. 23. Links, Content • link rels • content payloads • content pointers 23
  24. 24. Atom Feeds 24
  25. 25. The Elegant Feed • An Atom feed is a collection of documents, topped with its own metadata. 25
  26. 26. 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
  27. 27. Creating a feed • Slice - choose a view • Dice - take the namespaces out • Mash - Stick them together 27
  28. 28. Key Concept A Feed is the representation of a Query over Resources 28
  29. 29. 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
  30. 30. The Atom API 30
  31. 31. APIs through the ages • BloggerAPI, Metaweblog API • XML-RPC or SOAP • For the manipulation of resources: REST 31
  32. 32. First Principles • HTTP has verbs - GET POST PUT DELETE • Representations of Resources Erk! • GET the HTML representation of the resource 32
  33. 33. GET Ask for content from the application, by Application CONTENT asking for a specific URI over a specific Encoding. 33
  34. 34. POST Send content to a listening application, which CONTENT Application creates the resources, and returns the one thing we don’t know already. 34
  35. 35. PUT Send content to a listening CONTENT Application application, which REPLACES a resource. 35
  36. 36. DELETE Tells the listening DIE! KILL! Application application, to DIE! destroy the resource. 36
  37. 37. 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
  38. 38. Key Concept An Atom API call is an Atom Entry Document over an HTTP verb. 38
  39. 39. So what else do we need to know? • Endpoints • Authentication 39
  40. 40. Endpoints • PostURI - one per system • EditURI - one per resource • FeedURI - one per query • ResourcePostURI - one per system 40
  41. 41. 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
  42. 42. 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
  43. 43. 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
  44. 44. ResourcePostURI For posting of binary data. <link rel="resource.post" href="URI for Resource Posting goes here" title="The name of the site."> 44
  45. 45. Other features • Features defer to their elders • Security, Caching, Encryption 45
  46. 46. After the break • Documentcentrism • Using the Atom API to create an application 46
  47. 47. 47
  48. 48. Documentcentrism Content Stored Input as View Atom Entries 48
  49. 49. The System of the World Atom Feed XHTML RSS PDF Atom Entry Document Atom API File creation Other interfaces 49
  50. 50. Why represent in Atom • Because it’s a demo :-) • Because Atom itself is just a representation 50
  51. 51. Elemental • Input as an HTML Form • Store as Atom Entry Documents • Two outputs - Atom Feed, HTML document 51
  52. 52. Download Elemental http://benhammersley.com/speaking/EmergingTech2005/Elemental.tgz
  53. 53. Stepping through the code
  54. 54. Extending Elemental • More inputs • More outputs • Use Apache and Content Negotiation 54
  55. 55. Using Atom yourself • http://atomenabled.org • http://www.intertwingly.net/wiki/pie/ FrontPage • “Developing feeds with RSS and Atom”
  56. 56. Thank you

×