onebox 1.9.28.1 → 1.9.28.2

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: dc4d1baf17e282cf5f07d077639a7ad8a33ebb548553c4fdda69b0c691218abe
4
- data.tar.gz: 4bbfca52e600f49d31945b38ee2f99fdf74f99a85523eb62ca65566d687e2f75
3
+ metadata.gz: b2bb566d2096445a37f5328daab6bd9750c8fa75ce8740b7f2f858f56c9aa795
4
+ data.tar.gz: 1f4ce2ee9e5255a0889c3019649a9a34802a3b4d7c7d4494ab3425d98566d471
5
5
  SHA512:
6
- metadata.gz: 8456164389809bb552d1bba98fd5e8ef04818327aed97d6cc816b4db81ec5c0ce94aab4fed0c503aedde0f5b3dd848e49e92e0d7e6a25e66f8b116b927b27cf4
7
- data.tar.gz: 7fb44b1c4cb1b007ca592c7bf96e3e2d6467f6736e1c01b969a6dae1037c6a9644b1027f2a6fac691735305c7b7d64c13cbf2b8f21594f6dd713c96f1923c3c0
6
+ metadata.gz: 5e48b7a4787c335b9eefba80baa1b49d19e394b3a05ab1c43ed30fc176e5d0021a301ddbedcbf8d5a1e02649fadb41d8cd62d8668b3d0d62e030effffc667453
7
+ data.tar.gz: 8fbb2770d5ffa95e3efed6fb24c5f15468b659392e40bb5532abe7e7d4a677678dd2705e354efb8f33e4622c7608dac21bd6f446145a342c6683ec47d6cff178
@@ -1 +1,2 @@
1
- inherit_from: https://raw.githubusercontent.com/discourse/discourse/master/.rubocop.yml
1
+ inherit_gem:
2
+ rubocop-discourse: default.yml
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'htmlentities'
4
-
5
3
  module Onebox
6
4
  module Engine
7
5
  class InstagramOnebox
@@ -9,25 +7,43 @@ module Onebox
9
7
  include StandardEmbed
10
8
  include LayoutSupport
11
9
 
12
- matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\//)
10
+ matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\/[a-zA-Z\d_-]+/)
13
11
  always_https
14
12
 
15
- def data
16
- og = get_opengraph
17
- title = og.title.split(":")[0].strip.gsub(" on Instagram", "")
18
-
19
- json_data = html_doc.xpath('//script[contains(text(),"window._sharedData")]').text.to_s
20
- title = "[Album] #{title}" if json_data =~ /"edge_sidecar_to_children"/
13
+ def clean_url
14
+ url.scan(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\/[a-zA-Z\d_-]+/).flatten.first
15
+ end
21
16
 
22
- result = { link: og.url,
23
- title: Onebox::Helpers.truncate(title, 80),
24
- description: og.description(250)
17
+ def data
18
+ oembed = get_oembed
19
+ permalink = clean_url.gsub("/#{oembed.author_name}/", "/")
20
+ description = oembed.title
21
+ type = if description =~ /^Photos by/
22
+ "album"
23
+ elsif description =~ /^Video by/
24
+ "video"
25
+ else
26
+ "photo"
27
+ end
28
+ title = if type == "album"
29
+ "[Album] @#{oembed.author_name}"
30
+ else
31
+ "@#{oembed.author_name}"
32
+ end
33
+
34
+ result = { link: permalink,
35
+ title: title,
36
+ image: "#{permalink}/media/?size=l",
37
+ description: Onebox::Helpers.truncate(description, 250)
25
38
  }
39
+ result[:video_link] = permalink if type == "video"
40
+ result
41
+ end
26
42
 
27
- result[:image] = og.image if !og.image.nil?
28
- result[:video_link] = og.url if !og.video_secure_url.nil?
43
+ protected
29
44
 
30
- result
45
+ def get_oembed_url
46
+ oembed_url = "https://api.instagram.com/oembed/?url=#{clean_url}"
31
47
  end
32
48
  end
33
49
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "1.9.28.1"
4
+ VERSION = "1.9.28.2"
5
5
  end
@@ -33,8 +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', '~> 0.78.0'
37
- spec.add_development_dependency 'rubocop-discourse', '~> 1.0.1'
36
+ spec.add_development_dependency 'rubocop-discourse', '~> 2.1.2'
38
37
  spec.add_development_dependency 'twitter', '~> 4.8'
39
38
  spec.add_development_dependency 'guard-rspec', '~> 4.2.8'
40
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.28.1
4
+ version: 1.9.28.2
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-05-06 00:00:00.000000000 Z
13
+ date: 2020-05-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: addressable
@@ -180,34 +180,20 @@ dependencies:
180
180
  - - "~>"
181
181
  - !ruby/object:Gem::Version
182
182
  version: '1.1'
183
- - !ruby/object:Gem::Dependency
184
- name: rubocop
185
- requirement: !ruby/object:Gem::Requirement
186
- requirements:
187
- - - "~>"
188
- - !ruby/object:Gem::Version
189
- version: 0.78.0
190
- type: :development
191
- prerelease: false
192
- version_requirements: !ruby/object:Gem::Requirement
193
- requirements:
194
- - - "~>"
195
- - !ruby/object:Gem::Version
196
- version: 0.78.0
197
183
  - !ruby/object:Gem::Dependency
198
184
  name: rubocop-discourse
199
185
  requirement: !ruby/object:Gem::Requirement
200
186
  requirements:
201
187
  - - "~>"
202
188
  - !ruby/object:Gem::Version
203
- version: 1.0.1
189
+ version: 2.1.2
204
190
  type: :development
205
191
  prerelease: false
206
192
  version_requirements: !ruby/object:Gem::Requirement
207
193
  requirements:
208
194
  - - "~>"
209
195
  - !ruby/object:Gem::Version
210
- version: 1.0.1
196
+ version: 2.1.2
211
197
  - !ruby/object:Gem::Dependency
212
198
  name: twitter
213
199
  requirement: !ruby/object:Gem::Requirement
@@ -434,7 +420,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
434
420
  - !ruby/object:Gem::Version
435
421
  version: '0'
436
422
  requirements: []
437
- rubygems_version: 3.1.2
423
+ rubygems_version: 3.0.3
438
424
  signing_key:
439
425
  specification_version: 4
440
426
  summary: A gem for generating embeddable HTML previews from URLs.