atomPub, ruby y la api de 11870

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    1 Group

    atomPub, ruby y la api de 11870 - Presentation Transcript

    1. Atom Publishing Protocol, ruby y la api de 11870.com David Calavera
    2. antecedentes
    3. 11870.com ๏ recuerda y comparte negocios ... David Calavera Conferencia Rails 2007
    4. 11870.com • recuerda y comparte negocios ... ๏ no solo de comentarios vive el hombre David Calavera Conferencia Rails 2007
    5. 11870.com • recuerda y comparte negocios ... • no solo de comentarios vive el hombre ๏ ¿por qué tengo que atarme a la web? David Calavera Conferencia Rails 2007
    6. 11870.com • recuerda y comparte negocios ... • no solo de comentarios vive el hombre • ¿por qué tengo que atarme a la web? ๏ ¿quien tiene que adaptarse? David Calavera Conferencia Rails 2007
    7. atomPub
    8. “the atom publishing protocol is an application-level protocol for publishing and editing web resources” David Calavera Conferencia Rails 2007
    9. ๏ ¿sabes qué es HTTP y como usarlo? David Calavera Conferencia Rails 2007
    10. • ¿sabes qué es HTTP y como usarlo? ๏ ¿sabes qué es XML y como usarlo? David Calavera Conferencia Rails 2007
    11. • ¿sabes qué es HTTP y como usarlo? • ¿sabes qué es XML y como usarlo? ๏ ¿sabes qué es un feed y como crearlo? David Calavera Conferencia Rails 2007
    12. atomPub características
    13. estándar http://ietfreport.isoc.org/idref/rfc5023 David Calavera Conferencia Rails 2007
    14. basado en atom <?xml version=\"1.0\" encoding=\"utf-8\"?> <feed xmlns=\"http://www.w3.org/2005/Atom\" xml:lang=\"en\"> <id>http://www.verbosemode.com/wp-app.php/posts</id> <updated>2007-11-04T11:38:28Z</updated> <title type=\"text\">Verbose mode</title> <subtitle type=\"text\">Verbose mode</subtitle> <entry> <id>http://www.verbosemode.com/?p=3</id> <title type=\"text\">Spanish Rails Conf 07</title> <updated>2007-11-04T11:38:28Z</updated> <published>2007-11-04T11:38:28Z</published> ... David Calavera Conferencia Rails 2007
    15. arquitectura REST David Calavera Conferencia Rails 2007
    16. arquitectura REST ๏ protocolo sin estado David Calavera Conferencia Rails 2007
    17. arquitectura REST • protocolo sin estado ๏ operaciones bien definidas David Calavera Conferencia Rails 2007
    18. arquitectura REST • protocolo sin estado • operaciones bien definidas ๏ sintaxis universal (IRI) David Calavera Conferencia Rails 2007
    19. IRI www. .w3.mag.keio.ac.jp David Calavera Conferencia Rails 2007
    20. URI www.%e3%81%bb%e3%82%93%e3%81%a8%e3%81%86%e3% 81%ab%e3%81%aa%e3%81%8c%e3%81%84%e3%82%8f%e3% 81%91%e3%81%ae%e3%82%8f%e3%81%8b%e3%82%89%e3% 81%aa%e3%81%84%e3%81%a9%e3%82%81%e3%81%84%e3% 82%93%e3%82%81%e3%81%84%e3%81%ae%e3%82%89% e3%81%b9%e3%82%8b%e3%81%be%e3%81%a0%e3%81%aa% e3%81%8c%e3%81%8f%e3%81%97%e3%81%aa%e3%81%84% e3%81%a8%e3%81%9f%e3%82%8a%e3%81%aa%e3%81% 84.w3.mag.keio.ac.jp David Calavera Conferencia Rails 2007
    21. introspectivo David Calavera Conferencia Rails 2007
    22. introspectivo documento de servicio David Calavera Conferencia Rails 2007
    23. introspectivo documento de servicio colección colección David Calavera Conferencia Rails 2007
    24. introspectivo documento de servicio colección elementos colección elementos David Calavera Conferencia Rails 2007
    25. fácilmente extensible <?xml version=\"1.0\" encoding=\"utf-8\"?> <feed xmlns=\"http://www.w3.org/2005/Atom\" xml:lang=\"en\" xmlns:openSearch=\"http://a9.com/-/spec/opensearchrss/1.0/\"> <id>http://www.verbosemode.com/wp-app.php/posts</id> <updated>2007-11-04T11:38:28Z</updated> <title type=\"text\">Verbose mode</title> <subtitle type=\"text\">Verbose mode</subtitle> <openSearch:totalResults>1</openSearch:totalResults> <openSearch:startIndex>1</openSearch:startIndex> <openSearch:itemsPerPage>25</openSearch:itemsPerPage> <entry> <id>http://www.verbosemode.com/?p=3</id> <title type=\"text\">Spanish Rails Conf 07</title> <updated>2007-11-04T11:38:28Z</updated> <published>2007-11-04T11:38:28Z</published> ... David Calavera Conferencia Rails 2007
    26. multimedia David Calavera Conferencia Rails 2007
    27. más... ๏ paginación David Calavera Conferencia Rails 2007
    28. <?xml version=\"1.0\" encoding=\"utf-8\"?> <feed xmlns=\"http://www.w3.org/2005/Atom\" xml:lang=\"en\"> <id>http://www.verbosemode.com/wp-app.php/posts</id> <updated>2007-11-04T11:38:28Z</updated> <link rel=\"self\" href=\"http://www.verbosemode.com/wp-app.php/posts?p=3\"/> <link rel=\"next\" href=\"http://www.verbosemode.com/wp-app.php/posts?p=4\"/> <link rel=\"previous\" href=\"http://www.verbosemode.com/wp-app.php/posts?p=2\"/> <link rel=\"first\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <link rel=\"last\" href=\"http://www.verbosemode.com/wp-app.php/posts?p=5\"/> ... David Calavera Conferencia Rails 2007
    29. más... • paginación ๏ caché David Calavera Conferencia Rails 2007
    30. POST /wp-app.php/posts HTTP/1.1 201 Created Content-Type: application/atom+xml;type=entry;charset=\"utf-8\" ETag: \"c180de84f991g8\" David Calavera Conferencia Rails 2007
    31. POST /wp-app.php/posts HTTP/1.1 201 Created Content-Type: application/atom+xml;type=entry;charset=\"utf-8\" ETag: \"c180de84f991g8\" GET /wp-app.php/post/3 HTTP/1.1 304 Not Modified If-None-Match: \"c180de84f991g8\" David Calavera Conferencia Rails 2007
    32. POST /wp-app.php/posts HTTP/1.1 201 Created Content-Type: application/atom+xml;type=entry;charset=\"utf-8\" ETag: \"c180de84f991g8\" GET /wp-app.php/post/3 HTTP/1.1 304 Not Modified If-None-Match: \"c180de84f991g8\" PUT /wp-app.php/post/3 HTTP/1.1 412 Precondition Failed If-Match: \"c180de84f991g8\" David Calavera Conferencia Rails 2007
    33. más... • paginación • caché ๏ control de estado David Calavera Conferencia Rails 2007
    34. <?xml version=\"1.0\" encoding=\"utf-8\"?> <entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" xml:lang=\"en\"> <id>http://www.verbosemode.com/?p=3</id> <title type=\"text\">Spanish Rails Conf 07</title> <app:control> <app:draft>no</app:draft> </app:control> ... David Calavera Conferencia Rails 2007
    35. más... • paginación • caché • control de estado ๏ seguridad David Calavera Conferencia Rails 2007
    36. atomPub estructura
    37. atomPub:service GET 'http://www.verbosemode.com/wp-app.php/service' HTTP/1.1 200 OK David Calavera Conferencia Rails 2007
    38. atomPub:service <?xml version=\"1.0\" encoding=\"utf-8\"?> <service xmlns=\"http://www.w3.org/2007/app\" xmlns:atom=\"http://www.w3.org/2005/Atom\"> <workspace> <atom:title>Workspace</atom:title> <collection href=\"http://www.verbosemode.com/wp-app.php/posts\"> <atom:title>Posts</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href=\"http://www.verbosemode.com/wp-app.php/categories\"/> </collection> <collection href=\"http://www.verbosemode.com/wp-app.php/attachments\"> <atom:title>Media</atom:title> <accept>image/*</accept> <accept>audio/*</accept> <accept>video/*</accept> </collection> </workspace> </service> David Calavera Conferencia Rails 2007
    39. atomPub:service <?xml version=\"1.0\" encoding=\"utf-8\"?> <service xmlns=\"http://www.w3.org/2007/app\" xmlns:atom=\"http://www.w3.org/2005/Atom\"> <workspace> <atom:title>Workspace</atom:title> <collection href=\"http://www.verbosemode.com/wp-app.php/posts\"> <atom:title>Posts</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href=\"http://www.verbosemode.com/wp-app.php/categories\"/> </collection> <collection href=\"http://www.verbosemode.com/wp-app.php/attachments\"> <atom:title>Media</atom:title> <accept>image/*</accept> <accept>audio/*</accept> <accept>video/*</accept> </collection> </workspace> </service> David Calavera Conferencia Rails 2007
    40. atomPub:service <?xml version=\"1.0\" encoding=\"utf-8\"?> <service xmlns=\"http://www.w3.org/2007/app\" xmlns:atom=\"http://www.w3.org/2005/Atom\"> <workspace> <atom:title>Workspace</atom:title> <collection href=\"http://www.verbosemode.com/wp-app.php/posts\"> <atom:title>Posts</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href=\"http://www.verbosemode.com/wp-app.php/categories\"/> </collection> <collection href=\"http://www.verbosemode.com/wp-app.php/attachments\"> <atom:title>Media</atom:title> <accept>image/*</accept> <accept>audio/*</accept> <accept>video/*</accept> </collection> </workspace> </service> David Calavera Conferencia Rails 2007
    41. atomPub:service <?xml version=\"1.0\" encoding=\"utf-8\"?> <service xmlns=\"http://www.w3.org/2007/app\" xmlns:atom=\"http://www.w3.org/2005/Atom\"> <workspace> <atom:title>Workspace</atom:title> <collection href=\"http://www.verbosemode.com/wp-app.php/posts\"> <atom:title>Posts</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href=\"http://www.verbosemode.com/wp-app.php/categories\"/> </collection> <collection href=\"http://www.verbosemode.com/wp-app.php/attachments\"> <atom:title>Media</atom:title> <accept>image/*</accept> <accept>audio/*</accept> <accept>video/*</accept> </collection> </workspace> </service> David Calavera Conferencia Rails 2007
    42. atomPub:service <?xml version=\"1.0\" encoding=\"utf-8\"?> <service xmlns=\"http://www.w3.org/2007/app\" xmlns:atom=\"http://www.w3.org/2005/Atom\"> <workspace> <atom:title>Workspace</atom:title> <collection href=\"http://www.verbosemode.com/wp-app.php/posts\"> <atom:title>Posts</atom:title> <accept>application/atom+xml;type=entry</accept> <categories href=\"http://www.verbosemode.com/wp-app.php/categories\"/> </collection> <collection href=\"http://www.verbosemode.com/wp-app.php/attachments\"> <atom:title>Media</atom:title> <accept>image/*</accept> <accept>audio/*</accept> <accept>video/*</accept> </collection> </workspace> </service> David Calavera Conferencia Rails 2007
    43. atomPub:categories GET 'http://www.verbosemode.com/wp-app.php/categories' HTTP/1.1 200 OK David Calavera Conferencia Rails 2007
    44. atomPub:categories <?xml version=\"1.0\" encoding=\"utf-8\"?> <app:categories xmlns:app=\"http://www.w3.org/2007/app\" xmlns=\"http://www.w3.org/2005/Atom\" fixed=\"yes\" scheme=\"http://www.verbosemode.com\"> <category term=\"atomPub\" /> <category term=\"rails\" /> </app:categories> David Calavera Conferencia Rails 2007
    45. atomPub:collection POST 'http://www.verbosemode.com/wp-app.php/posts' HTTP/1.1 201 Created Content-Type: */* Location: 'http://www.verbosemode.com/wp-app.php/post/3' Content-Location: 'http://www.verbosemode.com/wp-app.php/post/3' GET 'http://www.verbosemode.com/wp-app.php/posts' HTTP/1.1 200 OK David Calavera Conferencia Rails 2007
    46. atomPub:collection <?xml version=\"1.0\" encoding=\"utf-8\"?> <feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" xml:lang=\"en\"> <id>http://www.verbosemode.com/wp-app.php/posts</id> <updated>2007-11-04T11:38:28Z</updated> <title type=\"text\">Verbose mode</title> <link rel=\"first\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <link rel=\"last\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <link rel=\"self\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <entry> <id>http://www.verbosemode.com/?p=3</id> <title type=\"text\">Spanish Rails Conf 07</title> <app:edited>2007-11-04T11:38:28Z</app:edited> <link rel=\"edit\" href=\"http://www.verbosemode.com/wp-app.php/post/3\"/> <app:control><app:draft>no</app:draft></app:control> ... David Calavera Conferencia Rails 2007
    47. atomPub:collection <?xml version=\"1.0\" encoding=\"utf-8\"?> <feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" xml:lang=\"en\"> <id>http://www.verbosemode.com/wp-app.php/posts</id> <updated>2007-11-04T11:38:28Z</updated> <title type=\"text\">Verbose mode</title> <link rel=\"first\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <link rel=\"last\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <link rel=\"self\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <entry> <id>http://www.verbosemode.com/?p=3</id> <title type=\"text\">Spanish Rails Conf 07</title> <app:edited>2007-11-04T11:38:28Z</app:edited> <link rel=\"edit\" href=\"http://www.verbosemode.com/wp-app.php/post/3\"/> <app:control><app:draft>no</app:draft></app:control> ... David Calavera Conferencia Rails 2007
    48. atomPub:collection <?xml version=\"1.0\" encoding=\"utf-8\"?> <feed xmlns=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" xml:lang=\"en\"> <id>http://www.verbosemode.com/wp-app.php/posts</id> <updated>2007-11-04T11:38:28Z</updated> <title type=\"text\">Verbose mode</title> <link rel=\"first\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <link rel=\"last\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <link rel=\"self\" href=\"http://www.verbosemode.com/wp-app.php/posts\"/> <entry> <id>http://www.verbosemode.com/?p=3</id> <title type=\"text\">Spanish Rails Conf 07</title> <app:edited>2007-11-04T11:38:28Z</app:edited> <link rel=\"edit\" href=\"http://www.verbosemode.com/wp-app.php/post/3\"/> <app:control><app:draft>no</app:draft></app:control> ... David Calavera Conferencia Rails 2007
    49. atomPub:entry PUT 'http://www.verbosemode.com/wp-app.php/post/3' HTTP/1.1 204 No Content Content-Type: application/atom+xml;type=entry DELETE 'http://www.verbosemode.com/wp-app.php/post/3' HTTP/1.1 200 OK GET 'http://www.verbosemode.com/wp-app.php/post/3' HTTP/1.1 200 OK David Calavera Conferencia Rails 2007
    50. atomPub:entry <?xml version=\"1.0\" encoding=\"utf-8\"?> <entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" xml:lang=\"en\"> <id>http://www.verbosemode.com/?p=3</id> <title type=\"text\">Spanish Rails Conf 07</title> <updated>2007-11-04T15:43:49Z</updated> <published>2007-11-04T11:38:28Z</published> <app:edited>2007-11-04T15:43:49Z</app:edited> <app:control><app:draft>no</app:draft></app:control> <author><name>david</name></author> <content type=\"xhtml\"><div xmlns='http://www.w3.org/1999/xhtml'> Next November 22 and 23 I'm going to attend to ...</div></content> <link rel=\"edit\" href=\"http://www.verbosemode.com/wp-app.php/post/3\" /> <category scheme=\"http://www.verbosemode.com\" term=\"atomPub\" /> <category scheme=\"http://www.verbosemode.com\" term=\"rails\" /> <summary type=\"text\">Next November 22 and 23 I&#8217;m ...</summary> </entry> David Calavera Conferencia Rails 2007
    51. atomPub:entry ¿y... qué pasa con los otros tipos de recursos? <entry xmlns=\"http://www.w3.org/2005/Atom\" xmlns:app=\"http://www.w3.org/2007/app\" xml:lang=\"en\"> <id>http://www.verbosemode.com/wp-content/uploads/2007/11/avatar.png</id> <title type=\"text\">avatar poster</title> <updated>2007-11-13T21:59:55Z</updated> <published>2007-11-13T21:59:55Z</published> <app:edited>2007-11-13T21:59:55Z</app:edited> <app:control><app:draft>no</app:draft></app:control> <author><name>david</name></author> <link rel=\"edit-media\" href=\"http://www.verbosemode.com/wp-app.php/attachment/file/4\" /> <link rel=\"edit\" href=\"http://www.verbosemode.com/wp-app.php/post/4\" /> <content type=\"image/png\" src=\"http://www.verbosemode.com/wp-content/uploads/2007/11/avatar.png\"/> </entry> David Calavera Conferencia Rails 2007
    52. atomPub:entry ¿y... qué pasa con los otros tipos de recursos? PUT 'http://www.verbosemode.com/wp-app.php/attachment/file/4' HTTP/1.1 204 No Content Content-Type: */* DELETE 'http://www.verbosemode.com/wp-app.php/attachment/file/4' HTTP/1.1 200 OK GET 'http://www.verbosemode.com/wp-app.php/attachment/file/4' HTTP/1.1 200 OK David Calavera Conferencia Rails 2007
    53. atomPub ¿pero... hay gente que usa esto?
    54. ๏ google: gdata, youtube, openSocial David Calavera Conferencia Rails 2007
    55. • google: gdata, youtube, openSocial ๏ microsoft: windows live writer David Calavera Conferencia Rails 2007
    56. • google: gdata, youtube, openSocial • microsoft: windows live writer ๏ ibm: lotus connections David Calavera Conferencia Rails 2007
    57. • google: gdata, youtube, openSocial • microsoft: windows live writer • ibm: lotus connections ๏ wordpress David Calavera Conferencia Rails 2007
    58. • google: gdata, youtube, openSocial • microsoft: windows live writer • ibm: lotus connections • wordpress ๏ nokia: liveblog David Calavera Conferencia Rails 2007
    59. • google: gdata, youtube, openSocial • microsoft: windows live writer • ibm: lotus connections • wordpress • nokia: liveblog ๏ six apart: typepad, movable type David Calavera Conferencia Rails 2007
    60. • google: gdata, youtube, openSocial • microsoft: windows live writer • ibm: lotus connections • wordpress • nokia: liveblog • six apart: typepad, movable type ๏ 11870.com
    61. ruby sin más
    62. Net::HTTP David Calavera Conferencia Rails 2007
    63. Net::HTTP ๏ fácil de mantener David Calavera Conferencia Rails 2007
    64. Net::HTTP • fácil de mantener ๏ respuesta condicionada al estado David Calavera Conferencia Rails 2007
    65. HTTPResponse HTTPSuccess # 2xx HTTPOK # 200 HTTPCreated # 201 HTTPRedirection # 3xx HTTPNotModified # 304 HTTPClientError # 4xx HTTPBadRequest # 400 HTTPUnauthorized # 401 HTTPForbidden # 403 HTTPNotFound # 404 HTTPPreconditionFailed # 412 HTTPUnsupportedMediaType # 415 HTTPServerError # 5xx HTTPInternalServerError # 500 David Calavera Conferencia Rails 2007
    66. Net:HTTP • fácil de mantener • respuesta condicionada al estado ๏ no sabe si estoy en una capa segura David Calavera Conferencia Rails 2007
    67. require 'net/http' require 'net/https' @uri = 'https://registro.conferenciarails.org' http = Net::HTTP.new @uri http.use_ssl = true if @uri =~ /^https/ David Calavera Conferencia Rails 2007
    68. los cuatro verbos http Net::HTTP.start(@uri.host, @uri.port) do |http| end David Calavera Conferencia Rails 2007
    69. los cuatro verbos http Net::HTTP.start(@uri.host, @uri.port) do |http| #POST http.request Net::HTTP::Post.new(@uri.path), data end David Calavera Conferencia Rails 2007
    70. los cuatro verbos http Net::HTTP.start(@uri.host, @uri.port) do |http| #POST http.request Net::HTTP::Post.new(@uri.path), data #GET http.request Net::HTTP::Get.new(@uri.path) end David Calavera Conferencia Rails 2007
    71. los cuatro verbos http Net::HTTP.start(@uri.host, @uri.port) do |http| #POST http.request Net::HTTP::Post.new(@uri.path), data #GET http.request Net::HTTP::Get.new(@uri.path) #PUT http.request Net::HTTP::Put.new(@uri.path), data end David Calavera Conferencia Rails 2007
    72. los cuatro verbos http Net::HTTP.start(@uri.host, @uri.port) do |http| #POST http.request Net::HTTP::Post.new(@uri.path), data #GET http.request Net::HTTP::Get.new(@uri.path) #PUT http.request Net::HTTP::Put.new(@uri.path), data #DELETE http.request Net::HTTP::Delete.new(@uri.path) end David Calavera Conferencia Rails 2007
    73. REXML ๏ parser completo David Calavera Conferencia Rails 2007
    74. REXML • parser completo ๏ escrito completamente en ruby David Calavera Conferencia Rails 2007
    75. REXML • parser completo • escrito completamente en ruby ๏ pasa los test de aceptación de Oasis David Calavera Conferencia Rails 2007
    76. REXML • parser completo • escrito completamente en ruby • pasa los test de aceptación de Oasis ๏ soporta XPath David Calavera Conferencia Rails 2007
    77. REXML y xpath NS = {'atom' => 'http://www.w3.org/2005/Atom', 'app' => 'http://www.w3.org/2007/app', 'georss' => 'http://www.georss.org/georss/10', 'gml' => 'http://www.opengis.net/gml' } REXML::XPath.each( feed.root, './atom:entry', NS) do |entry| title = REXML::XPath.first(entry, './atom:title/text()', NS) edited = REXML::XPath.first(entry, './app:edited/text()', NS) pos = REXML::XPath.first(entry, './georss:where/gml:Point/gml:pos/text()', NS) end David Calavera Conferencia Rails 2007
    78. REXML y xpath NS = {'atom' => 'http://www.w3.org/2005/Atom', 'app' => 'http://www.w3.org/2007/app', 'georss' => 'http://www.georss.org/georss/10', 'gml' => 'http://www.opengis.net/gml' } REXML::XPath.each( feed.root, './atom:entry', NS) do |entry| title = REXML::XPath.first(entry, './atom:title/text()', NS) edited = REXML::XPath.first(entry, './app:edited/text()', NS) pos = REXML::XPath.first(entry, './georss:where/gml:Point/gml:pos/text()', NS) end David Calavera Conferencia Rails 2007
    79. REXML y xpath NS = {'atom' => 'http://www.w3.org/2005/Atom', 'app' => 'http://www.w3.org/2007/app', 'georss' => 'http://www.georss.org/georss/10', 'gml' => 'http://www.opengis.net/gml' } REXML::XPath.each( feed.root, './atom:entry', NS) do |entry| title = REXML::XPath.first(entry, './atom:title/text()', NS) edited = REXML::XPath.first(entry, './app:edited/text()', NS) pos = REXML::XPath.first(entry, './georss:where/gml:Point/gml:pos/text()', NS) end David Calavera Conferencia Rails 2007
    80. REXML y xpath NS = {'atom' => 'http://www.w3.org/2005/Atom', 'app' => 'http://www.w3.org/2007/app', 'georss' => 'http://www.georss.org/georss/10', 'gml' => 'http://www.opengis.net/gml' } REXML::XPath.each( feed.root, './atom:entry', NS) do |entry| title = REXML::XPath.first(entry, './atom:title/text()', NS) edited = REXML::XPath.first(entry, './app:edited/text()', NS) pos = REXML::XPath.first(entry, './georss:where/gml:Point/gml:pos/text()', NS) end David Calavera Conferencia Rails 2007
    81. REXML y xpath NS = {'atom' => 'http://www.w3.org/2005/Atom', 'app' => 'http://www.w3.org/2007/app', 'georss' => 'http://www.georss.org/georss/10', 'gml' => 'http://www.opengis.net/gml' } REXML::XPath.each( feed.root, './atom:entry', NS) do |entry| title = REXML::XPath.first(entry, './atom:title/text()', NS) edited = REXML::XPath.first(entry, './app:edited/text()', NS) pos = REXML::XPath.first(entry, './georss:where/gml:Point/gml:pos/text()', NS) end David Calavera Conferencia Rails 2007
    82. Builder ๏ crea xml fácilmente David Calavera Conferencia Rails 2007
    83. require 'builder' builder = Builder::XmlMarkup.new xml = builder.feed( 'xmlns' => 'http://www.w3.org/2005/Atom' ) do |feed| feed.id 'http://conferenciarails.org/atomPub' feed.updated Time.now feed.author do |author| author.name 'David Calavera' end feed.entry do |entry| entry.title 'entrada para la conferencia rails' end end David Calavera Conferencia Rails 2007
    84. Builder • crea xml fácilmente ๏ no solo se usa con rails David Calavera Conferencia Rails 2007
    85. ๏ in the beginning... was the command line builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2) David Calavera Conferencia Rails 2007
    86. • in the beginning... was the command line builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2) ๏ vamos de camping Camping.goes :Atom module Atom::Views def index html do head do title 'Atom Publishing Protocol @ conferecia rails' end body do ... end end end David Calavera Conferencia Rails 2007
    87. ruby extras
    88. atom-tools http://code.necronomicorp.com/atom-tools ๏ parsea y manipula feeds David Calavera Conferencia Rails 2007
    89. atom-tools http://code.necronomicorp.com/atom-tools • parsea y manipula feeds ๏ adaptado al rfc 5023 David Calavera Conferencia Rails 2007
    90. atom-tools http://code.necronomicorp.com/atom-tools • parsea y manipula feeds • adaptado al rfc 5023 ๏ abstracción de http y xml David Calavera Conferencia Rails 2007
    91. require 'atom-tools' http = Atom::HTTP.new http.user = 'david' http.pass = 'my password' http.always_auth :basic service = Atom::Service.new 'http://verbosemode.com/wp-app.php/service', http service.collections.each do |collection| puts collection.accepts end David Calavera Conferencia Rails 2007
    92. require 'atom-tools' http = Atom::HTTP.new http.user = 'david' http.pass = 'my password' http.always_auth :basic service = Atom::Service.new 'http://verbosemode.com/wp-app.php/service', http service.collections.each do |collection| puts collection.accepts end David Calavera Conferencia Rails 2007
    93. require 'atom-tools' http = Atom::HTTP.new http.user = 'david' http.pass = 'my password' http.always_auth :basic service = Atom::Service.new 'http://verbosemode.com/wp-app.php/service', http service.collections.each do |collection| puts collection.accepts end David Calavera Conferencia Rails 2007
    94. atom_pub_server http://svn.thinkincode.net/rails/plugins/atom_pub_server ๏ rails es REST David Calavera Conferencia Rails 2007
    95. atom_pub_server http://svn.thinkincode.net/rails/plugins/atom_pub_server • rails es REST ๏ mejor soporte para atom y atomPub David Calavera Conferencia Rails 2007
    96. atom_feed do |feed| feed.title(\"My great blog!\") feed.updated((@posts.first.created_at)) for post in @posts feed.entry(post) do |entry| entry.tag!('georss:where', 'xmlns:georss' => 'http://www.georss.org/georss/10') do |where| where.tag!('gml:Poing', 'xmlns:gml' => 'http://www.opengis.net/gml') do |point| point.tag!('gml:pos', nil, '40.419967 -3.698965') end end David Calavera Conferencia Rails 2007
    97. atom_feed({'xmlns:georss' => 'http://www.georss.org/georss/10', 'xmlns:gml' => 'http://www.opengis.net/gml'}) do |feed| feed.title(\"My great blog!\") feed.updated((@posts.first.created_at)) for post in @posts feed.entry(post) do |entry| entry.georss:where do |where| where.gml:Point do |point| point.tag!('gml:pos', '40.419967 -3.698965') end end David Calavera Conferencia Rails 2007
    98. atom_pub_server http://svn.thinkincode.net/rails/plugins/atom_pub_server • rails es REST • mejor soporte para atom y atomPub ๏ acts_as_collection David Calavera Conferencia Rails 2007
    99. class PostsController < ApplicationController acts_as_collection :title => 'Posts', :workspace => 'Blog', :accept => Mime::ATOM_ENTRY, :href => 'http::/verbosemode.com/atomPub/posts', :categories => [ { :fixed => 'yes', :scheme => 'http://verbosemode.com/tags', :category => [{:term => 'rails'}, {:term => 'plugins'}] }, {:href => 'http://verbosemode.com/mysections'} ] end David Calavera Conferencia Rails 2007
    100. atom_pub_server http://svn.thinkincode.net/rails/plugins/atom_pub_server • rails es REST • mejor soporte para atom y atomPub • acts_as_collection ๏ acts_as_service_document David Calavera Conferencia Rails 2007
    101. class ServicesController < ApplicationController acts_as_service_document def index render :xml => service_document end end David Calavera Conferencia Rails 2007
    102. the ape http://www.tbray.org/ape ๏ the atom publishing exerciser
    103. the ape http://www.tbray.org/ape • the atom publishing exerciser ๏ introspección!!! David Calavera Conferencia Rails 2007
    104. David Calavera Conferencia Rails 2007
    105. the ape http://www.tbray.org/ape • the atom publishing exerciser • introspección!!! ๏ varios sistemas de autenticación David Calavera Conferencia Rails 2007
    106. David Calavera Conferencia Rails 2007
    107. the ape http://www.tbray.org/ape • the atom publishing exerciser • introspección!!! • varios sistemas de autenticación ๏ no es muy fácil de instalar (de momento) David Calavera Conferencia Rails 2007
    108. the ape http://www.tbray.org/ape • the atom publishing exerciser • introspección!!! • varios sistemas de autenticación • no es muy fácil de instalar (de momento) ๏ no es muy fácil de configurar (de momento) David Calavera Conferencia Rails 2007
    109. la api de 11870.com http://11870.com/api
    110. por partes ๏ api de búsqueda ➡ formato openSearch (http://opensearch.org) David Calavera Conferencia Rails 2007
    111. <?xml version=\" 1.0\" encoding=\"UTF-8\"?> <service xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns=\"http://www.w3.org/2007/app \" xml:base=\"http://11870.com/\"> <workspace> <atom:title type=\"text\">11870 workspace</atom:title> <collection href=\"/api/v1/search\"> <atom:title type=\"text\">Search</atom:title> </collection> </workspace> </service> David Calavera Conferencia Rails 2007
    112. por partes • api de búsqueda ๏ api de gestión de contenidos David Calavera Conferencia Rails 2007
    113. <?xml version=\"1.0\" encoding=\"UTF-8\"?> <service xmlns:atom=\"http://www.w3.org/2005/Atom\" xmlns=\" http://www.w3.org/2007/app\" xml:base=\"http://localhost/\"> <workspace> <atom:title type=\"text\">11870 workspace</atom:title> <collection href=\"/api/v1/sites/calavera\"> <atom:title type=\"text\">Sites</atom:title> <accept>application/atom+xml;type=entry</accept> <categories xmlns:oos=\"http://11870.com/api/oos \" href=\"http://localhost/api/v1/lists/calavera\" oos:label=\"lists\"/> <categories xmlns:oos=\" http://11870.com/api/oos\" href=\"http://localhost/api/v1/tags/calavera\" oos:label=\"tags\"/> <categories xmlns:oos=\" http://11870.com/api/oos\" href=\"http://localhost/api/v1/privacy\" oos:label=\"privacy\"/> </collection> <collection href=\"/api/v1/contacts/calavera\"> <atom:title type=\"text\">Contacts</atom:title> <accept>application/atom+xml;type=entry</accept> <categories xmlns:oos=\" http://11870.com/api/oos\" href=\"http://localhost/api/v1/trusted\" oos:label=\"trusted\"/> </collection> <collection href=\"/api/v1/users\"> <atom:title type=\"text\">Users</atom:title> <accept>image/*</accept> <accept>application/atom+xml;type=entry</accept> </collection> <collection href=\"/api/v1/search\"> <atom:title type=\"text\">Search</atom:title> </collection> </workspace> </service> David Calavera Conferencia Rails 2007
    114. más allá de atomPub ๏ sintaxis David Calavera Conferencia Rails 2007
    115. <entry xmlns:app=\"http://www.w3.org/2007/app\" xmlns:oos=\"http://11870.com/api/oos\" xmlns:georss=\"http://www.georss.org/georss/10\" xmlns=\"http://www.w3.org/2005/Atom\" xml:lang=\"en\"> <id>http://11870.com/pro/23474/calavera</id> <title type=\"text\">Apple Store Fifth Avenue</title> <oos:useraddress>767 5th Avenue</oos:useraddress> <oos:url>http://www.apple.com/retail/fifthavenue</oos:url> <oos:telephone>+1 212 3361440</oos:telephone> <oos:locality slug=\"/us/new-york\">New York</oos:locality> <oos:country slug=\"/us\">United States</oos:country> David Calavera Conferencia Rails 2007
    116. más allá de atomPub • sintaxis ๏ autenticación David Calavera Conferencia Rails 2007
    117. más allá de atomPub • sintaxis ๏ autenticación ➡ identificar aplicaciones David Calavera Conferencia Rails 2007
    118. Net::HTTP.start( '11870.com' ) do |http| req = Net::HTTP::Get.new('/api/v1') req['appToken'] = 'el app token que 11870 te ha asignado' digest = Digest::MD5.hexdigest(\"#{req['appToken']}#{la clave secreta}\") req['authSign'] = digest http.request req end David Calavera Conferencia Rails 2007
    119. más allá de atomPub • sintaxis ๏ autenticación ➡ identificar aplicaciones ➡ autenticar usuarios David Calavera Conferencia Rails 2007
    120. request['Authorization'] = 'WSSE profile=\"UsernameToken\"' request['X-WSSE'] = wsse! def wsse! nonce = Array.new(10){ rand(0x1000000) }.pack('I*') nonce_b64 = [nonce].pack(\"m\").chomp now = Time.now.gmtime.strftime(\"%FT%TZ\") digest = [Digest::SHA1.digest(nonce_b64 + now + @password)].pack(\"m\").chomp %Q<UsernameToken Username=\"#{@username}\", PasswordDigest=\"#{digest}\", Nonce=\"#{nonce_b64}\", Created=\"#{now}\"> end David Calavera Conferencia Rails 2007
    121. más allá de atomPub • sintaxis ๏ autenticación ➡ identificar aplicaciones ➡ autenticar usuarios ➡ evolucionará a OAuth (http://oauth.net) David Calavera Conferencia Rails 2007
    122. más allá de atomPub • sintaxis • autenticación ๏ múltiples representaciones David Calavera Conferencia Rails 2007
    123. { \"id\":\"/api/v1/sites/calavera\", \"title\":\"Sites\", \"updated\":\"2007-09-28T07:53:46.000Z\", \"authors\":[{ \"name\":\"calavera\" } ], \"links\":[{ \"href\":\"http://11870.com/api/v1/sites/calavera\", \"rel\":\"self\" },{ \"href\":\"http://11870.com/api/v1/sites/calavera?page=2\", \"rel\":\"next\" } ], \"entries\":[{ \"lang\":\"es\", \"id\":\"http://11870.com/pro/23474/calavera\", \"title\":\"Apple Store Fifth Avenue\", \"summary\":\"en directo\", \"content\":\"estoy ahora mismo en esta... David Calavera Conferencia Rails 2007
    124. más allá de atomPub • sintaxis • autenticación • múltiples representaciones ๏ control de versiones David Calavera Conferencia Rails 2007
    125. ๏ ahora Net::HTTP.start( '11870.com' ) do |http| http.request Net::HTTP::Get.new('/api/v1') end David Calavera Conferencia Rails 2007
    126. • ahora Net::HTTP.start( '11870.com' ) do |http| http.request Net::HTTP::Get.new('/api/v1') end ๏ en un futuro Net::HTTP.start( '11870.com' ) do |http| http.request Net::HTTP::Get.new('/api/v1.5') end David Calavera Conferencia Rails 2007
    127. más allá de atomPub • sintaxis • autenticación • múltiples representaciones • control de versiones ๏ soporte de librerías David Calavera Conferencia Rails 2007
    128. http://code.google.com/p/api-11870/ David Calavera Conferencia Rails 2007
    129. más allá de atomPub • sintaxis • autenticación • múltiples representaciones • control de versiones • soporte de librerías ๏ ¡documentación! David Calavera Conferencia Rails 2007
    130. http://groups.google.com/group/api-11870 David Calavera Conferencia Rails 2007
    131. la api de 11870.com oos4ruby
    132. búsqueda require 'oos4ruby' oos = Oos.new oos.auth_app 'appToken', 'secretKey' oos.search q => 'apple store in new york' oos.search bbox => ['SOUTH', 'WEST', 'NORTH', 'EAST'] oos.search lat => 'LATITUDE', lon => 'LONGITUDE', radius => '3000 METRES' oos.search tags => ['restaurant', 'cheap', 'clean'] David Calavera Conferencia Rails 2007
    133. búsqueda require 'oos4ruby' oos = Oos.new oos.auth_app 'appToken', 'secretKey' oos.search q => 'apple store in new york' oos.search bbox => ['SOUTH', 'WEST', 'NORTH', 'EAST'] oos.search lat => 'LATITUDE', lon => 'LONGITUDE', radius => '3000 METRES' oos.search tags => ['restaurant', 'cheap', 'clean'] David Calavera Conferencia Rails 2007
    134. búsqueda require 'oos4ruby' oos = Oos.new oos.auth_app 'appToken', 'secretKey' oos.search q => 'apple store in new york' oos.search bbox => ['SOUTH', 'WEST', 'NORTH', 'EAST'] oos.search lat => 'LATITUDE', lon => 'LONGITUDE', radius => '3000 METRES' oos.search tags => ['restaurant', 'cheap', 'clean'] David Calavera Conferencia Rails 2007
    135. búsqueda require 'oos4ruby' oos = Oos.new oos.auth_app 'appToken', 'secretKey' oos.search q => 'apple store in new york' oos.search bbox => ['SOUTH', 'WEST', 'NORTH', 'EAST'] oos.search lat => 'LATITUDE', lon => 'LONGITUDE', radius => '3000 METRES' oos.search tags => ['restaurant', 'cheap', 'clean'] David Calavera Conferencia Rails 2007
    136. búsqueda require 'oos4ruby' oos = Oos.new oos.auth_app 'appToken', 'secretKey' oos.search q => 'apple store in new york' oos.search bbox => ['SOUTH', 'WEST', 'NORTH', 'EAST'] oos.search lat => 'LATITUDE', lon => 'LONGITUDE', radius => '3000 METRES' oos.search tags => ['restaurant', 'cheap', 'clean'] David Calavera Conferencia Rails 2007
    137. gestión require 'oos4ruby' oos = Oos.new oos.auth_user 'user email', 'auth token' user = oos.user user.sites.each do |pro| unless pro.multimedia.empty? pro.multimedia.each do |media| puts media.type puts media.src end end end user.contacts.create! :slug => 'calavera', :trusted => 'true' user.update_avatar! '/Users/david/skull.png' David Calavera Conferencia Rails 2007
    138. gestión require 'oos4ruby' oos = Oos.new oos.auth_user 'user email', 'auth token' user = oos.user user.sites.each do |pro| unless pro.multimedia.empty? pro.multimedia.each do |media| puts media.type puts media.src end end end user.contacts.create! :slug => 'calavera', :trusted => 'true' user.update_avatar! '/Users/david/skull.png' David Calavera Conferencia Rails 2007
    139. gestión require 'oos4ruby' oos = Oos.new oos.auth_user 'user email', 'auth token' user = oos.user user.sites.each do |pro| unless pro.multimedia.empty? pro.multimedia.each do |media| puts media.type puts media.src end end end user.contacts.create! :slug => 'calavera', :trusted => 'true' user.update_avatar! '/Users/david/skull.png' David Calavera Conferencia Rails 2007
    140. gestión require 'oos4ruby' oos = Oos.new oos.auth_user 'user email', 'auth token' user = oos.user user.sites.each do |pro| unless pro.multimedia.empty? pro.multimedia.each do |media| puts media.type puts media.src end end end user.contacts.create! :slug => 'calavera', :trusted => 'true' user.update_avatar! '/Users/david/skull.png' David Calavera Conferencia Rails 2007
    141. ¿...?
    142. muchas gracias http://thinkincode.net

    David CalaveraDavid Calavera, 2 years ago

    custom

    2497 views, 0 favs, 6 embeds more stats

    More Info

    CC Attribution-ShareAlike LicenseCC Attribution-ShareAlike License

    Go to text version
    • Total Views 2497
      • 2272 on SlideShare
      • 225 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 27
    Most viewed embeds
    • 118 views on http://thinkincode.net
    • 63 views on http://11870.com
    • 41 views on http://www.thinkincode.net
    • 1 views on http://www.netvibes.com
    • 1 views on http://64.233.183.104

    more

    All embeds
    • 118 views on http://thinkincode.net
    • 63 views on http://11870.com
    • 41 views on http://www.thinkincode.net
    • 1 views on http://www.netvibes.com
    • 1 views on http://64.233.183.104
    • 1 views on http://thinkincode.org

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as innappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel

    Categories

    Groups / Events