onebox 2.1.4 → 2.1.5

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: cba7774ebf124a2d110630be26869977c6acf71d1a07603e890d3a1231430834
4
- data.tar.gz: fe5de86e2abdc20fee6139c596da13e1249a6d38d9c40a7759adbbaa5065c8f0
3
+ metadata.gz: 372344282cacdb38dfceab5dfb6c156d7c9fa5ec04cca9cc21eb8502987ce077
4
+ data.tar.gz: 02a26147e10f54261596572328cf85a758178cda845a20c9999cc1b5f96ffe18
5
5
  SHA512:
6
- metadata.gz: e9d0e1df1c6d14c4984b30c7b3392d519b0eeec63ee7a34656e3089d9c1bc81e1d7e801660ceb2d4da0ea89a779e64a0cb7cd332485b584a9d6873866dbe8819
7
- data.tar.gz: 4c3587d5445c97480c3d5dd4ee514ea9df427d26fb1fed1ace681b95aa6012d79c84323bd915803c4409b21695f4f2f28a6baf6016a8f50dc0f76a65d79be04d
6
+ metadata.gz: 187c7a40761cea4d784175373600c00c2045d29ba911c8838614bf51b76454ecd7080ee93ca787d6745e69fc9d823b6de0e592746a2ccc30e9a9d55847e86cd4
7
+ data.tar.gz: f73f392c9451e85e5678dd0eff146092bfc0f3ae6a261eb4dfae02fb6a614976571837f3ec52e512334a4e815c3e3c8f49694179a7a41ec387d7195153cb7810
@@ -316,7 +316,7 @@ module Onebox
316
316
  return true if AllowlistedGenericOnebox.html_providers.include?(data[:provider_name])
317
317
  return false unless data[:html]["iframe"]
318
318
 
319
- fragment = Nokogiri::HTML::fragment(data[:html])
319
+ fragment = Nokogiri::HTML5::fragment(data[:html])
320
320
  src = fragment.at_css('iframe')&.[]("src")
321
321
  options[:allowed_iframe_regexes]&.any? { |r| src =~ r }
322
322
  end
@@ -367,7 +367,7 @@ module Onebox
367
367
  end
368
368
 
369
369
  def embedded_html
370
- fragment = Nokogiri::HTML::fragment(data[:html])
370
+ fragment = Nokogiri::HTML5::fragment(data[:html])
371
371
  fragment.css("img").each { |img| img["class"] = "thumbnail" }
372
372
  if iframe = fragment.at_css("iframe")
373
373
  iframe.remove_attribute("style")
@@ -16,12 +16,26 @@ module Onebox
16
16
 
17
17
  def data
18
18
  og = get_opengraph
19
- author_name = og.description.match(/\(@(\w+)\) on Instagram/)[1]
19
+
20
+ # There are at least two different versions of the description. e.g.
21
+ # - "3,227 Likes, 88 Comments - An Account (@user.name) on Instagram: “Look at my picture!”"
22
+ # - "@user.name posted on their Instagram profile: “Look at my picture!”"
23
+
24
+ m = og.description.match(/\(@([\w\.]+)\) on Instagram/)
25
+ author_name = m[1] if m
26
+
27
+ author_name ||= begin
28
+ m = og.description.match(/^\@([\w\.]+)\ posted/)
29
+ m[1] if m
30
+ end
31
+
32
+ raise "Author username not found for post #{clean_url}" unless author_name
33
+
20
34
  permalink = clean_url.gsub("/#{author_name}/", "/")
21
35
 
22
36
  { link: permalink,
23
37
  title: "@#{author_name}",
24
- image: "#{permalink}/media/?size=l",
38
+ image: og.image,
25
39
  description: Onebox::Helpers.truncate(og.title, 250)
26
40
  }
27
41
  end
@@ -45,7 +45,7 @@ module Onebox
45
45
  return "" unless html
46
46
 
47
47
  if @options[:max_width]
48
- doc = Nokogiri::HTML::fragment(html)
48
+ doc = Nokogiri::HTML5::fragment(html)
49
49
  if doc
50
50
  doc.css('[width]').each do |e|
51
51
  width = e['width'].to_i
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "2.1.4"
4
+ VERSION = "2.1.5"
5
5
  end
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'fakeweb', '~> 1.3'
34
34
  spec.add_development_dependency 'pry', '~> 0.10'
35
35
  spec.add_development_dependency 'mocha', '~> 1.1'
36
- spec.add_development_dependency 'rubocop-discourse', '~> 2.1.2'
36
+ spec.add_development_dependency 'rubocop-discourse', '~> 2.4.0'
37
37
  spec.add_development_dependency 'twitter', '~> 4.8'
38
38
  spec.add_development_dependency 'guard-rspec', '~> 4.2.8'
39
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: 2.1.4
4
+ version: 2.1.5
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: 2020-10-21 00:00:00.000000000 Z
13
+ date: 2020-11-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -186,14 +186,14 @@ dependencies:
186
186
  requirements:
187
187
  - - "~>"
188
188
  - !ruby/object:Gem::Version
189
- version: 2.1.2
189
+ version: 2.4.0
190
190
  type: :development
191
191
  prerelease: false
192
192
  version_requirements: !ruby/object:Gem::Requirement
193
193
  requirements:
194
194
  - - "~>"
195
195
  - !ruby/object:Gem::Version
196
- version: 2.1.2
196
+ version: 2.4.0
197
197
  - !ruby/object:Gem::Dependency
198
198
  name: twitter
199
199
  requirement: !ruby/object:Gem::Requirement