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 +4 -4
- data/.rubocop.yml +2 -1
- data/lib/onebox/engine/instagram_onebox.rb +31 -15
- data/lib/onebox/version.rb +1 -1
- data/onebox.gemspec +1 -2
- metadata +5 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2bb566d2096445a37f5328daab6bd9750c8fa75ce8740b7f2f858f56c9aa795
|
4
|
+
data.tar.gz: 1f4ce2ee9e5255a0889c3019649a9a34802a3b4d7c7d4494ab3425d98566d471
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e48b7a4787c335b9eefba80baa1b49d19e394b3a05ab1c43ed30fc176e5d0021a301ddbedcbf8d5a1e02649fadb41d8cd62d8668b3d0d62e030effffc667453
|
7
|
+
data.tar.gz: 8fbb2770d5ffa95e3efed6fb24c5f15468b659392e40bb5532abe7e7d4a677678dd2705e354efb8f33e4622c7608dac21bd6f446145a342c6683ec47d6cff178
|
data/.rubocop.yml
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
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
|
16
|
-
|
17
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
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
|
-
|
28
|
-
result[:video_link] = og.url if !og.video_secure_url.nil?
|
43
|
+
protected
|
29
44
|
|
30
|
-
|
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
|
data/lib/onebox/version.rb
CHANGED
data/onebox.gemspec
CHANGED
@@ -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', '~>
|
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.
|
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-
|
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.
|
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.
|
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.
|
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.
|