Sha256: 4eb3f78dea9af9b04abd2b34175af438725dfd4d853b6667f7210a3f3ded3936
Contents?: true
Size: 533 Bytes
Versions: 3
Compression:
Stored size: 533 Bytes
Contents
AutoHtml.add_filter(:twitter).with({}) do |text, options| require 'uri' require 'net/http' regex = %r{(?<!href=")https://twitter\.com(/#!)?/[A-Za-z0-9_]{1,15}/status(es)?/\d+(/?)} text.gsub(regex) do |match| params = { :url => match }.merge(options) uri = URI("https://api.twitter.com/1/statuses/oembed.json") uri.query = URI.encode_www_form(params) http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true response = JSON.parse(http.get(uri.request_uri).body) response["html"] end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
auto_html-whistlerbrk-2.0.0.pre | lib/auto_html/filters/twitter.rb |
auto_html-1.6.4 | lib/auto_html/filters/twitter.rb |
auto_html-1.6.3 | lib/auto_html/filters/twitter.rb |