Sha256: f08ece1e4f11e1da31d4daf65b1784d3c8020c7192bd5ee4edfced70c26d7867

Contents?: true

Size: 819 Bytes

Versions: 8

Compression:

Stored size: 819 Bytes

Contents

# frozen_string_literal: true

module OembedProxy
  # Google Docs Fauxembed
  class GoogleDocument
    GOOGLE_DOCUMENT_REGEX = %r{\Ahttps://docs\.google\.com/document.+}.freeze

    def handles_url?(url)
      !(url =~ GOOGLE_DOCUMENT_REGEX).nil?
    end

    def get_data(url, _other_params = {})
      return nil unless handles_url? url

      oembed = {}

      oembed['type'] = 'rich'
      oembed['version'] = '1.0'

      oembed['provider_name'] = 'Google Apps Documents'
      oembed['provider_url'] = 'https://docs.google.com/document/‎'

      oembed['html'] = '<iframe class="google-docs document" width="100%" height="500" frameborder="0" scrolling="yes" marginheight="0" marginwidth="0" src="' + url + '"></iframe>'
      oembed['width'] = 500
      oembed['height'] = 500

      oembed
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
oembed_proxy-0.3 lib/oembed_proxy/google_document.rb
oembed_proxy-0.2.6 lib/oembed_proxy/google_document.rb
oembed_proxy-0.2.5 lib/oembed_proxy/google_document.rb
oembed_proxy-0.2.4 lib/oembed_proxy/google_document.rb
oembed_proxy-0.2.3 lib/oembed_proxy/google_document.rb
oembed_proxy-0.2.2 lib/oembed_proxy/google_document.rb
oembed_proxy-0.2.1 lib/oembed_proxy/google_document.rb
oembed_proxy-0.2.0 lib/oembed_proxy/google_document.rb