onebox 1.8.65 → 1.8.66
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/google_photos_onebox.rb +67 -0
- data/lib/onebox/engine/imgur_onebox.rb +2 -1
- data/lib/onebox/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3540aa0601e2e97d7837c59ea29849a2df8238954058d7392aac531451a2f5a4
|
4
|
+
data.tar.gz: 7145bc998e97ae158b25dbfe8d1aefef7738f40b0c392f3c784cfc5eba9e557e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e5c957d7db902ed14efc63d25c32ad61379818a0135872655b80929a2f613a278a27c7bc50b45edebc1aa0f6f8df52c74c30f4d3560c3b291a2525fd550858b
|
7
|
+
data.tar.gz: 3e6c7c2b69e745a42fd8a916e9b9e7860f476d2eb1fc47c7fb541c3d13ca5d179122e6a46729f61a09fcc71eaf347c7e4db8b0db40bd0fd6629b1b51efaa2a77
|
data/lib/onebox/engine.rb
CHANGED
@@ -0,0 +1,67 @@
|
|
1
|
+
module Onebox
|
2
|
+
module Engine
|
3
|
+
class GooglePhotosOnebox
|
4
|
+
include Engine
|
5
|
+
include StandardEmbed
|
6
|
+
|
7
|
+
matches_regexp(/^https?:\/\/(photos)\.(app\.goo\.gl|google\.com)/)
|
8
|
+
always_https
|
9
|
+
|
10
|
+
def to_html
|
11
|
+
og = get_opengraph
|
12
|
+
return video_html(og) if !Onebox::Helpers::blank?(og[:video_secure_url])
|
13
|
+
return album_html(og) if !Onebox::Helpers::blank?(og[:type]) && og[:type] == "google_photos:photo_album"
|
14
|
+
return image_html(og) if !Onebox::Helpers::blank?(og[:image])
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def video_html(og)
|
21
|
+
escaped_src = ::Onebox::Helpers.normalize_url_for_output(og[:video_secure_url])
|
22
|
+
|
23
|
+
<<-HTML
|
24
|
+
<video width='#{og[:video_width]}' height='#{og[:video_height]}' #{Helpers.title_attr(og)} controls loop>
|
25
|
+
<source src='#{escaped_src}' type='video/mp4'>
|
26
|
+
</video>
|
27
|
+
HTML
|
28
|
+
end
|
29
|
+
|
30
|
+
def album_html(og)
|
31
|
+
escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
|
32
|
+
escaped_src = ::Onebox::Helpers.normalize_url_for_output(get_secure_link(og[:image]))
|
33
|
+
album_title = "[Album] #{Onebox::Helpers.truncate(og[:title].strip, 80)}"
|
34
|
+
|
35
|
+
<<-HTML
|
36
|
+
<div class='onebox google-photos-album'>
|
37
|
+
<a href='#{escaped_url}' target='_blank'>
|
38
|
+
<span class='outer-box' style='width:#{og[:image_width]}px'>
|
39
|
+
<span class='inner-box'>
|
40
|
+
<span class='album-title'>#{album_title}</span>
|
41
|
+
</span>
|
42
|
+
</span>
|
43
|
+
<img src='#{escaped_src}' #{Helpers.title_attr(og)} height='#{og[:image_height]}' width='#{og[:image_width]}'>
|
44
|
+
</a>
|
45
|
+
</div>
|
46
|
+
HTML
|
47
|
+
end
|
48
|
+
|
49
|
+
def image_html(og)
|
50
|
+
escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
|
51
|
+
escaped_src = ::Onebox::Helpers.normalize_url_for_output(get_secure_link(og[:image]))
|
52
|
+
|
53
|
+
<<-HTML
|
54
|
+
<a href='#{escaped_url}' target='_blank' class="onebox">
|
55
|
+
<img src='#{escaped_src}' #{Helpers.title_attr(og)} alt='Google Photos' height='#{og[:image_height]}' width='#{og[:image_width]}'>
|
56
|
+
</a>
|
57
|
+
HTML
|
58
|
+
end
|
59
|
+
|
60
|
+
def get_secure_link(link)
|
61
|
+
secure_link = URI(link)
|
62
|
+
secure_link.scheme = 'https'
|
63
|
+
secure_link.to_s
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -31,13 +31,14 @@ module Onebox
|
|
31
31
|
def album_html(og)
|
32
32
|
escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
|
33
33
|
escaped_src = ::Onebox::Helpers.normalize_url_for_output(get_secure_link(og[:image]))
|
34
|
+
album_title = "[Album] #{Onebox::Helpers.truncate(og[:title].strip, 80)}"
|
34
35
|
|
35
36
|
<<-HTML
|
36
37
|
<div class='onebox imgur-album'>
|
37
38
|
<a href='#{escaped_url}' target='_blank'>
|
38
39
|
<span class='outer-box' style='width:#{og[:image_width]}px'>
|
39
40
|
<span class='inner-box'>
|
40
|
-
<span class='album-title'
|
41
|
+
<span class='album-title'>#{album_title}</span>
|
41
42
|
</span>
|
42
43
|
</span>
|
43
44
|
<img src='#{escaped_src}' #{Helpers.title_attr(og)} height='#{og[:image_height]}' width='#{og[:image_width]}'>
|
data/lib/onebox/version.rb
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: 1.8.
|
4
|
+
version: 1.8.66
|
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-
|
13
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|
@@ -322,6 +322,7 @@ files:
|
|
322
322
|
- lib/onebox/engine/google_calendar_onebox.rb
|
323
323
|
- lib/onebox/engine/google_docs_onebox.rb
|
324
324
|
- lib/onebox/engine/google_maps_onebox.rb
|
325
|
+
- lib/onebox/engine/google_photos_onebox.rb
|
325
326
|
- lib/onebox/engine/google_play_app_onebox.rb
|
326
327
|
- lib/onebox/engine/html.rb
|
327
328
|
- lib/onebox/engine/image_onebox.rb
|
@@ -413,7 +414,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
413
414
|
version: '0'
|
414
415
|
requirements: []
|
415
416
|
rubyforge_project:
|
416
|
-
rubygems_version: 2.7.
|
417
|
+
rubygems_version: 2.7.8
|
417
418
|
signing_key:
|
418
419
|
specification_version: 4
|
419
420
|
summary: A gem for generating embeddable HTML previews from URLs.
|