Upload
kerstin-puschke
View
1.087
Download
1
Tags:
Embed Size (px)
DESCRIPTION
short introductory talk about oembed and how to turn a rails app into an oembed provider. ruby usergroup hamurg, 2013
Citation preview
oEmbedon rails
Kerstin Puschke
Ruby Usergroup Hamburg
January 2013
K. Puschke (Ruby Usergroup HH) oembed January 2013 1 / 17
License
CC BY-SA 3.0Creative CommonsAttribution ShareAlike 3.0http://creativecommons.org/licenses/by-sa/3.0/
K. Puschke (Ruby Usergroup HH) oembed January 2013 2 / 17
Who am I
software engineer at XING
perl and rails@titanoboa42 on twittertitanoboa on githubtitanoboa on stackoverflow
K. Puschke (Ruby Usergroup HH) oembed January 2013 3 / 17
Who am I
software engineer at XINGperl and rails
@titanoboa42 on twittertitanoboa on githubtitanoboa on stackoverflow
K. Puschke (Ruby Usergroup HH) oembed January 2013 3 / 17
Who am I
software engineer at XINGperl and rails@titanoboa42 on twitter
titanoboa on githubtitanoboa on stackoverflow
K. Puschke (Ruby Usergroup HH) oembed January 2013 3 / 17
Who am I
software engineer at XINGperl and rails@titanoboa42 on twittertitanoboa on github
titanoboa on stackoverflow
K. Puschke (Ruby Usergroup HH) oembed January 2013 3 / 17
Who am I
software engineer at XINGperl and rails@titanoboa42 on twittertitanoboa on githubtitanoboa on stackoverflow
K. Puschke (Ruby Usergroup HH) oembed January 2013 3 / 17
third-party media embedding
Automated third-party media embeddingturn a url into an embedded representation of the resourcee.g. magically display embedded video instead of link
K. Puschke (Ruby Usergroup HH) oembed January 2013 4 / 17
third-party media embedding
screenscraping is a maintenance nightmare
provider specific APIs:additional effort for each additional provideroEmbed standardizes embedding
K. Puschke (Ruby Usergroup HH) oembed January 2013 5 / 17
third-party media embedding
screenscraping is a maintenance nightmareprovider specific APIs:additional effort for each additional provider
oEmbed standardizes embedding
K. Puschke (Ruby Usergroup HH) oembed January 2013 5 / 17
third-party media embedding
screenscraping is a maintenance nightmareprovider specific APIs:additional effort for each additional provideroEmbed standardizes embedding
K. Puschke (Ruby Usergroup HH) oembed January 2013 5 / 17
oEmbed
open embed format
open web standard for third-party media embeddingspecs published in 2008by Leah Culver (Pownce), Cal Henderson (Flickr), Mike Malone(Pownce), and Richard Crowley (OpenDNS)
K. Puschke (Ruby Usergroup HH) oembed January 2013 6 / 17
oEmbed
open embed formatopen web standard for third-party media embedding
specs published in 2008by Leah Culver (Pownce), Cal Henderson (Flickr), Mike Malone(Pownce), and Richard Crowley (OpenDNS)
K. Puschke (Ruby Usergroup HH) oembed January 2013 6 / 17
oEmbed
open embed formatopen web standard for third-party media embeddingspecs published in 2008
by Leah Culver (Pownce), Cal Henderson (Flickr), Mike Malone(Pownce), and Richard Crowley (OpenDNS)
K. Puschke (Ruby Usergroup HH) oembed January 2013 6 / 17
oEmbed
open embed formatopen web standard for third-party media embeddingspecs published in 2008by Leah Culver (Pownce), Cal Henderson (Flickr), Mike Malone(Pownce), and Richard Crowley (OpenDNS)
K. Puschke (Ruby Usergroup HH) oembed January 2013 6 / 17
oEmbed providers
youtube
vimeoflickrtwitterslidesharespeakerdeckintermediaries, e.g. embed.ly
K. Puschke (Ruby Usergroup HH) oembed January 2013 7 / 17
oEmbed providers
youtubevimeo
flickrtwitterslidesharespeakerdeckintermediaries, e.g. embed.ly
K. Puschke (Ruby Usergroup HH) oembed January 2013 7 / 17
oEmbed providers
youtubevimeoflickr
twitterslidesharespeakerdeckintermediaries, e.g. embed.ly
K. Puschke (Ruby Usergroup HH) oembed January 2013 7 / 17
oEmbed providers
youtubevimeoflickrtwitter
slidesharespeakerdeckintermediaries, e.g. embed.ly
K. Puschke (Ruby Usergroup HH) oembed January 2013 7 / 17
oEmbed providers
youtubevimeoflickrtwitterslideshare
speakerdeckintermediaries, e.g. embed.ly
K. Puschke (Ruby Usergroup HH) oembed January 2013 7 / 17
oEmbed providers
youtubevimeoflickrtwitterslidesharespeakerdeck
intermediaries, e.g. embed.ly
K. Puschke (Ruby Usergroup HH) oembed January 2013 7 / 17
oEmbed providers
youtubevimeoflickrtwitterslidesharespeakerdeckintermediaries, e.g. embed.ly
K. Puschke (Ruby Usergroup HH) oembed January 2013 7 / 17
oEmbed consumers
drupal
wordpresselggdiasporaxing
K. Puschke (Ruby Usergroup HH) oembed January 2013 8 / 17
oEmbed consumers
drupalwordpress
elggdiasporaxing
K. Puschke (Ruby Usergroup HH) oembed January 2013 8 / 17
oEmbed consumers
drupalwordpresselgg
diasporaxing
K. Puschke (Ruby Usergroup HH) oembed January 2013 8 / 17
oEmbed consumers
drupalwordpresselggdiaspora
K. Puschke (Ruby Usergroup HH) oembed January 2013 8 / 17
oEmbed consumers
drupalwordpresselggdiasporaxing
K. Puschke (Ruby Usergroup HH) oembed January 2013 8 / 17
oEmbed spec
http GET request to API endpoint with query param url
optional additional params: maxwidth, maxheight, formatresponse format xml or jsoninforms consumer how to embed, e.g. gives html snippet
K. Puschke (Ruby Usergroup HH) oembed January 2013 9 / 17
oEmbed spec
http GET request to API endpoint with query param url
optional additional params: maxwidth, maxheight, format
response format xml or jsoninforms consumer how to embed, e.g. gives html snippet
K. Puschke (Ruby Usergroup HH) oembed January 2013 9 / 17
oEmbed spec
http GET request to API endpoint with query param url
optional additional params: maxwidth, maxheight, formatresponse format xml or json
informs consumer how to embed, e.g. gives html snippet
K. Puschke (Ruby Usergroup HH) oembed January 2013 9 / 17
oEmbed spec
http GET request to API endpoint with query param url
optional additional params: maxwidth, maxheight, formatresponse format xml or jsoninforms consumer how to embed, e.g. gives html snippet
K. Puschke (Ruby Usergroup HH) oembed January 2013 9 / 17
Example: video
http://www.youtube.com/oembed?url=http://www.youtube.com/watch?v=zwk1KvnZxGw
{"author_name": "XINGcom","html": "<iframe width=\"480\" height=\"270\" src=..."version": "1.0","author_url": "http://www.youtube.com/user/XING..."thumbnail_width": 480,"height": 270,"provider_url": "http://www.youtube.com/","type": "video","width": 480,"thumbnail_height": 360,"thumbnail_url": "http://i3.ytimg.com/vi/..."provider_name": "YouTube","title": "Was ist XING?"
}K. Puschke (Ruby Usergroup HH) oembed January 2013 10 / 17
Example response: photo
{ "type": "photo","title": "Ba..."author_name": "..."author_url": "http://www.flickr.com/photos/..."width": "1024","height": "768","url": "http://farm4.staticflickr.com/3040/2362..."web_page": "http://www.flickr.com/photos/be..."thumbnail_url": "http://farm4.staticfli..."thumbnail_width": 75,"thumbnail_height": 75,"web_page_short_url": "http://flic.kr/p/4..."license": "All Rights Reserved","version": "1.0","cache_age": 3600,"provider_name": "Flickr",
K. Puschke (Ruby Usergroup HH) oembed January 2013 11 / 17
oEmbed gems
quite a few consumer gems
oembed-provider (rails 2 only)oembed-provider-engine (rails 3 only)mountable rails 3 engine, heavily based on oembed-provider
K. Puschke (Ruby Usergroup HH) oembed January 2013 12 / 17
oEmbed gems
quite a few consumer gemsoembed-provider (rails 2 only)
oembed-provider-engine (rails 3 only)mountable rails 3 engine, heavily based on oembed-provider
K. Puschke (Ruby Usergroup HH) oembed January 2013 12 / 17
oEmbed gems
quite a few consumer gemsoembed-provider (rails 2 only)oembed-provider-engine (rails 3 only)mountable rails 3 engine, heavily based on oembed-provider
K. Puschke (Ruby Usergroup HH) oembed January 2013 12 / 17
oembed-provider-engineturning your app into an oEmbed provider
mount OembedProviderEngine::Engine in routes.rbto provide route to API endpoint
your media item’s model
needs a method for each field to be part of the oEmbed response,e.g.html, thumbnail_url,. . .include OembedProviderEngine::OembedProvidablecall oembed_providable_as with media type, e.g.oembed_providable_as :video
K. Puschke (Ruby Usergroup HH) oembed January 2013 13 / 17
oembed-provider-engineturning your app into an oEmbed provider
mount OembedProviderEngine::Engine in routes.rbto provide route to API endpointyour media item’s model
needs a method for each field to be part of the oEmbed response,e.g.html, thumbnail_url,. . .include OembedProviderEngine::OembedProvidablecall oembed_providable_as with media type, e.g.oembed_providable_as :video
K. Puschke (Ruby Usergroup HH) oembed January 2013 13 / 17
oembed-provider-engineturning your app into an oEmbed provider
mount OembedProviderEngine::Engine in routes.rbto provide route to API endpointyour media item’s model
needs a method for each field to be part of the oEmbed response,e.g.html, thumbnail_url,. . .
include OembedProviderEngine::OembedProvidablecall oembed_providable_as with media type, e.g.oembed_providable_as :video
K. Puschke (Ruby Usergroup HH) oembed January 2013 13 / 17
oembed-provider-engineturning your app into an oEmbed provider
mount OembedProviderEngine::Engine in routes.rbto provide route to API endpointyour media item’s model
needs a method for each field to be part of the oEmbed response,e.g.html, thumbnail_url,. . .include OembedProviderEngine::OembedProvidable
call oembed_providable_as with media type, e.g.oembed_providable_as :video
K. Puschke (Ruby Usergroup HH) oembed January 2013 13 / 17
oembed-provider-engineturning your app into an oEmbed provider
mount OembedProviderEngine::Engine in routes.rbto provide route to API endpointyour media item’s model
needs a method for each field to be part of the oEmbed response,e.g.html, thumbnail_url,. . .include OembedProviderEngine::OembedProvidablecall oembed_providable_as with media type, e.g.oembed_providable_as :video
K. Puschke (Ruby Usergroup HH) oembed January 2013 13 / 17
oembed-provider-engineinner workings
oembed_providable_as creates scoped OembedResponsemodel, e.g. MediaItem::OembedResponse
response model has attributes for each field to be included intothe responseits initializer sets attributes to the respective values from the app’smedia itemhas methods to format the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 14 / 17
oembed-provider-engineinner workings
oembed_providable_as creates scoped OembedResponsemodel, e.g. MediaItem::OembedResponseresponse model has attributes for each field to be included intothe response
its initializer sets attributes to the respective values from the app’smedia itemhas methods to format the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 14 / 17
oembed-provider-engineinner workings
oembed_providable_as creates scoped OembedResponsemodel, e.g. MediaItem::OembedResponseresponse model has attributes for each field to be included intothe responseits initializer sets attributes to the respective values from the app’smedia item
has methods to format the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 14 / 17
oembed-provider-engineinner workings
oembed_providable_as creates scoped OembedResponsemodel, e.g. MediaItem::OembedResponseresponse model has attributes for each field to be included intothe responseits initializer sets attributes to the respective values from the app’smedia itemhas methods to format the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 14 / 17
oembed-provider-engineinner workings
API endpoint routes to engine’s controller
param url parsed to determine media item modelmedia item object initializedscoped response model created (if not already existing)response object initializedresponse formatted and returned
K. Puschke (Ruby Usergroup HH) oembed January 2013 15 / 17
oembed-provider-engineinner workings
API endpoint routes to engine’s controllerparam url parsed to determine media item model
media item object initializedscoped response model created (if not already existing)response object initializedresponse formatted and returned
K. Puschke (Ruby Usergroup HH) oembed January 2013 15 / 17
oembed-provider-engineinner workings
API endpoint routes to engine’s controllerparam url parsed to determine media item modelmedia item object initializedscoped response model created (if not already existing)
response object initializedresponse formatted and returned
K. Puschke (Ruby Usergroup HH) oembed January 2013 15 / 17
oembed-provider-engineinner workings
API endpoint routes to engine’s controllerparam url parsed to determine media item modelmedia item object initializedscoped response model created (if not already existing)response object initialized
response formatted and returned
K. Puschke (Ruby Usergroup HH) oembed January 2013 15 / 17
oembed-provider-engineinner workings
API endpoint routes to engine’s controllerparam url parsed to determine media item modelmedia item object initializedscoped response model created (if not already existing)response object initializedresponse formatted and returned
K. Puschke (Ruby Usergroup HH) oembed January 2013 15 / 17
oembed-provider-enginetodo
still very rails 2-ish :-( needs polishing
proper handling of authorizationcachingimprove test coverage, maybe migrate from shoulda to rspecallow for custom fields to be added to the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 16 / 17
oembed-provider-enginetodo
still very rails 2-ish :-( needs polishingproper handling of authorization
cachingimprove test coverage, maybe migrate from shoulda to rspecallow for custom fields to be added to the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 16 / 17
oembed-provider-enginetodo
still very rails 2-ish :-( needs polishingproper handling of authorizationcaching
improve test coverage, maybe migrate from shoulda to rspecallow for custom fields to be added to the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 16 / 17
oembed-provider-enginetodo
still very rails 2-ish :-( needs polishingproper handling of authorizationcachingimprove test coverage, maybe migrate from shoulda to rspec
allow for custom fields to be added to the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 16 / 17
oembed-provider-enginetodo
still very rails 2-ish :-( needs polishingproper handling of authorizationcachingimprove test coverage, maybe migrate from shoulda to rspecallow for custom fields to be added to the response
K. Puschke (Ruby Usergroup HH) oembed January 2013 16 / 17
Feedback & Co
Questions, comments,. . .twitter: @titanoboa42
email: [email protected]: https://github.com/xing/oembed_provider_engine. . . we are happy to accept pull requests
K. Puschke (Ruby Usergroup HH) oembed January 2013 17 / 17
Feedback & Co
Questions, comments,. . .twitter: @titanoboa42email: [email protected]
github: https://github.com/xing/oembed_provider_engine. . . we are happy to accept pull requests
K. Puschke (Ruby Usergroup HH) oembed January 2013 17 / 17
Feedback & Co
Questions, comments,. . .twitter: @titanoboa42email: [email protected]: https://github.com/xing/oembed_provider_engine. . . we are happy to accept pull requests
K. Puschke (Ruby Usergroup HH) oembed January 2013 17 / 17