onebox 1.9.23 → 1.9.24

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
  SHA256:
3
- metadata.gz: c59fdb0a75faf98373d219999658d29423c81273fc2540b288721e083261d000
4
- data.tar.gz: 842cfdd7957c5fd862ec7ed7931d5d61adf96656577bb2fe3c837dff436e4e57
3
+ metadata.gz: bf558389e0bd7431942769ee39ee40f770245463e97e25400accfe3a130af77f
4
+ data.tar.gz: 23d64fbf25b722401c33aac9f0230a1d9d904d9db13794041b744c7d43165bec
5
5
  SHA512:
6
- metadata.gz: 67c38c486f923c0dece67558435c43b0f80759e5020a360a726087b211eb17ffe932df872fd1d61f615935e32559ad895f7dcf05c48820d1720efd0b14b821d7
7
- data.tar.gz: 3dff1e9e38bf2a4a9940688f5399e851ce9ee5607ab917caf41a2435e01cfccda13808959fd8e804e3e1c39a3cef4579bd85f2ddfc68ac02bc129dd4a33053e5
6
+ metadata.gz: 06dfe747b8a6408ef1a34c07410f32baf4d94d1cf986edee4e5267daa2eb81278569e1263bc2c9565f20ac123f93c5ca35d324f3eba6140044cfb6169b499652
7
+ data.tar.gz: 1e6c04cea5599d7d1121c7e6ff502ca0d723fd3037e1955289ff26dce5eb74350db399ffa9293d7f9286971ef9b3cf5e88409ef30eeb454675b738c8924e1c64
@@ -52,7 +52,7 @@ module Onebox
52
52
 
53
53
  nil
54
54
  rescue
55
- return nil
55
+ nil
56
56
  end
57
57
  end
58
58
  end
@@ -25,7 +25,7 @@ module Onebox
25
25
  def get_pdf_info
26
26
  uri = URI.parse(@url)
27
27
  size = Onebox::Helpers.fetch_content_length(@url)
28
- return {
28
+ {
29
29
  filesize: size ? Onebox::Helpers.pretty_filesize(size.to_i) : nil,
30
30
  name: File.basename(uri.path)
31
31
  }
@@ -6,24 +6,23 @@ module Onebox
6
6
  include Engine
7
7
  include StandardEmbed
8
8
 
9
- # only match private Vimeo video links
10
- matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+\/[^\/]+?$/)
9
+ matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+/)
11
10
  always_https
12
11
 
13
12
  WIDTH ||= 640
14
13
  HEIGHT ||= 360
15
14
 
16
15
  def placeholder_html
17
- image_src = og_data.image_secure_url || og_data.image_url
18
- "<img src='#{image_src}' width='#{WIDTH}' height='#{HEIGHT}' #{og_data.title_attr}>"
16
+ ::Onebox::Helpers.video_placeholder_html
19
17
  end
20
18
 
21
19
  def to_html
22
- video_src = og_data.video_secure_url || og_data.video_url
23
- if video_src.nil?
24
- id = uri.path[/\/(\d+)/, 1]
25
- video_src = "https://player.vimeo.com/video/#{id}"
20
+ video_id = oembed_data[:video_id]
21
+ if video_id.nil?
22
+ # for private videos
23
+ video_id = uri.path[/\/(\d+)/, 1]
26
24
  end
25
+ video_src = "https://player.vimeo.com/video/#{video_id}"
27
26
  video_src = video_src.gsub('autoplay=1', '').chomp("?")
28
27
  <<-HTML
29
28
  <iframe width="#{WIDTH}"
@@ -38,6 +37,13 @@ module Onebox
38
37
 
39
38
  private
40
39
 
40
+ def oembed_data
41
+ response = Onebox::Helpers.fetch_response("https://vimeo.com/api/oembed.json?url=#{url}")
42
+ @oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
43
+ rescue
44
+ "{}"
45
+ end
46
+
41
47
  def og_data
42
48
  @og_data = get_opengraph
43
49
  end
@@ -26,7 +26,7 @@ module Onebox
26
26
  def extract_script_value(var_name)
27
27
  if (script_elem = raw.css("script").select { |script| script.inner_text.include? "var #{var_name} = " }) && script_elem.any?
28
28
  e = Nokogiri::HTML(script_elem[0].inner_text.match(/var\s+#{Regexp.quote(var_name)}\s+=\s+"(.*?)";/)[1])
29
- return CGI::unescapeHTML(e.text.scan(/(?:\\x([a-f0-9]{2}))|(.)/i).map { |x| x[0] ? [x[0].to_i(16)].pack('U') : x[1] }.join)
29
+ CGI::unescapeHTML(e.text.scan(/(?:\\x([a-f0-9]{2}))|(.)/i).map { |x| x[0] ? [x[0].to_i(16)].pack('U') : x[1] }.join)
30
30
  end
31
31
  end
32
32
 
@@ -132,7 +132,7 @@ module Onebox
132
132
  end
133
133
  end
134
134
  ndx = 7
135
- return "#{'%.2f' % (size / (scale**(ndx - 1)))} #{conv[ndx - 1]}"
135
+ "#{'%.2f' % (size / (scale**(ndx - 1)))} #{conv[ndx - 1]}"
136
136
  end
137
137
 
138
138
  def self.click_to_scroll_div(width = 690, height = 400)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "1.9.23"
4
+ VERSION = "1.9.24"
5
5
  end
@@ -32,7 +32,8 @@ Gem::Specification.new do |spec|
32
32
  spec.add_development_dependency 'fakeweb', '~> 1.3'
33
33
  spec.add_development_dependency 'pry', '~> 0.10'
34
34
  spec.add_development_dependency 'mocha', '~> 1.1'
35
- spec.add_development_dependency 'rubocop', '~> 0.50'
35
+ spec.add_development_dependency 'rubocop', '~> 0.69.0'
36
+ spec.add_development_dependency 'rubocop-discourse', '~> 1.0.1'
36
37
  spec.add_development_dependency 'twitter', '~> 4.8'
37
38
  spec.add_development_dependency 'guard-rspec', '~> 4.2.8'
38
39
  spec.add_development_dependency 'sinatra', '~> 1.4'
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.9.23
4
+ version: 1.9.24
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: 2019-11-20 00:00:00.000000000 Z
13
+ date: 2019-11-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -172,14 +172,28 @@ dependencies:
172
172
  requirements:
173
173
  - - "~>"
174
174
  - !ruby/object:Gem::Version
175
- version: '0.50'
175
+ version: 0.69.0
176
176
  type: :development
177
177
  prerelease: false
178
178
  version_requirements: !ruby/object:Gem::Requirement
179
179
  requirements:
180
180
  - - "~>"
181
181
  - !ruby/object:Gem::Version
182
- version: '0.50'
182
+ version: 0.69.0
183
+ - !ruby/object:Gem::Dependency
184
+ name: rubocop-discourse
185
+ requirement: !ruby/object:Gem::Requirement
186
+ requirements:
187
+ - - "~>"
188
+ - !ruby/object:Gem::Version
189
+ version: 1.0.1
190
+ type: :development
191
+ prerelease: false
192
+ version_requirements: !ruby/object:Gem::Requirement
193
+ requirements:
194
+ - - "~>"
195
+ - !ruby/object:Gem::Version
196
+ version: 1.0.1
183
197
  - !ruby/object:Gem::Dependency
184
198
  name: twitter
185
199
  requirement: !ruby/object:Gem::Requirement
@@ -407,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
407
421
  - !ruby/object:Gem::Version
408
422
  version: '0'
409
423
  requirements: []
410
- rubygems_version: 3.0.3
424
+ rubygems_version: 3.0.4
411
425
  signing_key:
412
426
  specification_version: 4
413
427
  summary: A gem for generating embeddable HTML previews from URLs.