onebox 2.1.8 → 2.2.4

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: b9885ad2362b97a26732cf64fef583674c58250648f403627aef33e87687f2bb
4
- data.tar.gz: 7678e338a3eb5276e53e3f673d230dc67f2b1cdf395adb339f09162f96e4c058
3
+ metadata.gz: 759d82290c29b9e1e3c97045ca14689dfc0f2f87221c1ce829b12a866abfd8a2
4
+ data.tar.gz: 5209c14887939549d9737409bd5dff67c2434c5a5f99596d2af93ef56aeaae6b
5
5
  SHA512:
6
- metadata.gz: 8fe261d1536790c511b437afcf5e6aff632d21f3c4ef47c96c4a3adbf31c6b8f2b07e186323ddb4858a1c37c23d651bd96deeb49feb493c4064c11f2ba5d0d92
7
- data.tar.gz: e46b1a057f9f6b351dd96eed98dbcee7209fe5ca9c4c247dbeb715988851a3ac99875e174022f60f08a5848e226f277562be131085dcbfa667544de41da17cd0
6
+ metadata.gz: 719a0e4e72b2719f8ab0fd71474bfd07ef485c4dcba2c13809d5fbafa86f9b831ebe1aa7a73237c9cde28d7babc472234fa9ae701d9b18aae25621a641c883a0
7
+ data.tar.gz: f8c0c6c5883c48ea2811940f00c2419438e199c1e9a70761453c9aafdf176404633dc79133fc87d4014ee0e0c74a037ee8ee19b2f9b46cd85ef07a491f64cfe6
@@ -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@v1
24
+ - uses: actions/checkout@v2
24
25
 
25
26
  - name: Setup ruby
26
- uses: actions/setup-ruby@v1
27
+ uses: ruby/setup-ruby@v1
27
28
  with:
28
29
  ruby-version: ${{ matrix.ruby }}
29
- architecture: 'x64'
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,9 +301,17 @@ module Onebox
301
301
  end
302
302
 
303
303
  def has_text?
304
+ has_title? && !Onebox::Helpers.blank?(data[:description])
305
+ end
306
+
307
+ def has_title?
304
308
  !Onebox::Helpers.blank?(data[:title])
305
309
  end
306
310
 
311
+ def is_image_article?
312
+ has_title? && has_image?
313
+ end
314
+
307
315
  def is_image?
308
316
  data[:type] =~ /photo|image/ &&
309
317
  data[:type] !~ /photostream/ &&
@@ -45,8 +45,7 @@ module Onebox
45
45
  end
46
46
 
47
47
  {
48
- link: og.url,
49
- path_link: url,
48
+ link: url,
50
49
  image: og.image,
51
50
  title: Onebox::Helpers.truncate(title, 250),
52
51
  path: display_path,
@@ -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
@@ -6,7 +6,7 @@ module Onebox
6
6
  private
7
7
 
8
8
  def raw
9
- @raw ||= ::MultiJson.load(open(url, read_timeout: timeout))
9
+ @raw ||= ::MultiJson.load(URI.open(url, read_timeout: timeout))
10
10
  end
11
11
  end
12
12
  end
@@ -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
@@ -8,6 +8,7 @@ module Onebox
8
8
 
9
9
  matches_regexp(/https?:\/\/(.+)?simplecast.com\/(episodes|s)\/.*/)
10
10
  always_https
11
+ requires_iframe_origins("https://embed.simplecast.com")
11
12
 
12
13
  def to_html
13
14
  get_oembed.html
@@ -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],
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "2.1.8"
4
+ VERSION = "2.2.4"
5
5
  end
data/onebox.gemspec CHANGED
@@ -41,5 +41,5 @@ Gem::Specification.new do |spec|
41
41
  spec.add_development_dependency 'haml', '~> 5.1'
42
42
  spec.add_development_dependency 'listen', '~> 2.10.0'
43
43
 
44
- spec.required_ruby_version = '>=2.4.0'
44
+ spec.required_ruby_version = '>=2.5.0'
45
45
  end
@@ -3,7 +3,7 @@
3
3
  <h3><a href='{{link}}' target="_blank" rel="noopener">{{title}}</a></h3>
4
4
 
5
5
  {{#path}}
6
- <p><a href='{{path_link}}' target="_blank" rel="noopener">{{path}}</a></p>
6
+ <p><a href='{{link}}' target="_blank" rel="noopener">{{path}}</a></p>
7
7
  {{/path}}
8
8
 
9
9
  {{#description}}
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.8
4
+ version: 2.2.4
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-12-04 00:00:00.000000000 Z
13
+ date: 2021-02-24 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.4.0
416
+ version: 2.5.0
417
417
  required_rubygems_version: !ruby/object:Gem::Requirement
418
418
  requirements:
419
419
  - - ">="