onebox 2.1.5 → 2.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onebox/engine.rb +2 -0
- data/lib/onebox/engine/allowlisted_generic_onebox.rb +9 -0
- data/lib/onebox/engine/instagram_onebox.rb +16 -21
- data/lib/onebox/engine/standard_embed.rb +1 -1
- data/lib/onebox/helpers.rb +1 -0
- data/lib/onebox/preview.rb +10 -0
- data/lib/onebox/version.rb +1 -1
- data/templates/instagram.mustache +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6fd88926ec341ed84409e7c77dbfcce244dbf2a0c74e0a19736e81b2b693e84
|
4
|
+
data.tar.gz: 18f53e5fb7b1fa4eab35ea27f87e97600e82af0eaf4fd5eed0809744bf7e53c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a5c344336f529d53b51ac47b5b0efee1b6fb29b0b2541948d650fa1d81e11f97edfa3d1a2f8abb7915b8cf9c86e41c74b64cb40b26924e380f68d52e0015c33
|
7
|
+
data.tar.gz: 9cefe31755197bbfb71ba3e741329c7bdba10fd9bb19892b237cb78b22769e0e19824119b94cb3cdd24f7bec10f4aeb91cbad3a7d40eefd84c2cbe64866908b0
|
data/lib/onebox/engine.rb
CHANGED
@@ -30,6 +30,7 @@ module Onebox
|
|
30
30
|
|
31
31
|
attr_reader :url, :uri
|
32
32
|
attr_reader :timeout
|
33
|
+
attr :errors
|
33
34
|
|
34
35
|
DEFAULT = {}
|
35
36
|
def options
|
@@ -44,6 +45,7 @@ module Onebox
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def initialize(link, timeout = nil)
|
48
|
+
@errors = {}
|
47
49
|
@options = DEFAULT
|
48
50
|
class_name = self.class.name.split("::").last.to_s
|
49
51
|
|
@@ -256,6 +256,15 @@ module Onebox
|
|
256
256
|
d[:data_1] = Onebox::Helpers.truncate("#{d[:price_currency].strip} #{d[:price_amount].strip}")
|
257
257
|
end
|
258
258
|
|
259
|
+
skip_missing_tags = [:video]
|
260
|
+
d.each do |k, v|
|
261
|
+
next if skip_missing_tags.include?(k)
|
262
|
+
if v == nil || v == ''
|
263
|
+
errors[k] ||= []
|
264
|
+
errors[k] << 'is blank'
|
265
|
+
end
|
266
|
+
end
|
267
|
+
|
259
268
|
d
|
260
269
|
end
|
261
270
|
end
|
@@ -15,35 +15,30 @@ module Onebox
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def data
|
18
|
-
|
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
|
-
|
34
|
-
permalink = clean_url.gsub("/#{author_name}/", "/")
|
18
|
+
oembed = get_oembed
|
19
|
+
permalink = clean_url.gsub("/#{oembed.author_name}/", "/")
|
35
20
|
|
36
21
|
{ link: permalink,
|
37
|
-
title: "@#{author_name}",
|
38
|
-
image:
|
39
|
-
description: Onebox::Helpers.truncate(
|
22
|
+
title: "@#{oembed.author_name}",
|
23
|
+
image: oembed.thumbnail_url,
|
24
|
+
description: Onebox::Helpers.truncate(oembed.title, 250),
|
40
25
|
}
|
26
|
+
|
41
27
|
end
|
42
28
|
|
43
29
|
protected
|
44
30
|
|
31
|
+
def access_token
|
32
|
+
(options[:facebook_app_access_token] || Onebox.options.facebook_app_access_token).to_s
|
33
|
+
end
|
34
|
+
|
45
35
|
def get_oembed_url
|
46
|
-
|
36
|
+
if access_token != ''
|
37
|
+
oembed_url = "https://graph.facebook.com/v9.0/instagram_oembed?url=#{clean_url}&access_token=#{access_token}"
|
38
|
+
else
|
39
|
+
# The following is officially deprecated by Instagram, but works in some limited circumstances.
|
40
|
+
oembed_url = "https://api.instagram.com/oembed/?url=#{clean_url}"
|
41
|
+
end
|
47
42
|
end
|
48
43
|
end
|
49
44
|
end
|
@@ -91,7 +91,7 @@ module Onebox
|
|
91
91
|
html_doc.css('meta').each do |m|
|
92
92
|
if (m["property"] && m["property"][/^twitter:(.+)$/i]) || (m["name"] && m["name"][/^twitter:(.+)$/i])
|
93
93
|
value = (m["content"] || m["value"]).to_s
|
94
|
-
twitter[$1.tr('-:' , '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
|
94
|
+
twitter[$1.tr('-:' , '_').to_sym] ||= value unless (Onebox::Helpers::blank?(value) || value == "0 minutes")
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
data/lib/onebox/helpers.rb
CHANGED
data/lib/onebox/preview.rb
CHANGED
data/lib/onebox/version.rb
CHANGED
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
|
+
version: 2.1.6
|
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-11-
|
13
|
+
date: 2020-11-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|