Sha256: 0113dec4916bdb70e9d7974a58a7894184a8a3f94e9e642e8e5d6a851a964aa4

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

module Oembedr
  module Providers

    # from ruby-oembed with a couple more I know of from user feedback :).
    LIST = {
      /(yotu\.be|youtube)/ => "http://www.youtube.com/oembed",
      /(flic\.kr|flickr)/ => "http://www.flickr.com/services/oembed/",
      /viddler/ => "http://lab.viddler.com/services/oembed/",
      /qik/ => "http://qik.com/api/oembed.{format}",
      /revision3/ => "http://revision3.com/api/oembed/",
      /hulu/ => "http://www.hulu.com/api/oembed.{format}",
      /vimeo/ => "http://www.vimeo.com/api/oembed.{format}",
      /instagr.am/ => "http://api.instagram.com/oembed",
      /slideshare/ => "http://www.slideshare.net/api/oembed/2",
      /(mlg\.tv|tv\.majorleaguegaming)/ => "http://tv.majorleaguegaming.com/oembed",
      /yfrog/ => "http://www.yfrog.com/api/oembed",
      /blip\.tv/ => "http://blip.tv/oembed/",
      /opera\.com/ => 'http://my.opera.com/service/oembed',
      /skitch\.com/ => 'http://skitch.com/oembed',
      /twitch\.tv/ => false, # OMG! Support OEmbed!
      /twitter\.com/ => 'https://api.twitter.com/1/statuses/oembed.{format}',
      # ...
    }

    # Locate the correct service endpoint for the given resource URL.
    #
    # @param url [String] a fully-qualified URL to an oembeddable resource
    #
    # @return the url, or false if no known endpoint.
    def service_endpoint url
      endpoint = LIST.find do |(pattern, endpoint)|
        pattern.match(url)
      end
      endpoint ? endpoint.last : false
    end

    # Return a boolean true or false if we can handle the given domain
    #
    # @param url [String] a fully-qualified URL to an oembeddable resource
    #
    # @return Boolean
    def known_service? url
      !!service_endpoint(url)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oembedr-0.0.2 lib/oembedr/providers.rb