onebox 1.5.62 → 1.5.63

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
  SHA1:
3
- metadata.gz: e4969ae9933bb333861d909df2089075648c2963
4
- data.tar.gz: 7eb13f7b5c2e8a37c43af1a56b138737c05ec16f
3
+ metadata.gz: 98f6286920826da98121c8d36aa07ba8188e0b30
4
+ data.tar.gz: 5bc9ca2a886a63491a493d3d793f56850b8477c9
5
5
  SHA512:
6
- metadata.gz: 7e2f1e665e5e62efb3cf32cc24ec61f06da47e89cdbc2db5ae3be7e436b9446b7d3eb9d0676b3af7537ff1c11c676c7653d733378c85b1a3739a328aa9cb3caa
7
- data.tar.gz: 4e43bc28d5ef4f0d60a7c11f25b57c9809774fb8ab7c594d435fcb8e2eceb472365a9ae20681f35d374272f99feec154e52481e63cf262dc3eca96a5d906f8ba
6
+ metadata.gz: 9391bbf88620ce75eb1d9872b1a23b8852fd96c9bdc2a61e37216b02f8494c10afe34809ce00a8925363124ab7f5a71cb6861c9b760bf0fdb210dea27457109a
7
+ data.tar.gz: 26babfa1d71b8c5b3b83a53424a2d44cda284035f8b4eca95efae2de3b891a7e149407eb1b10de16bbb96740cde38e7319b2464666790fe2c0916f56e1301bf6
data/lib/onebox/engine.rb CHANGED
@@ -165,3 +165,4 @@ require_relative "engine/steam_store_widget_onebox"
165
165
  require_relative "engine/pastebin_onebox"
166
166
  require_relative "engine/slides_onebox"
167
167
  require_relative "engine/xkcd_onebox"
168
+ require_relative "engine/giphy_onebox"
@@ -0,0 +1,20 @@
1
+ module Onebox
2
+ module Engine
3
+ class GiphyOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/giphy\.com\/gifs\//)
8
+
9
+ def to_html
10
+ oembed = get_oembed
11
+
12
+ <<-HTML
13
+ <a href="#{oembed[:url]}" target="_blank">
14
+ <img src="#{oembed[:image]}" width="#{oembed[:width]}" height="#{oembed[:height]}">
15
+ </a>
16
+ HTML
17
+ end
18
+ end
19
+ end
20
+ end
@@ -41,7 +41,7 @@ module Onebox
41
41
  @raw
42
42
  end
43
43
 
44
- private
44
+ protected
45
45
 
46
46
  def html_doc
47
47
  return @html_doc if @html_doc
@@ -83,8 +83,9 @@ module Onebox
83
83
  end
84
84
 
85
85
  # Attempt to retrieve the title from the meta tag
86
- if title = html_doc.at_css('title').try(:text)
87
- og[:title] ||= title unless Onebox::Helpers.blank?(title)
86
+ title_element = html_doc.at_css('title')
87
+ if title_element && title_element.text
88
+ og[:title] ||= title_element.text unless Onebox::Helpers.blank?(title_element.text)
88
89
  end
89
90
 
90
91
  og
@@ -220,10 +220,10 @@ module Onebox
220
220
 
221
221
  def generic_html
222
222
  return article_html if is_article?
223
- return embedded_html if is_embedded?
224
223
  return video_html if is_video?
225
224
  return image_html if is_image?
226
225
  return article_html if has_text?
226
+ return embedded_html if is_embedded?
227
227
  end
228
228
 
229
229
  def is_article?
@@ -65,7 +65,7 @@ module Onebox
65
65
  @video_id ||= begin
66
66
  # http://youtu.be/afyK1HSFfgw
67
67
  if uri.host["youtu.be"]
68
- id = uri.path[/\/([\w\-]+)\//, 1]
68
+ id = uri.path[/\/([\w\-]+)/, 1]
69
69
  return id if id
70
70
  end
71
71
 
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.62"
2
+ VERSION = "1.5.63"
3
3
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe Onebox::Engine::YoutubeOnebox do
4
4
  before do
5
5
  fake("https://www.youtube.com/watch?feature=player_embedded&v=21Lk4YiASMo", response("youtube"))
6
+ fake("https://youtu.be/21Lk4YiASMo", response("youtube"))
7
+ fake("http://www.youtube.com/oembed?format=json&url=http://www.youtube.com/watch?v=21Lk4YiASMo", response("youtube"))
6
8
  fake("https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ", response("youtube-channel"))
7
9
  fake("https://www.youtube.com/playlist?list=PL5308B2E5749D1696", response("youtube-playlist"))
8
10
  end
@@ -41,6 +43,7 @@ describe Onebox::Engine::YoutubeOnebox do
41
43
 
42
44
  it "returns an image as the placeholder" do
43
45
  expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo').placeholder_html).to match(/<img/)
46
+ expect(Onebox.preview('https://youtu.be/21Lk4YiASMo').placeholder_html).to match(/<img/)
44
47
  end
45
48
 
46
49
  it "passes the playlist ID through" do
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.5.62
4
+ version: 1.5.63
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: 2016-11-07 00:00:00.000000000 Z
13
+ date: 2016-11-14 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -302,6 +302,7 @@ files:
302
302
  - lib/onebox/engine/amazon_onebox.rb
303
303
  - lib/onebox/engine/audio_onebox.rb
304
304
  - lib/onebox/engine/douban_onebox.rb
305
+ - lib/onebox/engine/giphy_onebox.rb
305
306
  - lib/onebox/engine/github_blob_onebox.rb
306
307
  - lib/onebox/engine/github_commit_onebox.rb
307
308
  - lib/onebox/engine/github_gist_onebox.rb