onebox 1.8.68 → 1.8.69
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.rubocop.yml +1 -112
- data/README.md +0 -1
- data/lib/onebox/engine/asciinema_onebox.rb +3 -3
- data/lib/onebox/engine/cloudapp_onebox.rb +14 -14
- data/lib/onebox/engine/douban_onebox.rb +8 -8
- data/lib/onebox/engine/gfycat_onebox.rb +21 -21
- data/lib/onebox/engine/google_photos_onebox.rb +21 -21
- data/lib/onebox/engine/imgur_onebox.rb +26 -26
- data/lib/onebox/engine/soundcloud_onebox.rb +9 -9
- data/lib/onebox/engine/standard_embed.rb +50 -50
- data/lib/onebox/engine/trello_onebox.rb +5 -5
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +66 -66
- data/lib/onebox/engine/wikimedia_onebox.rb +14 -14
- data/lib/onebox/engine/wistia_onebox.rb +8 -8
- data/lib/onebox/engine/xkcd_onebox.rb +11 -11
- data/lib/onebox/engine/youtube_onebox.rb +78 -78
- data/lib/onebox/file_type_finder.rb +19 -19
- data/lib/onebox/helpers.rb +3 -3
- data/lib/onebox/layout.rb +28 -28
- data/lib/onebox/mixins/git_blob_onebox.rb +1 -1
- data/lib/onebox/preview.rb +31 -31
- data/lib/onebox/sanitize_config.rb +9 -7
- data/lib/onebox/version.rb +1 -1
- data/templates/twitterstatus.mustache +10 -2
- metadata +2 -2
@@ -11,13 +11,13 @@ module Onebox
|
|
11
11
|
#
|
12
12
|
# For easy reference, keep these sorted in alphabetical order.
|
13
13
|
@long_file_types = {
|
14
|
-
".bib"
|
15
|
-
".html.hbs"
|
14
|
+
".bib" => "tex",
|
15
|
+
".html.hbs" => "handlebars",
|
16
16
|
".html.handlebars" => "handlebars",
|
17
|
-
".latex"
|
18
|
-
".ru"
|
19
|
-
".simplecov"
|
20
|
-
".sty"
|
17
|
+
".latex" => "tex",
|
18
|
+
".ru" => "rb",
|
19
|
+
".simplecov" => "rb", # Not official, but seems commonly found
|
20
|
+
".sty" => "tex"
|
21
21
|
}
|
22
22
|
|
23
23
|
# Some extensionless files for which we know the type
|
@@ -27,24 +27,24 @@ module Onebox
|
|
27
27
|
# For easy reference, keep these sorted in alphabetical order,
|
28
28
|
# FIRST by their types and THEN by their names.
|
29
29
|
@extensionless_files = {
|
30
|
-
"cmake.in"
|
30
|
+
"cmake.in" => "cmake",
|
31
31
|
|
32
|
-
"gruntfile"
|
33
|
-
"gulpfile"
|
32
|
+
"gruntfile" => "js",
|
33
|
+
"gulpfile" => "js",
|
34
34
|
|
35
|
-
"artisan"
|
35
|
+
"artisan" => "php",
|
36
36
|
|
37
|
-
"berksfile"
|
38
|
-
"capfile"
|
39
|
-
"cheffile"
|
37
|
+
"berksfile" => "rb",
|
38
|
+
"capfile" => "rb",
|
39
|
+
"cheffile" => "rb",
|
40
40
|
"cheffile.lock" => "rb",
|
41
|
-
"gemfile"
|
42
|
-
"guardfile"
|
43
|
-
"rakefile"
|
44
|
-
"thorfile"
|
45
|
-
"vagrantfile"
|
41
|
+
"gemfile" => "rb",
|
42
|
+
"guardfile" => "rb",
|
43
|
+
"rakefile" => "rb",
|
44
|
+
"thorfile" => "rb",
|
45
|
+
"vagrantfile" => "rb",
|
46
46
|
|
47
|
-
"boxfile"
|
47
|
+
"boxfile" => "yaml" # Not currently (2014-11) in Highlight.js
|
48
48
|
}
|
49
49
|
|
50
50
|
def self.from_file_name(file_name)
|
data/lib/onebox/helpers.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Onebox
|
2
2
|
module Helpers
|
3
3
|
|
4
|
-
class DownloadTooLarge < StandardError; end
|
4
|
+
class DownloadTooLarge < StandardError; end
|
5
5
|
|
6
6
|
def self.symbolize_keys(hash)
|
7
7
|
return {} if hash.nil?
|
@@ -137,8 +137,8 @@ module Onebox
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def self.pretty_filesize(size)
|
140
|
-
conv = [ 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB' ]
|
141
|
-
scale = 1024
|
140
|
+
conv = [ 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB' ]
|
141
|
+
scale = 1024
|
142
142
|
|
143
143
|
ndx = 1
|
144
144
|
if (size < 2 * (scale**ndx)) then
|
data/lib/onebox/layout.rb
CHANGED
@@ -33,37 +33,37 @@ module Onebox
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
def uri
|
37
|
+
@uri = URI(link)
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
def checksum
|
41
|
+
@md5.hexdigest("#{VERSION}:#{link}")
|
42
|
+
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
def link
|
45
|
+
::Onebox::Helpers.normalize_url_for_output(record[:link])
|
46
|
+
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
def domain
|
49
|
+
record[:domain] || URI(link || '').host.to_s.sub(/^www\./, '')
|
50
|
+
end
|
51
51
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
52
|
+
def details
|
53
|
+
{
|
54
|
+
link: record[:link],
|
55
|
+
title: record[:title],
|
56
|
+
favicon: record[:favicon],
|
57
|
+
domain: domain,
|
58
|
+
article_published_time: record[:article_published_time],
|
59
|
+
article_published_time_title: record[:article_published_time_title],
|
60
|
+
metadata_1_label: record[:metadata_1_label],
|
61
|
+
metadata_1_value: record[:metadata_1_value],
|
62
|
+
metadata_2_label: record[:metadata_2_label],
|
63
|
+
metadata_2_value: record[:metadata_2_value],
|
64
|
+
subname: view.template_name,
|
65
|
+
view: view.to_html
|
66
|
+
}
|
67
|
+
end
|
68
68
|
end
|
69
69
|
end
|
@@ -202,7 +202,7 @@ module Onebox
|
|
202
202
|
# AFTER the call to `raw`! Don't get bitten by this like I did!
|
203
203
|
content: raw,
|
204
204
|
lang: "lang-#{@lang}",
|
205
|
-
lines:
|
205
|
+
lines: @selected_lines_array ,
|
206
206
|
has_lines: !@selected_lines_array.nil?,
|
207
207
|
selected_one_liner: @selected_one_liner,
|
208
208
|
cr_results: @cr_results,
|
data/lib/onebox/preview.rb
CHANGED
@@ -33,48 +33,48 @@ module Onebox
|
|
33
33
|
|
34
34
|
private
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
def engine_html
|
37
|
+
engine.to_html
|
38
|
+
end
|
39
39
|
|
40
|
-
|
41
|
-
|
40
|
+
def process_html(html)
|
41
|
+
return "" unless html
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
if @options[:max_width]
|
44
|
+
doc = Nokogiri::HTML::fragment(html)
|
45
|
+
if doc
|
46
|
+
doc.css('[width]').each do |e|
|
47
|
+
width = e['width'].to_i
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
e['width'] = @options[:max_width]
|
49
|
+
if width > @options[:max_width]
|
50
|
+
height = e['height'].to_i
|
51
|
+
if (height > 0)
|
52
|
+
ratio = (height.to_f / width.to_f)
|
53
|
+
e['height'] = (@options[:max_width] * ratio).floor
|
56
54
|
end
|
55
|
+
e['width'] = @options[:max_width]
|
57
56
|
end
|
58
|
-
return doc.to_html
|
59
57
|
end
|
58
|
+
return doc.to_html
|
60
59
|
end
|
61
|
-
|
62
|
-
html
|
63
60
|
end
|
64
61
|
|
65
|
-
|
66
|
-
|
67
|
-
end
|
62
|
+
html
|
63
|
+
end
|
68
64
|
|
69
|
-
|
70
|
-
|
71
|
-
|
65
|
+
def sanitize(html)
|
66
|
+
Sanitize.fragment(html, @options[:sanitize_config] || Sanitize::Config::ONEBOX)
|
67
|
+
end
|
72
68
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
69
|
+
def engine
|
70
|
+
return nil unless @engine_class
|
71
|
+
return @engine if @engine
|
72
|
+
|
73
|
+
@engine = @engine_class.new(@url, cache)
|
74
|
+
@engine.options = @options
|
75
|
+
@engine
|
76
|
+
end
|
77
77
|
|
78
|
-
|
78
|
+
class InvalidURI < StandardError; end
|
79
79
|
end
|
80
80
|
end
|
@@ -4,16 +4,18 @@ class Sanitize
|
|
4
4
|
HTTP_PROTOCOLS ||= ['http', 'https', :relative].freeze
|
5
5
|
|
6
6
|
ONEBOX ||= freeze_config merge(RELAXED,
|
7
|
-
elements: RELAXED[:elements] + %w[audio embed iframe source video],
|
7
|
+
elements: RELAXED[:elements] + %w[audio embed iframe source video svg path],
|
8
8
|
|
9
9
|
attributes: {
|
10
|
-
'a'
|
11
|
-
'audio'
|
12
|
-
'embed'
|
10
|
+
'a' => RELAXED[:attributes]['a'] + %w(target),
|
11
|
+
'audio' => %w[controls],
|
12
|
+
'embed' => %w[height src type width],
|
13
13
|
'iframe' => %w[allowfullscreen frameborder height scrolling src width],
|
14
14
|
'source' => %w[src type],
|
15
|
-
'video'
|
16
|
-
'
|
15
|
+
'video' => %w[controls height loop width autoplay muted poster],
|
16
|
+
'path' => %w[d],
|
17
|
+
'svg' => ['aria-hidden', 'width', 'height', 'viewbox'],
|
18
|
+
'div' => [:data], # any data-* attributes
|
17
19
|
},
|
18
20
|
|
19
21
|
add_attributes: {
|
@@ -38,7 +40,7 @@ class Sanitize
|
|
38
40
|
],
|
39
41
|
|
40
42
|
protocols: {
|
41
|
-
'embed'
|
43
|
+
'embed' => { 'src' => HTTP_PROTOCOLS },
|
42
44
|
'iframe' => { 'src' => HTTP_PROTOCOLS },
|
43
45
|
'source' => { 'src' => HTTP_PROTOCOLS },
|
44
46
|
},
|
data/lib/onebox/version.rb
CHANGED
@@ -10,9 +10,17 @@
|
|
10
10
|
<div class='date'>
|
11
11
|
<a href="{{link}}" target="_blank">{{timestamp}}</a>
|
12
12
|
{{#likes}}
|
13
|
-
<span class="like"
|
13
|
+
<span class="like">
|
14
|
+
<svg viewBox="0 0 512 512" width="14px" height="16px" aria-hidden="true">
|
15
|
+
<path d="M462.3 62.6C407.5 15.9 326 24.3 275.7 76.2L256 96.5l-19.7-20.3C186.1 24.3 104.5 15.9 49.7 62.6c-62.8 53.6-66.1 149.8-9.9 207.9l193.5 199.8c12.5 12.9 32.8 12.9 45.3 0l193.5-199.8c56.3-58.1 53-154.3-9.8-207.9z"></path>
|
16
|
+
</svg> {{likes}}
|
17
|
+
</span>
|
14
18
|
{{/likes}}
|
15
19
|
{{#retweets}}
|
16
|
-
<span class="retweet"
|
20
|
+
<span class="retweet">
|
21
|
+
<svg viewBox="0 0 640 512" width="14px" height="16px" aria-hidden="true">
|
22
|
+
<path d="M629.657 343.598L528.971 444.284c-9.373 9.372-24.568 9.372-33.941 0L394.343 343.598c-9.373-9.373-9.373-24.569 0-33.941l10.823-10.823c9.562-9.562 25.133-9.34 34.419.492L480 342.118V160H292.451a24.005 24.005 0 0 1-16.971-7.029l-16-16C244.361 121.851 255.069 96 276.451 96H520c13.255 0 24 10.745 24 24v222.118l40.416-42.792c9.285-9.831 24.856-10.054 34.419-.492l10.823 10.823c9.372 9.372 9.372 24.569-.001 33.941zm-265.138 15.431A23.999 23.999 0 0 0 347.548 352H160V169.881l40.416 42.792c9.286 9.831 24.856 10.054 34.419.491l10.822-10.822c9.373-9.373 9.373-24.569 0-33.941L144.971 67.716c-9.373-9.373-24.569-9.373-33.941 0L10.343 168.402c-9.373 9.373-9.373 24.569 0 33.941l10.822 10.822c9.562 9.562 25.133 9.34 34.419-.491L96 169.881V392c0 13.255 10.745 24 24 24h243.549c21.382 0 32.09-25.851 16.971-40.971l-16.001-16z"></path>
|
23
|
+
</svg> {{retweets}}
|
24
|
+
</span>
|
17
25
|
{{/retweets}}
|
18
26
|
</div>
|
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.69
|
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-12-13 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|