onebox 2.2.8 → 2.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +34 -12
- 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/gfycat_onebox.rb +1 -1
- 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 +9 -1
- 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 +8 -8
- 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/html.rb +5 -1
- 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/pastebin_onebox.rb +1 -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/twitter_status_onebox.rb +1 -1
- 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 +46 -17
- data/lib/onebox/file_type_finder.rb +0 -1
- data/lib/onebox/helpers.rb +25 -14
- 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/sanitize_config.rb +1 -1
- 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 +1 -0
- metadata +7 -5
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Onebox
|
4
|
+
module Mixins
|
5
|
+
module GithubBody
|
6
|
+
def self.included(klass)
|
7
|
+
klass.include(Onebox::Engine)
|
8
|
+
klass.include(InstanceMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
GITHUB_COMMENT_REGEX = /(<!--.*?-->\r\n)/
|
13
|
+
MAX_BODY_LENGTH = 80
|
14
|
+
def compute_body(body)
|
15
|
+
body = body.dup
|
16
|
+
excerpt = nil
|
17
|
+
|
18
|
+
body = (body || '').gsub(GITHUB_COMMENT_REGEX, '')
|
19
|
+
body = body.length > 0 ? body : nil
|
20
|
+
if body && body.length > MAX_BODY_LENGTH
|
21
|
+
excerpt = body[MAX_BODY_LENGTH..body.length].rstrip
|
22
|
+
body = body[0..MAX_BODY_LENGTH - 1]
|
23
|
+
end
|
24
|
+
|
25
|
+
[body, excerpt]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/onebox/preview.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
module Onebox
|
4
4
|
class Preview
|
5
|
-
|
6
5
|
# see https://bugs.ruby-lang.org/issues/14688
|
7
6
|
client_exception = defined?(Net::HTTPClientException) ? Net::HTTPClientException : Net::HTTPServerException
|
8
7
|
WEB_EXCEPTIONS ||= [client_exception, OpenURI::HTTPError, Timeout::Error, Net::HTTPError, Errno::ECONNREFUSED]
|
@@ -85,7 +84,7 @@ module Onebox
|
|
85
84
|
|
86
85
|
def engine
|
87
86
|
return nil unless @engine_class
|
88
|
-
return @engine if @engine
|
87
|
+
return @engine if defined?(@engine)
|
89
88
|
|
90
89
|
@engine = @engine_class.new(@url)
|
91
90
|
@engine.options = @options
|
@@ -6,7 +6,7 @@ class Sanitize
|
|
6
6
|
HTTP_PROTOCOLS ||= ['http', 'https', :relative].freeze
|
7
7
|
|
8
8
|
ONEBOX ||= freeze_config merge(RELAXED,
|
9
|
-
elements: RELAXED[:elements] + %w[audio embed iframe source video svg path],
|
9
|
+
elements: RELAXED[:elements] + %w[audio details embed iframe source video svg path],
|
10
10
|
|
11
11
|
attributes: {
|
12
12
|
'a' => RELAXED[:attributes]['a'] + %w(target),
|
data/lib/onebox/version.rb
CHANGED
@@ -0,0 +1,3 @@
|
|
1
|
+
{{#body}}
|
2
|
+
<p class="github-body-container">{{body}}{{#excerpt}}<span class="show-more-container"><a href="{{html_url}}" target="_blank" rel="noopener" class="show-more">…</a>{{/excerpt}}</span>{{#excerpt}}<span class="excerpt hidden">{{excerpt}}</span>{{/excerpt}}</p>
|
3
|
+
{{/body}}
|
@@ -26,15 +26,13 @@
|
|
26
26
|
</a>
|
27
27
|
</div>
|
28
28
|
</div>
|
29
|
-
</div>
|
30
|
-
</div>
|
31
29
|
|
32
|
-
|
33
|
-
<p class='github-content'>{{content}}</p>
|
34
|
-
</div>
|
30
|
+
{{> github/github_body}}
|
35
31
|
|
36
|
-
<div class='labels'>
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
<div class='labels'>
|
33
|
+
{{#labels}}
|
34
|
+
<span style="display:inline-block;margin-top:2px;background-color: #B8B8B8;padding: 2px;border-radius: 4px;color: #fff;margin-left: 3px;">{{name}}</span>
|
35
|
+
{{/labels}}
|
36
|
+
</div>
|
37
|
+
</div>
|
40
38
|
</div>
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onebox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joanna Zeta
|
8
8
|
- Vyki Englert
|
9
9
|
- Robin Ward
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -367,6 +367,7 @@ files:
|
|
367
367
|
- lib/onebox/layout_support.rb
|
368
368
|
- lib/onebox/matcher.rb
|
369
369
|
- lib/onebox/mixins/git_blob_onebox.rb
|
370
|
+
- lib/onebox/mixins/github_body.rb
|
370
371
|
- lib/onebox/mixins/twitch_onebox.rb
|
371
372
|
- lib/onebox/oembed.rb
|
372
373
|
- lib/onebox/open_graph.rb
|
@@ -382,6 +383,7 @@ files:
|
|
382
383
|
- templates/_layout.mustache
|
383
384
|
- templates/allowlistedgeneric.mustache
|
384
385
|
- templates/amazon.mustache
|
386
|
+
- templates/github/github_body.mustache
|
385
387
|
- templates/githubblob.mustache
|
386
388
|
- templates/githubcommit.mustache
|
387
389
|
- templates/githubfolder.mustache
|
@@ -405,7 +407,7 @@ homepage: https://github.com/discourse/onebox
|
|
405
407
|
licenses:
|
406
408
|
- MIT
|
407
409
|
metadata: {}
|
408
|
-
post_install_message:
|
410
|
+
post_install_message:
|
409
411
|
rdoc_options: []
|
410
412
|
require_paths:
|
411
413
|
- lib
|
@@ -421,7 +423,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
421
423
|
version: '0'
|
422
424
|
requirements: []
|
423
425
|
rubygems_version: 3.0.3
|
424
|
-
signing_key:
|
426
|
+
signing_key:
|
425
427
|
specification_version: 4
|
426
428
|
summary: A gem for generating embeddable HTML previews from URLs.
|
427
429
|
test_files: []
|