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 +4 -4
- data/lib/onebox/engine.rb +1 -0
- data/lib/onebox/engine/giphy_onebox.rb +20 -0
- data/lib/onebox/engine/standard_embed.rb +4 -3
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +1 -1
- data/lib/onebox/engine/youtube_onebox.rb +1 -1
- data/lib/onebox/version.rb +1 -1
- data/spec/lib/onebox/engine/youtube_onebox_spec.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98f6286920826da98121c8d36aa07ba8188e0b30
|
4
|
+
data.tar.gz: 5bc9ca2a886a63491a493d3d793f56850b8477c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9391bbf88620ce75eb1d9872b1a23b8852fd96c9bdc2a61e37216b02f8494c10afe34809ce00a8925363124ab7f5a71cb6861c9b760bf0fdb210dea27457109a
|
7
|
+
data.tar.gz: 26babfa1d71b8c5b3b83a53424a2d44cda284035f8b4eca95efae2de3b891a7e149407eb1b10de16bbb96740cde38e7319b2464666790fe2c0916f56e1301bf6
|
data/lib/onebox/engine.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
87
|
-
|
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?
|
data/lib/onebox/version.rb
CHANGED
@@ -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.
|
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-
|
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
|