onebox 1.5.22 → 1.5.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2fb92353f1527a271605471d0115a60931073832
4
- data.tar.gz: c97622b3d51890dd888e15f0be87493e910901a7
3
+ metadata.gz: b94e9f549867048719ac4be58c7bfe8ac1f7add1
4
+ data.tar.gz: 101edaaae7ea70b7f62d36f5cf59220fcd35ab3b
5
5
  SHA512:
6
- metadata.gz: 3af69983a71d88760ffeb61123c414cbc6ba999bff37e4e326a482637d248b3869bd93e4ae49c2d6c601fb2c79da4116e12df40993c7509c539a481a9d2751e6
7
- data.tar.gz: 2468de3c42c9dcf6fd8532e9790fa4432a6d8e185238e7e73011c19f008de281780448b76db420744c5452047c5d3590ec7e99b1901d159e64ed95c566d62704
6
+ metadata.gz: 682207fa30191d21690b08ce72bb9dd74a1b969d01d698d42dc3b81a4bc88ac4194ba83a4831ff59acb7a48bd39554bf06dad88edeb1d33bdfcf817910e8df08
7
+ data.tar.gz: 2943b3d46a0abba088984ba14de5deaecf9daf7db7cf47d2165e37f72de05b2ab9203e6b58af7de05252b06f24faa2940f7f7e744b04fe1abd40e5c36460de46
data/lib/onebox/engine.rb CHANGED
@@ -160,3 +160,4 @@ require_relative "engine/douban_onebox"
160
160
  require_relative "engine/whitelisted_generic_onebox"
161
161
  require_relative "engine/pubmed_onebox"
162
162
  require_relative "engine/soundcloud_onebox"
163
+ require_relative "engine/imgur_onebox"
@@ -0,0 +1,34 @@
1
+ module Onebox
2
+ module Engine
3
+ class ImgurOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/.*imgur\.com/)
8
+ always_https
9
+
10
+ def to_html
11
+ imgur_data = get_imgur_data
12
+ return "<video width='#{imgur_data[:"player:width"]}' height='#{imgur_data[:"player:height"]}' controls autoplay loop><source src='#{imgur_data[:"player:stream"]}' type='video/mp4'></video>" if imgur_data[:"player:stream"]
13
+ return "<a href='#{url}' target='_blank'><img src='#{imgur_data[:image]}' alt='Imgur' height='#{imgur_data[:"image:height"]}' width='#{imgur_data[:"image:width"]}'></a>" if imgur_data[:image]
14
+ return "<a href='#{url}' target='_blank'><img src='#{imgur_data[:"image0:src"]}' alt='Imgur'></a>" if imgur_data[:"image0:src"]
15
+ return nil
16
+ end
17
+
18
+ private
19
+ def get_imgur_data
20
+ response = Onebox::Helpers.fetch_response(url)
21
+ html = Nokogiri::HTML(response.body)
22
+ imgur_data = {}
23
+ html.css('meta').each do |m|
24
+ if m.attribute('name') && m.attribute('name').to_s.match(/^twitter:/i)
25
+ m_content = m.attribute('content').to_s.strip
26
+ m_name = m.attribute('name').to_s.gsub('twitter:', '')
27
+ imgur_data[m_name.to_sym] = m_content
28
+ end
29
+ end
30
+ return imgur_data
31
+ end
32
+ end
33
+ end
34
+ end
@@ -63,7 +63,6 @@ module Onebox
63
63
  ign.com
64
64
  ikea.com
65
65
  imdb.com
66
- imgur.com
67
66
  indiatimes.com
68
67
  instagr.am
69
68
  instagram.com
@@ -128,10 +127,10 @@ module Onebox
128
127
  end
129
128
 
130
129
  # Often using the `html` attribute is not what we want, like for some blogs that
131
- # include the entire page HTML. However for some providers like Imgur it allows us
130
+ # include the entire page HTML. However for some providers like Flickr it allows us
132
131
  # to return gifv and galleries.
133
132
  def self.default_html_providers
134
- ['Flickr', 'Imgur', 'Meetup']
133
+ ['Flickr', 'Meetup']
135
134
  end
136
135
 
137
136
  def self.html_providers
@@ -152,7 +151,7 @@ module Onebox
152
151
  end
153
152
 
154
153
  def self.https_hosts
155
- %w(slideshare.net imgur.com dailymotion.com livestream.com)
154
+ %w(slideshare.net dailymotion.com livestream.com)
156
155
  end
157
156
 
158
157
  def self.host_matches(uri, list)
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.22"
2
+ VERSION = "1.5.23"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onebox
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.22
4
+ version: 1.5.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joanna Zeta
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-07-21 00:00:00.000000000 Z
13
+ date: 2015-08-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -299,6 +299,7 @@ files:
299
299
  - lib/onebox/engine/google_play_app_onebox.rb
300
300
  - lib/onebox/engine/html.rb
301
301
  - lib/onebox/engine/image_onebox.rb
302
+ - lib/onebox/engine/imgur_onebox.rb
302
303
  - lib/onebox/engine/json.rb
303
304
  - lib/onebox/engine/pubmed_onebox.rb
304
305
  - lib/onebox/engine/soundcloud_onebox.rb
@@ -413,7 +414,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
413
414
  version: '0'
414
415
  requirements: []
415
416
  rubyforge_project:
416
- rubygems_version: 2.4.5
417
+ rubygems_version: 2.4.3
417
418
  signing_key:
418
419
  specification_version: 4
419
420
  summary: A gem for turning URLs into previews.