onebox 2.2.0 → 2.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +5 -10
- data/lib/onebox/engine/allowlisted_generic_onebox.rb +10 -3
- data/lib/onebox/engine/audio_onebox.rb +1 -1
- data/lib/onebox/engine/github_issue_onebox.rb +1 -2
- data/lib/onebox/engine/instagram_onebox.rb +2 -2
- data/lib/onebox/engine/json.rb +1 -1
- data/lib/onebox/engine/pubmed_onebox.rb +1 -1
- data/lib/onebox/engine/simplecast_onebox.rb +1 -0
- data/lib/onebox/engine/video_onebox.rb +1 -1
- data/lib/onebox/mixins/git_blob_onebox.rb +1 -1
- data/lib/onebox/sanitize_config.rb +1 -1
- data/lib/onebox/status_check.rb +1 -1
- data/lib/onebox/version.rb +1 -1
- data/onebox.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 43221e11b40d179b5a90c7c84f6c79096ba999b06ab411d159668c775de75e99
|
4
|
+
data.tar.gz: f23358a13d9644974b3e266f5acfd32eb13e113e085a4806369f2f858397e425
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 290c2d0fbc5b6e2f3a4a4557e82cf6f509b8756d4c56be587af86cf95bd5c9cd58ba01e5b266b29268723941efbd542d03d89afa92bf08f0a8c87b42752e03c8
|
7
|
+
data.tar.gz: 5497119a20088d0b09fe69b172926ba60318cf4145a174bac66f8ef781fc7465e6cf0e9524f94156633cb605d3e9081f62697b641ce3e514c2cfc74d2a8026f3
|
data/.github/workflows/ci.yml
CHANGED
@@ -15,24 +15,19 @@ jobs:
|
|
15
15
|
strategy:
|
16
16
|
matrix:
|
17
17
|
ruby:
|
18
|
-
- 2.4
|
19
18
|
- 2.5
|
20
19
|
- 2.6
|
20
|
+
- 2.7
|
21
|
+
- 3.0
|
21
22
|
|
22
23
|
steps:
|
23
|
-
- uses: actions/checkout@
|
24
|
+
- uses: actions/checkout@v2
|
24
25
|
|
25
26
|
- name: Setup ruby
|
26
|
-
uses:
|
27
|
+
uses: ruby/setup-ruby@v1
|
27
28
|
with:
|
28
29
|
ruby-version: ${{ matrix.ruby }}
|
29
|
-
|
30
|
-
|
31
|
-
- name: Setup bundler
|
32
|
-
run: gem install bundler
|
33
|
-
|
34
|
-
- name: Setup gems
|
35
|
-
run: bundle install
|
30
|
+
bundler-cache: true
|
36
31
|
|
37
32
|
- name: Rubocop
|
38
33
|
run: bundle exec rubocop
|
@@ -286,7 +286,7 @@ module Onebox
|
|
286
286
|
return image_html if is_image?
|
287
287
|
return embedded_html if is_embedded?
|
288
288
|
return card_html if is_card?
|
289
|
-
return article_html if has_text?
|
289
|
+
return article_html if (has_text? || is_image_article?)
|
290
290
|
end
|
291
291
|
|
292
292
|
def is_card?
|
@@ -301,8 +301,15 @@ module Onebox
|
|
301
301
|
end
|
302
302
|
|
303
303
|
def has_text?
|
304
|
-
!Onebox::Helpers.blank?(data[:
|
305
|
-
|
304
|
+
has_title? && !Onebox::Helpers.blank?(data[:description])
|
305
|
+
end
|
306
|
+
|
307
|
+
def has_title?
|
308
|
+
!Onebox::Helpers.blank?(data[:title])
|
309
|
+
end
|
310
|
+
|
311
|
+
def is_image_article?
|
312
|
+
has_title? && has_image?
|
306
313
|
end
|
307
314
|
|
308
315
|
def is_image?
|
@@ -15,7 +15,7 @@ module Onebox
|
|
15
15
|
escaped_url = ::Onebox::Helpers.normalize_url_for_output(@url)
|
16
16
|
|
17
17
|
<<-HTML
|
18
|
-
<audio controls>
|
18
|
+
<audio controls #{@options[:disable_media_download_controls] ? 'controlslist="nodownload"' : ""}>
|
19
19
|
<source src="#{escaped_url}">
|
20
20
|
<a href="#{escaped_url}">#{@url}</a>
|
21
21
|
</audio>
|
@@ -22,8 +22,7 @@ module Onebox
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def data
|
25
|
-
|
26
|
-
@raw ||= ::MultiJson.load(open(url, "Accept" => "application/vnd.github.v3.text+json", read_timeout: timeout)) #custom Accept header so we can get body as text.
|
25
|
+
@raw ||= ::MultiJson.load(URI.open(url, "Accept" => "application/vnd.github.v3.text+json", read_timeout: timeout)) #custom Accept header so we can get body as text.
|
27
26
|
body_text = @raw["body_text"]
|
28
27
|
|
29
28
|
content_words = body_text.gsub("\n\n", "\n").gsub("\n", "<br>").split(" ") #one pass of removing double newline, then we change \n to <br> and later on we revert it back to \n this is a workaround to avoid losing newlines after we join it back.
|
@@ -7,11 +7,11 @@ module Onebox
|
|
7
7
|
include StandardEmbed
|
8
8
|
include LayoutSupport
|
9
9
|
|
10
|
-
matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\/[a-zA-Z\d_-]+/)
|
10
|
+
matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/(?:p|tv)\/[a-zA-Z\d_-]+/)
|
11
11
|
always_https
|
12
12
|
|
13
13
|
def clean_url
|
14
|
-
url.scan(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/p\/[a-zA-Z\d_-]+/).flatten.first
|
14
|
+
url.scan(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/?(?:.*)\/(?:p|tv)\/[a-zA-Z\d_-]+/).flatten.first
|
15
15
|
end
|
16
16
|
|
17
17
|
def data
|
data/lib/onebox/engine/json.rb
CHANGED
@@ -11,7 +11,7 @@ module Onebox
|
|
11
11
|
private
|
12
12
|
|
13
13
|
def get_xml
|
14
|
-
doc = Nokogiri::XML(open(URI.join(@url, "?report=xml&format=text")))
|
14
|
+
doc = Nokogiri::XML(URI.open(URI.join(@url, "?report=xml&format=text")))
|
15
15
|
pre = doc.xpath("//pre")
|
16
16
|
Nokogiri::XML("<root>" + pre.text + "</root>")
|
17
17
|
end
|
@@ -20,7 +20,7 @@ module Onebox
|
|
20
20
|
escaped_url = ::Onebox::Helpers.normalize_url_for_output(@url)
|
21
21
|
<<-HTML
|
22
22
|
<div class="onebox video-onebox">
|
23
|
-
<video width='100%' height='100%' controls>
|
23
|
+
<video width='100%' height='100%' controls #{@options[:disable_media_download_controls] ? 'controlslist="nodownload"' : ""}>
|
24
24
|
<source src='#{escaped_url}'>
|
25
25
|
<a href='#{escaped_url}'>#{@url}</a>
|
26
26
|
</video>
|
@@ -167,7 +167,7 @@ module Onebox
|
|
167
167
|
@raw = "https://render.githubusercontent.com/view/solid?url=" + self.raw_template(m)
|
168
168
|
|
169
169
|
else
|
170
|
-
contents = open(self.raw_template(m), read_timeout: timeout).read
|
170
|
+
contents = URI.open(self.raw_template(m), read_timeout: timeout).read
|
171
171
|
|
172
172
|
contents_lines = contents.lines #get contents lines
|
173
173
|
contents_lines_size = contents_lines.size #get number of lines
|
@@ -10,7 +10,7 @@ class Sanitize
|
|
10
10
|
|
11
11
|
attributes: {
|
12
12
|
'a' => RELAXED[:attributes]['a'] + %w(target),
|
13
|
-
'audio' => %w[controls],
|
13
|
+
'audio' => %w[controls controlslist],
|
14
14
|
'embed' => %w[height src type width],
|
15
15
|
'iframe' => %w[allowfullscreen frameborder height scrolling src width data-original-href data-unsanitized-src],
|
16
16
|
'source' => %w[src type],
|
data/lib/onebox/status_check.rb
CHANGED
@@ -35,7 +35,7 @@ module Onebox
|
|
35
35
|
private
|
36
36
|
|
37
37
|
def check
|
38
|
-
res = open(@url, read_timeout: (@options.timeout || Onebox.options.timeout))
|
38
|
+
res = URI.open(@url, read_timeout: (@options.timeout || Onebox.options.timeout))
|
39
39
|
@status = res.status.first.to_i
|
40
40
|
rescue OpenURI::HTTPError => e
|
41
41
|
@status = e.io.status.first.to_i
|
data/lib/onebox/version.rb
CHANGED
data/onebox.gemspec
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.2.
|
4
|
+
version: 2.2.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:
|
13
|
+
date: 2021-02-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -413,7 +413,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
413
413
|
requirements:
|
414
414
|
- - ">="
|
415
415
|
- !ruby/object:Gem::Version
|
416
|
-
version: 2.
|
416
|
+
version: 2.5.0
|
417
417
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
418
418
|
requirements:
|
419
419
|
- - ">="
|