onebox 1.8.36 → 1.8.38

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
- SHA256:
3
- metadata.gz: 75def311705c3e04f08f263f624625bfa3e57b0183dc72f89c93ba3756a27ef4
4
- data.tar.gz: d60df762c104ceeeb7f7370429bef4bd305e88a0b0dbb6457a21f3aa600db879
2
+ SHA1:
3
+ metadata.gz: 93d84795208b6845f986569134baa989a7b0413f
4
+ data.tar.gz: 065ab0d91d48f0f70accf25491945a0e42f6484d
5
5
  SHA512:
6
- metadata.gz: 4795ca2825a9de8d12a34d857b3b5a228ce5f2c92751a04884b99e739677f4b3343c7adf731a584898c85b0d8d0c4ceb6a501c8fc59884d78423ded2a227b516
7
- data.tar.gz: 1f8fa8b09145a5802a7ee2508098efea6e50054f838a6072b7cc86a0ed813b09145085c3106e191981520bbdb10ef55a27eed912e6b5c35ccc3737f7f2c0d36b
6
+ metadata.gz: 6a3ba89b23f5930a2aff0eef44644d69927b4a816220b68c0f8cc953961b226d611564863a491f492c97e9f01674bd872ff19200eac74283043bd18e1a318e7a
7
+ data.tar.gz: b27d5b3b1f4f898ef4540899858db5420762df9aa855fef9ea11c651caf681fe081891ace02cb5502908d9b019dc0a8021a9928066c3902887624156ef88867f
@@ -18,14 +18,32 @@ module Onebox
18
18
 
19
19
  def to_html
20
20
  <<-HTML
21
- <div>
22
- <video controls loop autoplay muted poster="#{data[:posterUrl]}" width="#{data[:width]}" height="#{data[:height]}">
23
- <source id="webmSource" src="#{data[:webmUrl]}" type="video/webm">
24
- <source id="mp4Source" src="#{data[:mp4Url]}" type="video/mp4">
25
- <img title="Sorry, your browser doesn't support HTML5 video." src="#{data[:posterUrl]}">
26
- </video><br/>
27
- <a href="#{data[:url]}">#{data[:name]}</a>
28
- </div>
21
+ <aside class="onebox gfycat">
22
+ <header class="source">
23
+ <img src="https://gfycat.com/static/favicons/favicon-96x96.png" class="site-icon" width="64" height="64">
24
+ <a href="#{data[:url]}" target="_blank" rel="nofollow noopener">Gfycat.com</a>
25
+ </header>
26
+ <article class="onebox-body">
27
+ <h4>
28
+ #{data[:title]} by
29
+ <a href="https://gfycat.com/@#{data[:author]}" target="_blank" rel="nofollow noopener">
30
+ <span>#{data[:author]}</span>
31
+ </a>
32
+ </h4>
33
+
34
+ <div class="video">
35
+ <video controls loop #{data[:autoplay]} muted poster="#{data[:posterUrl]}" style="--aspect-ratio: #{data[:width]}/#{data[:height]}">
36
+ <source id="webmSource" src="#{data[:webmUrl]}" type="video/webm">
37
+ <source id="mp4Source" src="#{data[:mp4Url]}" type="video/mp4">
38
+ <img title="Sorry, your browser doesn't support HTML5 video." src="#{data[:posterUrl]}">
39
+ </video>
40
+ </div>
41
+ <p>
42
+ <span class="label1">#{data[:tags]}</span>
43
+ </p>
44
+
45
+ </article>
46
+ </aside>
29
47
  HTML
30
48
  end
31
49
 
@@ -41,18 +59,27 @@ module Onebox
41
59
  private
42
60
 
43
61
  def match
44
- @match ||= @url.match(/^https?:\/\/gfycat\.com\/(?<name>.+)/)
62
+ @match ||= @url.match(/^https?:\/\/gfycat\.com\/(gifs\/detail\/)?(?<name>.+)/)
45
63
  end
46
64
 
47
65
  def data
66
+
67
+ total_tags = [raw['gfyItem']['tags'], raw['gfyItem']['userTags']].flatten.compact
68
+ tag_links = total_tags.map { |t| "<a href='https://gfycat.com/gifs/search/#{t}'>##{t}</a>" }.join(' ') if total_tags
69
+ autoplay = raw['gfyItem']['webmSize'].to_i < 10485760 ? 'autoplay' : ''
70
+
48
71
  {
49
72
  name: raw['gfyItem']['gfyName'],
73
+ title: raw['gfyItem']['title'] || 'No Title',
74
+ author: raw['gfyItem']['userName'],
75
+ tags: tag_links,
50
76
  url: @url,
51
77
  posterUrl: raw['gfyItem']['posterUrl'],
52
78
  webmUrl: raw['gfyItem']['webmUrl'],
53
79
  mp4Url: raw['gfyItem']['mp4Url'],
54
80
  width: raw['gfyItem']['width'],
55
- height: raw['gfyItem']['height']
81
+ height: raw['gfyItem']['height'],
82
+ autoplay: autoplay
56
83
  }
57
84
  end
58
85
 
@@ -10,7 +10,7 @@ module Onebox
10
10
  def to_html
11
11
  opengraph = get_opengraph
12
12
 
13
- src = opengraph[:video_url].gsub("?autostart=1", "")
13
+ src = opengraph[:video_url].gsub("autostart=1", "")
14
14
  escaped_src = ::Onebox::Helpers.normalize_url_for_output(src)
15
15
 
16
16
  <<-HTML
@@ -12,7 +12,7 @@ class Sanitize
12
12
  'embed' => %w[height src type width],
13
13
  'iframe' => %w[allowfullscreen frameborder height scrolling src width],
14
14
  'source' => %w[src type],
15
- 'video' => %w[controls height loop width],
15
+ 'video' => %w[controls height loop width autoplay muted poster],
16
16
  'div' => [:data], # any data-* attributes
17
17
  },
18
18
 
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.8.36"
2
+ VERSION = "1.8.38"
3
3
  end
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.8.36
4
+ version: 1.8.38
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: 2018-01-11 00:00:00.000000000 Z
13
+ date: 2018-02-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -511,7 +511,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
511
511
  version: '0'
512
512
  requirements: []
513
513
  rubyforge_project:
514
- rubygems_version: 2.7.3
514
+ rubygems_version: 2.5.2
515
515
  signing_key:
516
516
  specification_version: 4
517
517
  summary: A gem for turning URLs into previews.