From b71829e970cb7a1fe667f4b3a180848cd87aa04a Mon Sep 17 00:00:00 2001 From: Marcos Wright-Kuhns Date: Thu, 24 Mar 2016 23:21:59 -0700 Subject: [PATCH] Break all built-in OEmbed::Providers into separate files This makes rubocop more happy *and* actually makes organization a bit simpler. This commit is expected to be broken. --- .rubocop.yml | 1 + CHANGELOG.rdoc | 10 + lib/oembed/providers.rb | 267 ------------------ lib/oembed/providers/aggregators/embedly.rb | 18 ++ .../{ => aggregators}/embedly_urls.yml | 0 lib/oembed/providers/default/facebook.rb | 22 ++ lib/oembed/providers/default/flickr.rb | 11 + lib/oembed/providers/default/hulu.rb | 8 + lib/oembed/providers/default/imgur.rb | 9 + lib/oembed/providers/default/instagram.rb | 14 + lib/oembed/providers/default/movie_clips.rb | 8 + .../providers/default/poll_everywhere.rb | 10 + lib/oembed/providers/default/scribd.rb | 8 + lib/oembed/providers/default/slideshare.rb | 10 + lib/oembed/providers/default/sound_cloud.rb | 10 + lib/oembed/providers/default/spotify.rb | 14 + lib/oembed/providers/default/tumblr.rb | 9 + lib/oembed/providers/default/twitter.rb | 11 + lib/oembed/providers/default/viddler.rb | 9 + lib/oembed/providers/default/vimeo.rb | 10 + lib/oembed/providers/default/vine.rb | 10 + lib/oembed/providers/default/youtube.rb | 20 ++ lib/oembed/providers/minor/clearspring.rb | 10 + lib/oembed/providers/minor/kinomap.rb | 9 + lib/oembed/providers/minor/mlg_tv.rb | 10 + lib/oembed/providers/minor/my_opera.rb | 9 + lib/oembed/providers/minor/nfb_canada.rb | 8 + lib/oembed/providers/minor/revision3.rb | 8 + lib/oembed/providers/minor/twenty_three.rb | 8 + lib/oembed/providers/oohembed_urls.yml | 17 -- lib/tasks/oembed.rake | 20 -- 31 files changed, 284 insertions(+), 304 deletions(-) create mode 100644 lib/oembed/providers/aggregators/embedly.rb rename lib/oembed/providers/{ => aggregators}/embedly_urls.yml (100%) create mode 100644 lib/oembed/providers/default/facebook.rb create mode 100644 lib/oembed/providers/default/flickr.rb create mode 100644 lib/oembed/providers/default/hulu.rb create mode 100644 lib/oembed/providers/default/imgur.rb create mode 100644 lib/oembed/providers/default/instagram.rb create mode 100644 lib/oembed/providers/default/movie_clips.rb create mode 100644 lib/oembed/providers/default/poll_everywhere.rb create mode 100644 lib/oembed/providers/default/scribd.rb create mode 100644 lib/oembed/providers/default/slideshare.rb create mode 100644 lib/oembed/providers/default/sound_cloud.rb create mode 100644 lib/oembed/providers/default/spotify.rb create mode 100644 lib/oembed/providers/default/tumblr.rb create mode 100644 lib/oembed/providers/default/twitter.rb create mode 100644 lib/oembed/providers/default/viddler.rb create mode 100644 lib/oembed/providers/default/vimeo.rb create mode 100644 lib/oembed/providers/default/vine.rb create mode 100644 lib/oembed/providers/default/youtube.rb create mode 100644 lib/oembed/providers/minor/clearspring.rb create mode 100644 lib/oembed/providers/minor/kinomap.rb create mode 100644 lib/oembed/providers/minor/mlg_tv.rb create mode 100644 lib/oembed/providers/minor/my_opera.rb create mode 100644 lib/oembed/providers/minor/nfb_canada.rb create mode 100644 lib/oembed/providers/minor/revision3.rb create mode 100644 lib/oembed/providers/minor/twenty_three.rb delete mode 100644 lib/oembed/providers/oohembed_urls.yml diff --git a/.rubocop.yml b/.rubocop.yml index 10b40a2..e030af2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -12,6 +12,7 @@ Style/SpecialGlobalVars: Style/Documentation: Exclude: - lib/oembed/version.rb + - lib/oembed/providers/*.rb # Because I perefer {...} blocks in rspec Style/BlockDelimiters: diff --git a/CHANGELOG.rdoc b/CHANGELOG.rdoc index 52cd36e..5f37e05 100644 --- a/CHANGELOG.rdoc +++ b/CHANGELOG.rdoc @@ -10,13 +10,23 @@ * OEmbed::Provider#build * OEmbed::Provider#raw * OEmbed::ProviderDiscovery#raw +* Removed the following built-in OEmbed::Providers + * OEmbed::Providers::OohEmbed + * OEmbed::Providers::Skitch + * OEmbed::Providers::Qik + * OEmbed::Providers::Yfrog === New * Begin using rubocop to enforce code consistency. +* Added the following built-in OEmbed::Providers + * OEmbed::Providers::Kinomap (Minor) + === Changes +* Divided built-in OEmbed::Providers into categories: + Default, Minor, & Aggregators * Lots of internal refactoring & code cleanup to reach base rubocop standards. === Fixes diff --git a/lib/oembed/providers.rb b/lib/oembed/providers.rb index 8265ff0..2bc5535 100644 --- a/lib/oembed/providers.rb +++ b/lib/oembed/providers.rb @@ -131,272 +131,5 @@ def add_official_provider(provider_class, sub_type = nil) @@to_register[sub_type.to_s] << provider_class end end - - # Custom providers: - - # Provider for youtube.com - # http://apiblog.youtube.com/2009/10/oembed-support.html - # - # Options: - # * To get the iframe embed code - # OEmbed::Providers::Youtube.endpoint += "?iframe=1" - # * To get the flash/object embed code - # OEmbed::Providers::Youtube.endpoint += "?iframe=0" - # * To require https embed code - # OEmbed::Providers::Youtube.endpoint += "?scheme=https" - Youtube = OEmbed::Provider.new('https://www.youtube.com/oembed?scheme=https') - Youtube << 'http://*.youtube.com/*' - Youtube << 'https://*.youtube.com/*' - Youtube << 'http://*.youtu.be/*' - Youtube << 'https://*.youtu.be/*' - add_official_provider(Youtube) - - # Provider for flickr.com - Flickr = OEmbed::Provider.new('https://www.flickr.com/services/oembed/') - Flickr << 'http://*.flickr.com/*' - Flickr << 'https://*.flickr.com/*' - Flickr << 'http://flic.kr/*' - Flickr << 'https://flic.kr/*' - add_official_provider(Flickr) - - # Provider for viddler.com - # http://developers.viddler.com/documentation/services/oembed/ - Viddler = OEmbed::Provider.new('http://lab.viddler.com/services/oembed/') - Viddler << 'http://*.viddler.com/*' - add_official_provider(Viddler) - - # Provider for qik.com - # http://qik.com/blog/qik-embraces-oembed-for-embedding-videos/ - Qik = OEmbed::Provider.new('http://qik.com/api/oembed.{format}') - Qik << 'http://qik.com/*' - Qik << 'http://qik.com/video/*' - add_official_provider(Qik) - - # Provider for revision3.com - Revision3 = OEmbed::Provider.new('http://revision3.com/api/oembed/') - Revision3 << 'http://*.revision3.com/*' - add_official_provider(Revision3) - - # Provider for hulu.com - Hulu = OEmbed::Provider.new('http://www.hulu.com/api/oembed.{format}') - Hulu << 'http://www.hulu.com/watch/*' - add_official_provider(Hulu) - - # Provider for vimeo.com - # https://developer.vimeo.com/apis/oembed - Vimeo = OEmbed::Provider.new('https://vimeo.com/api/oembed.{format}') - Vimeo << 'http://*.vimeo.com/*' - Vimeo << 'https://*.vimeo.com/*' - add_official_provider(Vimeo) - - # Provider for twitter.com - # https://dev.twitter.com/rest/reference/get/statuses/oembed - Twitter = OEmbed::Provider.new('https://api.twitter.com/1/statuses/oembed.{format}') - Twitter << 'https://*.twitter.com/*/status/*' - add_official_provider(Twitter) - - # Provider for vine.co - # https://dev.twitter.com/web/vine/oembed - Vine = OEmbed::Provider.new('https://vine.co/oembed.{format}') - Vine << 'http://*.vine.co/v/*' - Vine << 'https://*.vine.co/v/*' - add_official_provider(Vine) - - # Provider for instagram.com - # https://instagr.am/developer/embedding/ - Instagram = OEmbed::Provider.new('https://api.instagram.com/oembed', :json) - Instagram << 'http://instagr.am/p/*' - Instagram << 'http://instagram.com/p/*' - Instagram << 'http://www.instagram.com/p/*' - Instagram << 'https://instagr.am/p/*' - Instagram << 'https://instagram.com/p/*' - Instagram << 'https://www.instagram.com/p/*' - add_official_provider(Instagram) - - # Providers for Facebook Posts & Videos - # https://developers.facebook.com/docs/plugins/oembed-endpoints - FacebookPost = OEmbed::Provider.new('https://www.facebook.com/plugins/post/oembed.json/', :json) - FacebookPost << 'https://www.facebook.com/*/posts/*' - FacebookPost << 'https://www.facebook.com/*/activity/*' - FacebookPost << 'https://www.facebook.com/photo*' - FacebookPost << 'https://www.facebook.com/photos*' - FacebookPost << 'https://www.facebook.com/*/photos*' - FacebookPost << 'https://www.facebook.com/permalink*' - FacebookPost << 'https://www.facebook.com/media*' - FacebookPost << 'https://www.facebook.com/questions*' - FacebookPost << 'https://www.facebook.com/notes*' - add_official_provider(FacebookPost) - - FacebookVideo = OEmbed::Provider.new('https://www.facebook.com/plugins/video/oembed.json/', :json) - FacebookVideo << 'https://www.facebook.com/*/videos/*' - FacebookVideo << 'https://www.facebook.com/video*' - add_official_provider(FacebookVideo) - - # Provider for slideshare.net - # http://www.slideshare.net/developers/oembed - Slideshare = OEmbed::Provider.new('https://www.slideshare.net/api/oembed/2') - Slideshare << 'http://www.slideshare.net/*/*' - Slideshare << 'http://www.slideshare.net/mobile/*/*' - add_official_provider(Slideshare) - - # Provider for yfrog - # http://code.google.com/p/imageshackapi/wiki/OEMBEDSupport - Yfrog = OEmbed::Provider.new('https://www.yfrog.com/api/oembed', :json) - Yfrog << 'http://yfrog.com/*' - add_official_provider(Yfrog) - - # Provider for imgur.com - Imgur = OEmbed::Provider.new('https://api.imgur.com/oembed.{format}') - Imgur << 'https://*.imgur.com/gallery/*' - Imgur << 'http://*.imgur.com/gallery/*' - add_official_provider(Imgur) - - # provider for mlg-tv - # http://tv.majorleaguegaming.com/oembed - MlgTv = OEmbed::Provider.new('http://tv.majorleaguegaming.com/oembed') - MlgTv << 'http://tv.majorleaguegaming.com/video/*' - MlgTv << 'http://mlg.tv/video/*' - add_official_provider(MlgTv) - - # pownce.com closed in 2008 - # Pownce = OEmbed::Provider.new("http://api.pownce.com/2.1/oembed.{format}") - # Pownce << "http://*.pownce.com/*" - # add_official_provider(Pownce) - - # Provider for polleverywhere.com - PollEverywhere = OEmbed::Provider.new('http://www.polleverywhere.com/services/oembed/') - PollEverywhere << 'http://www.polleverywhere.com/polls/*' - PollEverywhere << 'http://www.polleverywhere.com/multiple_choice_polls/*' - PollEverywhere << 'http://www.polleverywhere.com/free_text_polls/*' - add_official_provider(PollEverywhere) - - # Provider for my.opera.com - # http://my.opera.com/devblog/blog/2008/12/02/embedding-my-opera-content-oembed - MyOpera = OEmbed::Provider.new('http://my.opera.com/service/oembed', :json) - MyOpera << 'http://my.opera.com/*' - add_official_provider(MyOpera) - - # Provider for clearspring.com - ClearspringWidgets = OEmbed::Provider.new('http://widgets.clearspring.com/widget/v1/oembed/') - ClearspringWidgets << 'http://www.clearspring.com/widgets/*' - add_official_provider(ClearspringWidgets) - - # Provider for nfb.ca - NFBCanada = OEmbed::Provider.new('http://www.nfb.ca/remote/services/oembed/') - NFBCanada << 'http://*.nfb.ca/film/*' - add_official_provider(NFBCanada) - - # Provider for scribd.com - Scribd = OEmbed::Provider.new('https://www.scribd.com/services/oembed') - Scribd << 'http://*.scribd.com/*' - add_official_provider(Scribd) - - # Provider for movieclips.com - MovieClips = OEmbed::Provider.new('http://movieclips.com/services/oembed/') - MovieClips << 'http://movieclips.com/watch/*/*/' - add_official_provider(MovieClips) - - # Provider for 23hq.com - TwentyThree = OEmbed::Provider.new('http://www.23hq.com/23/oembed') - TwentyThree << 'http://www.23hq.com/*' - add_official_provider(TwentyThree) - - # Provider for soundcloud.com - # http://developers.soundcloud.com/docs/oembed - SoundCloud = OEmbed::Provider.new('https://soundcloud.com/oembed', :json) - SoundCloud << 'http://*.soundcloud.com/*' - SoundCloud << 'https://*.soundcloud.com/*' - add_official_provider(SoundCloud) - - # Provider for spotify.com - # https://twitter.com/nicklas2k/status/330094611202723840 - # http://blog.embed.ly/post/45149936446/oembed-for-spotify - Spotify = OEmbed::Provider.new('https://embed.spotify.com/oembed/') - Spotify << 'http://open.spotify.com/*' - Spotify << 'https://open.spotify.com/*' - Spotify << 'http://play.spotify.com/*' - Spotify << 'https://play.spotify.com/*' - Spotify << /^spotify\:(.*?)/ - add_official_provider(Spotify) - - # Provider for skitch.com - # http://skitch.com/oembed/%3C/endpoint - Skitch = OEmbed::Provider.new('http://skitch.com/oembed') - Skitch << 'http://*.skitch.com/*' - Skitch << 'https://*.skitch.com/*' - add_official_provider(Skitch) - - # Provider for tumblr.com - Tumblr = OEmbed::Provider.new('http://www.tumblr.com/oembed/1.0/', :json) - Tumblr << 'http://*.tumblr.com/post/*' - Tumblr << 'https://*.tumblr.com/post/*' - add_official_provider(Tumblr) - - ## Provider for clikthrough.com - # http://corporate.clikthrough.com/wp/?p=275 - # Clickthrough = OEmbed::Provider.new("http://www.clikthrough.com/services/oembed/") - # Clickthrough << "http://*.clikthrough.com/theater/video/*" - # add_official_provider(Clickthrough) - - ## Provider for kinomap.com - # http://www.kinomap.com/#!oEmbed - # Kinomap = OEmbed::Provider.new("http://www.kinomap.com/oembed") - # Kinomap << "http://www.kinomap.com/*" - # add_official_provider(Kinomap) - - # Provider for oohembed.com, which is a provider aggregator. See - # OEmbed::Providers::OohEmbed.urls for a full list of supported url schemas. - # Embed.ly has taken over the oohembed.com domain and as of July 20 all oohEmbed - # request will require you use an API key. For details on the transition see - # http://blog.embed.ly/oohembed - OohEmbed = OEmbed::Provider.new('http://oohembed.com/oohembed/', :json) - OohEmbed << 'http://*.5min.com/Video/*' # micro-video host - OohEmbed << %r{http://(.*?).amazon.(com|co.uk|de|ca|jp)/(.*?)/(gp/product|o/ASIN|obidos/ASIN|dp)/(.*?)} # Online product shopping - OohEmbed << 'http://*.blip.tv/*' - OohEmbed << 'http://*.clikthrough.com/theater/video/*' - OohEmbed << 'http://*.collegehumor.com/video:*' # Comedic & original videos - OohEmbed << 'http://*.thedailyshow.com/video/*' # Syndicated show - OohEmbed << 'http://*.dailymotion.com/*' - OohEmbed << 'http://dotsub.com/view/*' - OohEmbed << 'http://*.flickr.com/photos/*' - OohEmbed << 'http://*.funnyordie.com/videos/*' # Comedy video host - OohEmbed << 'http://video.google.com/videoplay?*' # Video hosting - OohEmbed << 'http://www.hulu.com/watch/*' - OohEmbed << 'http://*.kinomap.com/*' - OohEmbed << 'http://*.livejournal.com/' - OohEmbed << 'http://*.metacafe.com/watch/*' # Video host - OohEmbed << 'http://*.nfb.ca/film/*' - OohEmbed << 'http://*.photobucket.com/albums/*' - OohEmbed << 'http://*.photobucket.com/groups/*' - OohEmbed << 'http://*.phodroid.com/*/*/*' # Photo host - OohEmbed << 'http://qik.com/*' - OohEmbed << 'http://*.revision3.com/*' - OohEmbed << 'http://*.scribd.com/*' - OohEmbed << 'http://*.slideshare.net/*' # Share presentations online - OohEmbed << 'http://*.twitpic.com/*' # Picture hosting for Twitter - OohEmbed << 'http://twitter.com/*/statuses/*' # Mirco-blogging network - OohEmbed << 'http://*.viddler.com/explore/*' - OohEmbed << 'http://www.vimeo.com/*' - OohEmbed << 'http://www.vimeo.com/groups/*/videos/*' - OohEmbed << 'http://*.wikipedia.org/wiki/*' # Online encyclopedia - OohEmbed << 'http://*.wordpress.com/*/*/*/*' # Blogging Engine & community - OohEmbed << 'http://*.xkcd.com/*' # A hilarious stick figure comic - OohEmbed << %r{http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/(.*?)} # image & video hosting - OohEmbed << 'http://*.youtube.com/watch*' - - # Provider for Embedly.com, which is a provider aggregator. See - # OEmbed::Providers::Embedly.urls for a full list of supported url schemas. - # http://embed.ly/docs/endpoints/1/oembed - # - # You can append your Embed.ly API key to the provider so that all requests are signed - # OEmbed::Providers::Embedly.endpoint += "?key=#{my_embedly_key}" - # - # If you don't yet have an API key you'll need to sign up here: http://embed.ly/pricing - Embedly = OEmbed::Provider.new('http://api.embed.ly/1/oembed') - # Add all known URL regexps for Embedly. To update this list run `rake oembed:update_embedly` - YAML.load_file(File.join(File.dirname(__FILE__), '/providers/embedly_urls.yml')).each do |url| - Embedly << url - end - add_official_provider(Embedly, :aggregators) end end diff --git a/lib/oembed/providers/aggregators/embedly.rb b/lib/oembed/providers/aggregators/embedly.rb new file mode 100644 index 0000000..71cc16b --- /dev/null +++ b/lib/oembed/providers/aggregators/embedly.rb @@ -0,0 +1,18 @@ +module OEmbed + class Providers + # Provider for Embedly.com, which is a provider aggregator. See + # OEmbed::Providers::Embedly.urls for a full list of supported url schemas. + # http://embed.ly/docs/endpoints/1/oembed + # + # You can append your Embed.ly API key to the provider so that all requests are signed + # OEmbed::Providers::Embedly.endpoint += "?key=#{my_embedly_key}" + # + # If you don't yet have an API key you'll need to sign up here: http://embed.ly/pricing + Embedly = OEmbed::Provider.new('http://api.embed.ly/1/oembed') + # Add all known URL regexps for Embedly. To update this list run `rake oembed:update_embedly` + YAML.load_file(File.join(File.dirname(__FILE__), '/embedly_urls.yml')).each do |url| + Embedly << url + end + add_official_provider(Embedly, :aggregators) + end +end diff --git a/lib/oembed/providers/embedly_urls.yml b/lib/oembed/providers/aggregators/embedly_urls.yml similarity index 100% rename from lib/oembed/providers/embedly_urls.yml rename to lib/oembed/providers/aggregators/embedly_urls.yml diff --git a/lib/oembed/providers/default/facebook.rb b/lib/oembed/providers/default/facebook.rb new file mode 100644 index 0000000..b26e4c1 --- /dev/null +++ b/lib/oembed/providers/default/facebook.rb @@ -0,0 +1,22 @@ +module OEmbed + class Providers + # Providers for Facebook Posts & Videos + # https://developers.facebook.com/docs/plugins/oembed-endpoints + FacebookPost = OEmbed::Provider.new('https://www.facebook.com/plugins/post/oembed.json/', :json) + FacebookPost << 'https://www.facebook.com/*/posts/*' + FacebookPost << 'https://www.facebook.com/*/activity/*' + FacebookPost << 'https://www.facebook.com/photo*' + FacebookPost << 'https://www.facebook.com/photos*' + FacebookPost << 'https://www.facebook.com/*/photos*' + FacebookPost << 'https://www.facebook.com/permalink*' + FacebookPost << 'https://www.facebook.com/media*' + FacebookPost << 'https://www.facebook.com/questions*' + FacebookPost << 'https://www.facebook.com/notes*' + add_official_provider(FacebookPost) + + FacebookVideo = OEmbed::Provider.new('https://www.facebook.com/plugins/video/oembed.json/', :json) + FacebookVideo << 'https://www.facebook.com/*/videos/*' + FacebookVideo << 'https://www.facebook.com/video*' + add_official_provider(FacebookVideo) + end +end diff --git a/lib/oembed/providers/default/flickr.rb b/lib/oembed/providers/default/flickr.rb new file mode 100644 index 0000000..76b56db --- /dev/null +++ b/lib/oembed/providers/default/flickr.rb @@ -0,0 +1,11 @@ +module OEmbed + class Providers + # Provider for flickr.com + Flickr = OEmbed::Provider.new('https://www.flickr.com/services/oembed/') + Flickr << 'http://*.flickr.com/*' + Flickr << 'https://*.flickr.com/*' + Flickr << 'http://flic.kr/*' + Flickr << 'https://flic.kr/*' + add_official_provider(Flickr) + end +end diff --git a/lib/oembed/providers/default/hulu.rb b/lib/oembed/providers/default/hulu.rb new file mode 100644 index 0000000..65f8cba --- /dev/null +++ b/lib/oembed/providers/default/hulu.rb @@ -0,0 +1,8 @@ +module OEmbed + class Providers + # Provider for hulu.com + Hulu = OEmbed::Provider.new('http://www.hulu.com/api/oembed.{format}') + Hulu << 'http://www.hulu.com/watch/*' + add_official_provider(Hulu) + end +end diff --git a/lib/oembed/providers/default/imgur.rb b/lib/oembed/providers/default/imgur.rb new file mode 100644 index 0000000..3657117 --- /dev/null +++ b/lib/oembed/providers/default/imgur.rb @@ -0,0 +1,9 @@ +module OEmbed + class Providers + # Provider for imgur.com + Imgur = OEmbed::Provider.new('https://api.imgur.com/oembed.{format}') + Imgur << 'https://*.imgur.com/gallery/*' + Imgur << 'http://*.imgur.com/gallery/*' + add_official_provider(Imgur) + end +end diff --git a/lib/oembed/providers/default/instagram.rb b/lib/oembed/providers/default/instagram.rb new file mode 100644 index 0000000..16f0609 --- /dev/null +++ b/lib/oembed/providers/default/instagram.rb @@ -0,0 +1,14 @@ +module OEmbed + class Providers + # Provider for instagram.com + # https://instagr.am/developer/embedding/ + Instagram = OEmbed::Provider.new('https://api.instagram.com/oembed', :json) + Instagram << 'http://instagr.am/p/*' + Instagram << 'http://instagram.com/p/*' + Instagram << 'http://www.instagram.com/p/*' + Instagram << 'https://instagr.am/p/*' + Instagram << 'https://instagram.com/p/*' + Instagram << 'https://www.instagram.com/p/*' + add_official_provider(Instagram) + end +end diff --git a/lib/oembed/providers/default/movie_clips.rb b/lib/oembed/providers/default/movie_clips.rb new file mode 100644 index 0000000..530b3d1 --- /dev/null +++ b/lib/oembed/providers/default/movie_clips.rb @@ -0,0 +1,8 @@ +module OEmbed + class Providers + # Provider for movieclips.com + MovieClips = OEmbed::Provider.new('http://movieclips.com/services/oembed/') + MovieClips << 'http://movieclips.com/watch/*/*/' + add_official_provider(MovieClips) + end +end diff --git a/lib/oembed/providers/default/poll_everywhere.rb b/lib/oembed/providers/default/poll_everywhere.rb new file mode 100644 index 0000000..197f484 --- /dev/null +++ b/lib/oembed/providers/default/poll_everywhere.rb @@ -0,0 +1,10 @@ +module OEmbed + class Providers + # Provider for polleverywhere.com + PollEverywhere = OEmbed::Provider.new('http://www.polleverywhere.com/services/oembed/') + PollEverywhere << 'http://www.polleverywhere.com/polls/*' + PollEverywhere << 'http://www.polleverywhere.com/multiple_choice_polls/*' + PollEverywhere << 'http://www.polleverywhere.com/free_text_polls/*' + add_official_provider(PollEverywhere) + end +end diff --git a/lib/oembed/providers/default/scribd.rb b/lib/oembed/providers/default/scribd.rb new file mode 100644 index 0000000..9766aea --- /dev/null +++ b/lib/oembed/providers/default/scribd.rb @@ -0,0 +1,8 @@ +module OEmbed + class Providers + # Provider for scribd.com + Scribd = OEmbed::Provider.new('https://www.scribd.com/services/oembed') + Scribd << 'http://*.scribd.com/*' + add_official_provider(Scribd) + end +end diff --git a/lib/oembed/providers/default/slideshare.rb b/lib/oembed/providers/default/slideshare.rb new file mode 100644 index 0000000..f11d28c --- /dev/null +++ b/lib/oembed/providers/default/slideshare.rb @@ -0,0 +1,10 @@ +module OEmbed + class Providers + # Provider for slideshare.net + # http://www.slideshare.net/developers/oembed + Slideshare = OEmbed::Provider.new('https://www.slideshare.net/api/oembed/2') + Slideshare << 'http://www.slideshare.net/*/*' + Slideshare << 'http://www.slideshare.net/mobile/*/*' + add_official_provider(Slideshare) + end +end diff --git a/lib/oembed/providers/default/sound_cloud.rb b/lib/oembed/providers/default/sound_cloud.rb new file mode 100644 index 0000000..8d62754 --- /dev/null +++ b/lib/oembed/providers/default/sound_cloud.rb @@ -0,0 +1,10 @@ +module OEmbed + class Providers + # Provider for soundcloud.com + # http://developers.soundcloud.com/docs/oembed + SoundCloud = OEmbed::Provider.new('https://soundcloud.com/oembed', :json) + SoundCloud << 'http://*.soundcloud.com/*' + SoundCloud << 'https://*.soundcloud.com/*' + add_official_provider(SoundCloud) + end +end diff --git a/lib/oembed/providers/default/spotify.rb b/lib/oembed/providers/default/spotify.rb new file mode 100644 index 0000000..8ce63fd --- /dev/null +++ b/lib/oembed/providers/default/spotify.rb @@ -0,0 +1,14 @@ +module OEmbed + class Providers + # Provider for spotify.com + # https://twitter.com/nicklas2k/status/330094611202723840 + # http://blog.embed.ly/post/45149936446/oembed-for-spotify + Spotify = OEmbed::Provider.new('https://embed.spotify.com/oembed/') + Spotify << 'http://open.spotify.com/*' + Spotify << 'https://open.spotify.com/*' + Spotify << 'http://play.spotify.com/*' + Spotify << 'https://play.spotify.com/*' + Spotify << /^spotify\:(.*?)/ + add_official_provider(Spotify) + end +end diff --git a/lib/oembed/providers/default/tumblr.rb b/lib/oembed/providers/default/tumblr.rb new file mode 100644 index 0000000..c14fdf0 --- /dev/null +++ b/lib/oembed/providers/default/tumblr.rb @@ -0,0 +1,9 @@ +module OEmbed + class Providers + # Provider for tumblr.com + Tumblr = OEmbed::Provider.new('http://www.tumblr.com/oembed/1.0/', :json) + Tumblr << 'http://*.tumblr.com/post/*' + Tumblr << 'https://*.tumblr.com/post/*' + add_official_provider(Tumblr) + end +end diff --git a/lib/oembed/providers/default/twitter.rb b/lib/oembed/providers/default/twitter.rb new file mode 100644 index 0000000..afcc288 --- /dev/null +++ b/lib/oembed/providers/default/twitter.rb @@ -0,0 +1,11 @@ +module OEmbed + class Providers + # Provider for twitter.com + # https://dev.twitter.com/rest/reference/get/statuses/oembed + Twitter = OEmbed::Provider.new( + 'https://api.twitter.com/1/statuses/oembed.{format}' + ) + Twitter << 'https://*.twitter.com/*/status/*' + add_official_provider(Twitter) + end +end diff --git a/lib/oembed/providers/default/viddler.rb b/lib/oembed/providers/default/viddler.rb new file mode 100644 index 0000000..41b695d --- /dev/null +++ b/lib/oembed/providers/default/viddler.rb @@ -0,0 +1,9 @@ +module OEmbed + class Providers + # Provider for viddler.com + # http://developers.viddler.com/#oembed + Viddler = OEmbed::Provider.new('http://www.viddler.com/oembed/') + Viddler << 'http://*.viddler.com/*' + add_official_provider(Viddler) + end +end diff --git a/lib/oembed/providers/default/vimeo.rb b/lib/oembed/providers/default/vimeo.rb new file mode 100644 index 0000000..c2eec9d --- /dev/null +++ b/lib/oembed/providers/default/vimeo.rb @@ -0,0 +1,10 @@ +module OEmbed + class Providers + # Provider for vimeo.com + # https://developer.vimeo.com/apis/oembed + Vimeo = OEmbed::Provider.new('https://vimeo.com/api/oembed.{format}') + Vimeo << 'http://*.vimeo.com/*' + Vimeo << 'https://*.vimeo.com/*' + add_official_provider(Vimeo) + end +end diff --git a/lib/oembed/providers/default/vine.rb b/lib/oembed/providers/default/vine.rb new file mode 100644 index 0000000..d092507 --- /dev/null +++ b/lib/oembed/providers/default/vine.rb @@ -0,0 +1,10 @@ +module OEmbed + class Providers + # Provider for vine.co + # https://dev.twitter.com/web/vine/oembed + Vine = OEmbed::Provider.new('https://vine.co/oembed.{format}') + Vine << 'http://*.vine.co/v/*' + Vine << 'https://*.vine.co/v/*' + add_official_provider(Vine) + end +end diff --git a/lib/oembed/providers/default/youtube.rb b/lib/oembed/providers/default/youtube.rb new file mode 100644 index 0000000..0811e33 --- /dev/null +++ b/lib/oembed/providers/default/youtube.rb @@ -0,0 +1,20 @@ +module OEmbed + class Providers + # Provider for youtube.com + # http://apiblog.youtube.com/2009/10/oembed-support.html + # + # Options: + # * To get the iframe embed code + # OEmbed::Providers::Youtube.endpoint += "?iframe=1" + # * To get the flash/object embed code + # OEmbed::Providers::Youtube.endpoint += "?iframe=0" + # * To require https embed code + # OEmbed::Providers::Youtube.endpoint += "?scheme=https" + Youtube = OEmbed::Provider.new('https://www.youtube.com/oembed?scheme=https') + Youtube << 'http://*.youtube.com/*' + Youtube << 'https://*.youtube.com/*' + Youtube << 'http://*.youtu.be/*' + Youtube << 'https://*.youtu.be/*' + add_official_provider(Youtube) + end +end diff --git a/lib/oembed/providers/minor/clearspring.rb b/lib/oembed/providers/minor/clearspring.rb new file mode 100644 index 0000000..c30ae74 --- /dev/null +++ b/lib/oembed/providers/minor/clearspring.rb @@ -0,0 +1,10 @@ +module OEmbed + class Providers + # Provider for clearspring.com + ClearspringWidgets = OEmbed::Provider.new( + 'http://widgets.clearspring.com/widget/v1/oembed/' + ) + ClearspringWidgets << 'http://www.clearspring.com/widgets/*' + add_official_provider(ClearspringWidgets) + end +end diff --git a/lib/oembed/providers/minor/kinomap.rb b/lib/oembed/providers/minor/kinomap.rb new file mode 100644 index 0000000..a9f199e --- /dev/null +++ b/lib/oembed/providers/minor/kinomap.rb @@ -0,0 +1,9 @@ +module OEmbed + class Providers + # Provider for kinomap.com + # http://www.kinomap.com/#!oEmbed + Kinomap = OEmbed::Provider.new('http://www.kinomap.com/oembed') + Kinomap << 'http://www.kinomap.com/*' + add_official_provider(Kinomap) + end +end diff --git a/lib/oembed/providers/minor/mlg_tv.rb b/lib/oembed/providers/minor/mlg_tv.rb new file mode 100644 index 0000000..bebcf3a --- /dev/null +++ b/lib/oembed/providers/minor/mlg_tv.rb @@ -0,0 +1,10 @@ +module OEmbed + class Providers + # provider for mlg-tv + # http://tv.majorleaguegaming.com/oembed + MlgTv = OEmbed::Provider.new('http://tv.majorleaguegaming.com/oembed') + MlgTv << 'http://tv.majorleaguegaming.com/video/*' + MlgTv << 'http://mlg.tv/video/*' + add_official_provider(MlgTv) + end +end diff --git a/lib/oembed/providers/minor/my_opera.rb b/lib/oembed/providers/minor/my_opera.rb new file mode 100644 index 0000000..6179236 --- /dev/null +++ b/lib/oembed/providers/minor/my_opera.rb @@ -0,0 +1,9 @@ +module OEmbed + class Providers + # Provider for my.opera.com + # http://my.opera.com/devblog/blog/2008/12/02/embedding-my-opera-content-oembed + MyOpera = OEmbed::Provider.new('http://my.opera.com/service/oembed', :json) + MyOpera << 'http://my.opera.com/*' + add_official_provider(MyOpera) + end +end diff --git a/lib/oembed/providers/minor/nfb_canada.rb b/lib/oembed/providers/minor/nfb_canada.rb new file mode 100644 index 0000000..5c18fae --- /dev/null +++ b/lib/oembed/providers/minor/nfb_canada.rb @@ -0,0 +1,8 @@ +module OEmbed + class Providers + # Provider for nfb.ca + NFBCanada = OEmbed::Provider.new('http://www.nfb.ca/remote/services/oembed/') + NFBCanada << 'http://*.nfb.ca/film/*' + add_official_provider(NFBCanada) + end +end diff --git a/lib/oembed/providers/minor/revision3.rb b/lib/oembed/providers/minor/revision3.rb new file mode 100644 index 0000000..633eeb7 --- /dev/null +++ b/lib/oembed/providers/minor/revision3.rb @@ -0,0 +1,8 @@ +module OEmbed + class Providers + # Provider for revision3.com + Revision3 = OEmbed::Provider.new('http://revision3.com/api/oembed/') + Revision3 << 'http://*.revision3.com/*' + add_official_provider(Revision3) + end +end diff --git a/lib/oembed/providers/minor/twenty_three.rb b/lib/oembed/providers/minor/twenty_three.rb new file mode 100644 index 0000000..d9d5fc6 --- /dev/null +++ b/lib/oembed/providers/minor/twenty_three.rb @@ -0,0 +1,8 @@ +module OEmbed + class Providers + # Provider for 23hq.com + TwentyThree = OEmbed::Provider.new('http://www.23hq.com/23/oembed') + TwentyThree << 'http://www.23hq.com/*' + add_official_provider(TwentyThree) + end +end diff --git a/lib/oembed/providers/oohembed_urls.yml b/lib/oembed/providers/oohembed_urls.yml deleted file mode 100644 index 598c8b1..0000000 --- a/lib/oembed/providers/oohembed_urls.yml +++ /dev/null @@ -1,17 +0,0 @@ ---- -- http://*.blip.tv/* -- http://*.clikthrough.com/theater/video/* -- http://*.dailymotion.com/* -- http://*.flickr.com/photos/* -- http://*.kinomap.com/* -- http://*.nfb.ca/film/* -- http://*.photobucket.com/albums/*|http://*.photobucket.com/groups/* -- http://*.revision3.com/* -- http://*.scribd.com/* -- http://*.viddler.com/explore/* -- http://*.youtube.com/watch* -- http://dotsub.com/view/* -- http://qik.com/* -- http://www.hulu.com/watch/* -- http://www.vimeo.com/* and http://www.vimeo.com/groups/*/videos/* -- http://yfrog.(com|ru|com.tr|it|fr|co.il|co.uk|com.pl|pl|eu|us)/* diff --git a/lib/tasks/oembed.rake b/lib/tasks/oembed.rake index bec8af2..c8c6390 100644 --- a/lib/tasks/oembed.rake +++ b/lib/tasks/oembed.rake @@ -20,26 +20,6 @@ begin YAML.dump(url_regexps, File.open(yaml_path, 'w')) end - - # Note: At the moment the list of enpoints in the oohembed-provided JSON file - # do NOT match the full listing on their website. Until we sort that out, we'll - # continue to use the manually entered list of oohembed URLs - desc 'Update the list of URLs supported by oohembed via their API' - task :update_oohembed do - # Details in the Q & A section of http://oohembed.com/ - json_uri = URI.parse('http://oohembed.com/static/endpoints.json') - yaml_path = File.join(File.dirname(__FILE__), '../oembed/providers/oohembed_urls.yml') - - services = JSON.parse(json_uri.read) - - url_regexps = [] - services.each do |service| - url_regexps << service['url'] - end - url_regexps.sort! - - YAML.dump(url_regexps, File.open(yaml_path, 'w')) - end end rescue LoadError puts 'The oembed rake tasks require JSON. Install it with: gem install json'