onebox 2.2.12 → 2.2.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +0 -4
- data/lib/onebox/engine.rb +1 -1
- data/lib/onebox/engine/allowlisted_generic_onebox.rb +11 -9
- data/lib/onebox/engine/amazon_onebox.rb +3 -1
- data/lib/onebox/engine/asciinema_onebox.rb +0 -1
- data/lib/onebox/engine/audioboom_onebox.rb +5 -2
- data/lib/onebox/engine/bandcamp_onebox.rb +8 -8
- data/lib/onebox/engine/cloudapp_onebox.rb +12 -12
- data/lib/onebox/engine/coub_onebox.rb +0 -1
- data/lib/onebox/engine/facebook_media_onebox.rb +8 -7
- data/lib/onebox/engine/five_hundred_px_onebox.rb +0 -1
- data/lib/onebox/engine/flickr_onebox.rb +14 -15
- data/lib/onebox/engine/giphy_onebox.rb +0 -1
- data/lib/onebox/engine/github_blob_onebox.rb +4 -0
- data/lib/onebox/engine/github_commit_onebox.rb +2 -3
- data/lib/onebox/engine/github_gist_onebox.rb +1 -2
- data/lib/onebox/engine/github_issue_onebox.rb +16 -18
- data/lib/onebox/engine/github_pullrequest_onebox.rb +7 -4
- data/lib/onebox/engine/gitlab_blob_onebox.rb +4 -0
- data/lib/onebox/engine/google_calendar_onebox.rb +1 -1
- data/lib/onebox/engine/google_docs_onebox.rb +7 -7
- data/lib/onebox/engine/google_drive_onebox.rb +7 -7
- data/lib/onebox/engine/google_maps_onebox.rb +0 -2
- data/lib/onebox/engine/google_photos_onebox.rb +14 -14
- data/lib/onebox/engine/google_play_app_onebox.rb +3 -7
- data/lib/onebox/engine/instagram_onebox.rb +2 -2
- data/lib/onebox/engine/kaltura_onebox.rb +8 -6
- data/lib/onebox/engine/opengraph_image.rb +0 -1
- data/lib/onebox/engine/pubmed_onebox.rb +3 -2
- data/lib/onebox/engine/replit_onebox.rb +0 -1
- data/lib/onebox/engine/sketchfab_onebox.rb +8 -8
- data/lib/onebox/engine/slides_onebox.rb +10 -10
- data/lib/onebox/engine/soundcloud_onebox.rb +0 -1
- data/lib/onebox/engine/stack_exchange_onebox.rb +2 -1
- data/lib/onebox/engine/standard_embed.rb +2 -2
- data/lib/onebox/engine/steam_store_onebox.rb +6 -5
- data/lib/onebox/engine/trello_onebox.rb +2 -2
- data/lib/onebox/engine/twitch_clips_onebox.rb +1 -3
- data/lib/onebox/engine/twitch_stream_onebox.rb +1 -2
- data/lib/onebox/engine/twitch_video_onebox.rb +0 -2
- data/lib/onebox/engine/typeform_onebox.rb +7 -6
- data/lib/onebox/engine/vimeo_onebox.rb +9 -7
- data/lib/onebox/engine/wikimedia_onebox.rb +1 -2
- data/lib/onebox/engine/wikipedia_onebox.rb +12 -8
- data/lib/onebox/engine/youku_onebox.rb +7 -7
- data/lib/onebox/engine/youtube_onebox.rb +14 -13
- data/lib/onebox/file_type_finder.rb +0 -1
- data/lib/onebox/helpers.rb +2 -2
- data/lib/onebox/mixins/git_blob_onebox.rb +5 -3
- data/lib/onebox/mixins/github_body.rb +30 -0
- data/lib/onebox/mixins/twitch_onebox.rb +0 -1
- data/lib/onebox/preview.rb +1 -2
- data/lib/onebox/version.rb +1 -1
- data/templates/github/github_body.mustache +3 -0
- data/templates/githubissue.mustache +7 -9
- data/templates/githubpullrequest.mustache +4 -16
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee0229502d76efea853fff81a0e756e33867b7034219bb56805dcf891ab42207
|
4
|
+
data.tar.gz: 9e6f581f0dd784f0edb841c05f4faa785bae4cfaf4ac2c482050034ead36b912
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7139dd42d40ebf30b4228c41018db4408fd53c196838c0b8d94afae27ba30d1ba258fc57fbea7ff432619f473a2e22c86b62251c094591f9a9ec90693b768655
|
7
|
+
data.tar.gz: 69d506c95f5fbf5526967195ce5f9c1224c1af71f72f0477063e4a8a0e59b8ab4300270cc28aae2cfc74f5e41187b3e3aed11b1656e83c0e766293eb932ca84a
|
data/.rspec
CHANGED
data/lib/onebox/engine.rb
CHANGED
@@ -374,15 +374,17 @@ module Onebox
|
|
374
374
|
escaped_image_src = ::Onebox::Helpers.normalize_url_for_output(data[:image])
|
375
375
|
|
376
376
|
<<-HTML
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
377
|
+
<video
|
378
|
+
title='#{data[:title]}'
|
379
|
+
width='#{data[:video_width]}'
|
380
|
+
height='#{data[:video_height]}'
|
381
|
+
style='max-width:100%'
|
382
|
+
poster='#{escaped_image_src}'
|
383
|
+
controls=''
|
384
|
+
>
|
385
|
+
<source src='#{escaped_video_src}'>
|
386
|
+
</video>
|
387
|
+
HTML
|
386
388
|
end
|
387
389
|
|
388
390
|
def embedded_html
|
@@ -14,6 +14,8 @@ module Onebox
|
|
14
14
|
matches_regexp(/^https?:\/\/(?:www\.)?(?:smile\.)?(amazon|amzn)\.(?<tld>com|ca|de|it|es|fr|co\.jp|co\.uk|cn|in|com\.br|com\.mx|nl|pl|sa|sg|se|com\.tr|ae)\//)
|
15
15
|
|
16
16
|
def url
|
17
|
+
@raw ||= nil
|
18
|
+
|
17
19
|
# If possible, fetch the cached HTML body immediately so we can
|
18
20
|
# try to grab the canonical URL from that document,
|
19
21
|
# rather than guess at the best URL structure to use
|
@@ -36,7 +38,7 @@ module Onebox
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def tld
|
39
|
-
@tld
|
41
|
+
@tld ||= @@matcher.match(@url)["tld"]
|
40
42
|
end
|
41
43
|
|
42
44
|
def http_params
|
@@ -13,14 +13,17 @@ module Onebox
|
|
13
13
|
oembed = get_oembed
|
14
14
|
|
15
15
|
<<-HTML
|
16
|
-
<img
|
16
|
+
<img
|
17
|
+
src="#{oembed.thumbnail_url}"
|
18
|
+
style="max-width: #{oembed.width}px; max-height: #{oembed.height}px;"
|
19
|
+
#{oembed.title_attr}
|
20
|
+
>
|
17
21
|
HTML
|
18
22
|
end
|
19
23
|
|
20
24
|
def to_html
|
21
25
|
get_oembed.html
|
22
26
|
end
|
23
|
-
|
24
27
|
end
|
25
28
|
end
|
26
29
|
end
|
@@ -20,16 +20,16 @@ module Onebox
|
|
20
20
|
escaped_src = og.video_secure_url || og.video
|
21
21
|
|
22
22
|
<<-HTML
|
23
|
-
<iframe
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
<iframe
|
24
|
+
src="#{escaped_src}"
|
25
|
+
width="#{og.video_width}"
|
26
|
+
height="#{og.video_height}"
|
27
|
+
scrolling="no"
|
28
|
+
frameborder="0"
|
29
|
+
allowfullscreen
|
30
|
+
></iframe>
|
30
31
|
HTML
|
31
32
|
end
|
32
|
-
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
@@ -25,28 +25,28 @@ module Onebox
|
|
25
25
|
|
26
26
|
def link_html(og)
|
27
27
|
<<-HTML
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
<a href='#{og.url}' target='_blank' rel='noopener'>
|
29
|
+
#{og.title}
|
30
|
+
</a>
|
31
|
+
HTML
|
32
32
|
end
|
33
33
|
|
34
34
|
def video_html(og)
|
35
35
|
direct_src = ::Onebox::Helpers.normalize_url_for_output("#{og.get(:url)}/#{og.title}")
|
36
36
|
|
37
37
|
<<-HTML
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
<video width='480' height='360' #{og.title_attr} controls loop>
|
39
|
+
<source src='#{direct_src}' type='video/mp4'>
|
40
|
+
</video>
|
41
|
+
HTML
|
42
42
|
end
|
43
43
|
|
44
44
|
def image_html(og)
|
45
45
|
<<-HTML
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
<a href='#{og.url}' target='_blank' class='onebox' rel='noopener'>
|
47
|
+
<img src='#{og.image}' #{og.title_attr} alt='CloudApp' width='480'>
|
48
|
+
</a>
|
49
|
+
HTML
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
@@ -14,13 +14,14 @@ module Onebox
|
|
14
14
|
metadata = get_twitter
|
15
15
|
if metadata.present? && metadata[:card] == "player" && metadata[:player].present?
|
16
16
|
<<-HTML
|
17
|
-
<iframe
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
17
|
+
<iframe
|
18
|
+
src="#{metadata[:player]}"
|
19
|
+
width="#{metadata[:player_width]}"
|
20
|
+
height="#{metadata[:player_height]}"
|
21
|
+
scrolling="no"
|
22
|
+
frameborder="0"
|
23
|
+
allowfullscreen
|
24
|
+
></iframe>
|
24
25
|
HTML
|
25
26
|
else
|
26
27
|
html = Onebox::Engine::AllowlistedGenericOnebox.new(@url, @timeout).to_html
|
@@ -25,29 +25,28 @@ module Onebox
|
|
25
25
|
album_title = "[Album] #{og.title}"
|
26
26
|
|
27
27
|
<<-HTML
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
</span>
|
28
|
+
<div class='onebox flickr-album'>
|
29
|
+
<a href='#{escaped_url}' target='_blank' rel='noopener'>
|
30
|
+
<span class='outer-box' style='max-width:#{og.image_width}px'>
|
31
|
+
<span class='inner-box'>
|
32
|
+
<span class='album-title'>#{album_title}</span>
|
34
33
|
</span>
|
35
|
-
|
36
|
-
|
37
|
-
</
|
38
|
-
|
34
|
+
</span>
|
35
|
+
<img src='#{og.get_secure_image}' #{og.title_attr} height='#{og.image_height}' width='#{og.image_width}'>
|
36
|
+
</a>
|
37
|
+
</div>
|
38
|
+
HTML
|
39
39
|
end
|
40
40
|
|
41
41
|
def image_html(og)
|
42
42
|
escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
|
43
43
|
|
44
44
|
<<-HTML
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
45
|
+
<a href='#{escaped_url}' target='_blank' rel='noopener' class="onebox">
|
46
|
+
<img src='#{og.get_secure_image}' #{og.title_attr} alt='Imgur' height='#{og.image_height}' width='#{og.image_width}'>
|
47
|
+
</a>
|
48
|
+
HTML
|
49
49
|
end
|
50
|
-
|
51
50
|
end
|
52
51
|
end
|
53
52
|
end
|
@@ -8,17 +8,21 @@ module Onebox
|
|
8
8
|
def self.git_regexp
|
9
9
|
/^https?:\/\/(www\.)?github\.com.*\/blob\//
|
10
10
|
end
|
11
|
+
|
11
12
|
def self.onebox_name
|
12
13
|
"githubblob"
|
13
14
|
end
|
14
15
|
|
15
16
|
include Onebox::Mixins::GitBlobOnebox
|
17
|
+
|
16
18
|
def raw_regexp
|
17
19
|
/github\.com\/(?<user>[^\/]+)\/(?<repo>[^\/]+)\/blob\/(?<sha1>[^\/]+)\/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?/mi
|
18
20
|
end
|
21
|
+
|
19
22
|
def raw_template(m)
|
20
23
|
"https://raw.githubusercontent.com/#{m[:user]}/#{m[:repo]}/#{m[:sha1]}/#{m[:file]}"
|
21
24
|
end
|
25
|
+
|
22
26
|
def title
|
23
27
|
Sanitize.fragment(Onebox::Helpers.uri_unencode(link).sub(/^https?\:\/\/github\.com\//, ''))
|
24
28
|
end
|
@@ -17,11 +17,10 @@ module Onebox
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def match
|
20
|
-
return @match if @match
|
20
|
+
return @match if defined?(@match)
|
21
21
|
|
22
22
|
@match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/commit/(?<sha>[^/]+)})
|
23
|
-
|
24
|
-
@match = @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<pr>[^/]+)/commit/(?<sha>[^/]+)}) if @match.nil?
|
23
|
+
@match ||= @url.match(%{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<pr>[^/]+)/commit/(?<sha>[^/]+)})
|
25
24
|
|
26
25
|
@match
|
27
26
|
end
|
@@ -9,7 +9,7 @@ module Onebox
|
|
9
9
|
|
10
10
|
MAX_FILES = 3
|
11
11
|
|
12
|
-
matches_regexp
|
12
|
+
matches_regexp(/^http(?:s)?:\/\/gist\.(?:(?:\w)+\.)?(github)\.com(?:\/)?/)
|
13
13
|
always_https
|
14
14
|
|
15
15
|
def url
|
@@ -76,7 +76,6 @@ module Onebox
|
|
76
76
|
@lines ||= @json["content"].split("\n")
|
77
77
|
end
|
78
78
|
end
|
79
|
-
|
80
79
|
end
|
81
80
|
end
|
82
81
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../mixins/github_body'
|
4
|
+
|
3
5
|
module Onebox
|
4
6
|
module Engine
|
5
7
|
class GithubIssueOnebox
|
@@ -7,7 +9,9 @@ module Onebox
|
|
7
9
|
include Engine
|
8
10
|
include LayoutSupport
|
9
11
|
include JSON
|
10
|
-
|
12
|
+
include Onebox::Mixins::GithubBody
|
13
|
+
|
14
|
+
matches_regexp(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?github\.com\/(?<org>.+)\/(?<repo>.+)\/issues\/([[:digit:]]+)/)
|
11
15
|
always_https
|
12
16
|
|
13
17
|
def url
|
@@ -22,32 +26,26 @@ module Onebox
|
|
22
26
|
end
|
23
27
|
|
24
28
|
def data
|
25
|
-
|
26
|
-
|
27
|
-
|
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.
|
29
|
-
max_words = 20
|
30
|
-
short_content = content_words[0..max_words].join(" ")
|
31
|
-
short_content += "..." if content_words.length > max_words
|
32
|
-
|
33
|
-
created_at = Time.parse(@raw['created_at'])
|
34
|
-
closed_at = Time.parse(@raw['closed_at']) if @raw['closed_at']
|
35
|
-
|
29
|
+
created_at = Time.parse(raw['created_at'])
|
30
|
+
closed_at = Time.parse(raw['closed_at']) if raw['closed_at']
|
31
|
+
body, excerpt = compute_body(raw['body'])
|
36
32
|
ulink = URI(link)
|
33
|
+
|
37
34
|
{
|
38
35
|
link: @url,
|
39
|
-
title:
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
title: raw["title"],
|
37
|
+
body: body,
|
38
|
+
excerpt: excerpt,
|
39
|
+
labels: raw["labels"],
|
40
|
+
user: raw['user'],
|
43
41
|
created_at: created_at.strftime("%I:%M%p - %d %b %y %Z"),
|
44
42
|
created_at_date: created_at.strftime("%F"),
|
45
43
|
created_at_time: created_at.strftime("%T"),
|
46
44
|
closed_at: closed_at&.strftime("%I:%M%p - %d %b %y %Z"),
|
47
45
|
closed_at_date: closed_at&.strftime("%F"),
|
48
46
|
closed_at_time: closed_at&.strftime("%T"),
|
49
|
-
closed_by:
|
50
|
-
avatar: "https://avatars1.githubusercontent.com/u/#{
|
47
|
+
closed_by: raw['closed_by'],
|
48
|
+
avatar: "https://avatars1.githubusercontent.com/u/#{raw['user']['id']}?v=2&s=96",
|
51
49
|
domain: "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}",
|
52
50
|
}
|
53
51
|
end
|
@@ -1,13 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative '../mixins/github_body'
|
4
|
+
|
3
5
|
module Onebox
|
4
6
|
module Engine
|
5
7
|
class GithubPullRequestOnebox
|
6
8
|
include Engine
|
7
9
|
include LayoutSupport
|
8
10
|
include JSON
|
11
|
+
include Onebox::Mixins::GithubBody
|
12
|
+
|
13
|
+
GITHUB_COMMENT_REGEX = /(<!--.*?-->\r\n)/
|
9
14
|
|
10
|
-
matches_regexp
|
15
|
+
matches_regexp(/^https?:\/\/(?:www\.)?(?:(?:\w)+\.)?(github)\.com(?:\/)?(?:.)*\/pull/)
|
11
16
|
always_https
|
12
17
|
|
13
18
|
def url
|
@@ -20,7 +25,6 @@ module Onebox
|
|
20
25
|
@match ||= @url.match(%r{github\.com/(?<owner>[^/]+)/(?<repository>[^/]+)/pull/(?<number>[^/]+)})
|
21
26
|
end
|
22
27
|
|
23
|
-
GITHUB_COMMENT_REGEX = /(<!--.*?-->\r\n)/
|
24
28
|
def data
|
25
29
|
result = raw.clone
|
26
30
|
result['link'] = link
|
@@ -33,8 +37,7 @@ module Onebox
|
|
33
37
|
ulink = URI(link)
|
34
38
|
result['domain'] = "#{ulink.host}/#{ulink.path.split('/')[1]}/#{ulink.path.split('/')[2]}"
|
35
39
|
|
36
|
-
body
|
37
|
-
result['body'] = body.present? ? body : nil
|
40
|
+
result['body'], result['excerpt'] = compute_body(result['body'])
|
38
41
|
|
39
42
|
result
|
40
43
|
end
|
@@ -8,17 +8,21 @@ module Onebox
|
|
8
8
|
def self.git_regexp
|
9
9
|
/^https?:\/\/(www\.)?gitlab\.com.*\/blob\//
|
10
10
|
end
|
11
|
+
|
11
12
|
def self.onebox_name
|
12
13
|
"gitlabblob"
|
13
14
|
end
|
14
15
|
|
15
16
|
include Onebox::Mixins::GitBlobOnebox
|
17
|
+
|
16
18
|
def raw_regexp
|
17
19
|
/gitlab\.com\/(?<user>[^\/]+)\/(?<repo>[^\/]+)\/blob\/(?<sha1>[^\/]+)\/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?/mi
|
18
20
|
end
|
21
|
+
|
19
22
|
def raw_template(m)
|
20
23
|
"https://gitlab.com/#{m[:user]}/#{m[:repo]}/raw/#{m[:sha1]}/#{m[:file]}"
|
21
24
|
end
|
25
|
+
|
22
26
|
def title
|
23
27
|
Sanitize.fragment(Onebox::Helpers.uri_unencode(link).sub(/^https?\:\/\/gitlab\.com\//, ''))
|
24
28
|
end
|