onebox 1.8.85 → 1.8.86
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/Gemfile.lock +1 -1
- data/lib/onebox/engine/github_blob_onebox.rb +1 -1
- data/lib/onebox/engine/vimeo_onebox.rb +22 -3
- data/lib/onebox/engine/whitelisted_generic_onebox.rb +4 -2
- data/lib/onebox/mixins/git_blob_onebox.rb +38 -27
- data/lib/onebox/sanitize_config.rb +1 -1
- data/lib/onebox/version.rb +1 -1
- data/templates/githubblob.mustache +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 631c22d7ba52fd8d88052176bc42a74bfec14409ec65da82c9b8bf8eb64bae79
|
4
|
+
data.tar.gz: '09d424a57ca87f9dd5c3be877c9b8ad0bd3cf4101536d3bbcf158f9ef9fef7de'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65cd19cd9e45693343c0cc470f9511d53eb7c43829a56591f18df1bd72583847c29533074ccc366916a45545a7824849298e7ed3d4bb42031f76d431a1824c6e
|
7
|
+
data.tar.gz: 00f273d8ba17d3d4a5046bed67bccba703bd02d3f3ea96d727685fab1b4406dab017650872e8fdc329ffe6ad50f5d683884b37c7367200d5f7f29d387c5a6d1e
|
data/Gemfile.lock
CHANGED
@@ -15,7 +15,7 @@ module Onebox
|
|
15
15
|
/github\.com\/(?<user>[^\/]+)\/(?<repo>[^\/]+)\/blob\/(?<sha1>[^\/]+)\/(?<file>[^#]+)(#(L(?<from>[^-]*)(-L(?<to>.*))?))?/mi
|
16
16
|
end
|
17
17
|
def raw_template(m)
|
18
|
-
"https://raw.
|
18
|
+
"https://raw.githubusercontent.com/#{m[:user]}/#{m[:repo]}/#{m[:sha1]}/#{m[:file]}"
|
19
19
|
end
|
20
20
|
def title
|
21
21
|
Sanitize.fragment(URI.unescape(link).sub(/^https?\:\/\/github\.com\//, ''))
|
@@ -7,13 +7,32 @@ module Onebox
|
|
7
7
|
matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+(\/[^\/]+)?$/)
|
8
8
|
always_https
|
9
9
|
|
10
|
+
WIDTH ||= 640
|
11
|
+
HEIGHT ||= 360
|
12
|
+
|
10
13
|
def placeholder_html
|
11
|
-
|
12
|
-
"<img src='#{
|
14
|
+
image_src = og_data.image_secure_url || og_data.image_url
|
15
|
+
"<img src='#{image_src}' width='#{WIDTH}' height='#{HEIGHT}' #{og_data.title_attr}>"
|
13
16
|
end
|
14
17
|
|
15
18
|
def to_html
|
16
|
-
|
19
|
+
video_src = og_data.video_secure_url || og_data.video_url
|
20
|
+
video_src = video_src.gsub('autoplay=1', '').chomp("?")
|
21
|
+
<<-HTML
|
22
|
+
<iframe width="#{WIDTH}"
|
23
|
+
height="#{HEIGHT}"
|
24
|
+
src="#{video_src}"
|
25
|
+
data-original-href="#{link}"
|
26
|
+
frameborder="0"
|
27
|
+
allowfullscreen>
|
28
|
+
</iframe>
|
29
|
+
HTML
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def og_data
|
35
|
+
@og_data = get_opengraph
|
17
36
|
end
|
18
37
|
end
|
19
38
|
end
|
@@ -336,15 +336,17 @@ module Onebox
|
|
336
336
|
end
|
337
337
|
|
338
338
|
def video_html
|
339
|
-
|
339
|
+
escaped_video_src = ::Onebox::Helpers.normalize_url_for_output(data[:video])
|
340
|
+
escaped_image_src = ::Onebox::Helpers.normalize_url_for_output(data[:image])
|
340
341
|
|
341
342
|
<<-HTML
|
342
343
|
<video title='#{data[:title]}'
|
343
344
|
width='#{data[:video_width]}'
|
344
345
|
height='#{data[:video_height]}'
|
345
346
|
style='max-width:100%'
|
347
|
+
poster='#{escaped_image_src}'
|
346
348
|
controls=''>
|
347
|
-
<source src='#{
|
349
|
+
<source src='#{escaped_video_src}'>
|
348
350
|
</video>
|
349
351
|
HTML
|
350
352
|
end
|
@@ -158,38 +158,46 @@ module Onebox
|
|
158
158
|
|
159
159
|
@file = m[:file]
|
160
160
|
@lang = Onebox::FileTypeFinder.from_file_name(m[:file])
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
161
|
+
|
162
|
+
if @lang == "stl" && link.match(/^https?:\/\/(www\.)?github\.com.*\/blob\//)
|
163
|
+
|
164
|
+
@model_file = @lang.dup
|
165
|
+
@raw = "https://render.githubusercontent.com/view/solid?url=" + self.raw_template(m)
|
166
|
+
|
167
|
+
else
|
168
|
+
contents = open(self.raw_template(m), read_timeout: timeout).read
|
169
|
+
|
170
|
+
contents_lines = contents.lines #get contents lines
|
171
|
+
contents_lines_size = contents_lines.size #get number of lines
|
172
|
+
|
173
|
+
cr = calc_range(m, contents_lines_size) #calculate the range of lines for output
|
174
|
+
selected_one_liner = cr[:selected_one_liner] #if url is a one-liner calc_range will return it
|
175
|
+
from = cr[:from]
|
176
|
+
to = cr[:to]
|
177
|
+
@truncated = cr[:truncated]
|
178
|
+
range_provided = cr[:range_provided]
|
179
|
+
@cr_results = cr
|
180
|
+
|
181
|
+
if range_provided #if a range provided (single line or more)
|
182
|
+
if SHOW_LINE_NUMBER
|
183
|
+
lines_result = line_number_helper(contents_lines[(from - 1)..(to - 1)], from, selected_one_liner) #print code with prefix line numbers in case range provided
|
184
|
+
contents = lines_result[:output]
|
185
|
+
@selected_lines_array = lines_result[:array]
|
186
|
+
else
|
187
|
+
contents = contents_lines[(from - 1)..(to - 1)].join()
|
188
|
+
end
|
189
|
+
|
179
190
|
else
|
180
191
|
contents = contents_lines[(from - 1)..(to - 1)].join()
|
181
192
|
end
|
182
193
|
|
183
|
-
|
184
|
-
|
185
|
-
|
194
|
+
if contents.length > MAX_CHARS #truncate content chars to limits
|
195
|
+
contents = contents[0..MAX_CHARS]
|
196
|
+
@truncated = true
|
197
|
+
end
|
186
198
|
|
187
|
-
|
188
|
-
contents = contents[0..MAX_CHARS]
|
189
|
-
@truncated = true
|
199
|
+
@raw = contents
|
190
200
|
end
|
191
|
-
|
192
|
-
@raw = contents
|
193
201
|
end
|
194
202
|
end
|
195
203
|
|
@@ -206,7 +214,10 @@ module Onebox
|
|
206
214
|
has_lines: !@selected_lines_array.nil?,
|
207
215
|
selected_one_liner: @selected_one_liner,
|
208
216
|
cr_results: @cr_results,
|
209
|
-
truncated: @truncated
|
217
|
+
truncated: @truncated,
|
218
|
+
model_file: @model_file,
|
219
|
+
width: 480,
|
220
|
+
height: 360
|
210
221
|
}
|
211
222
|
end
|
212
223
|
end
|
@@ -10,7 +10,7 @@ class Sanitize
|
|
10
10
|
'a' => RELAXED[:attributes]['a'] + %w(target),
|
11
11
|
'audio' => %w[controls],
|
12
12
|
'embed' => %w[height src type width],
|
13
|
-
'iframe' => %w[allowfullscreen frameborder height scrolling src width],
|
13
|
+
'iframe' => %w[allowfullscreen frameborder height scrolling src width data-original-href],
|
14
14
|
'source' => %w[src type],
|
15
15
|
'video' => %w[controls height loop width autoplay muted poster],
|
16
16
|
'path' => %w[d],
|
data/lib/onebox/version.rb
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
<h4><a href="{{link}}" target="_blank">{{title}}</a></h4>
|
2
2
|
{{^has_lines}}
|
3
|
+
{{#model_file}}
|
4
|
+
<iframe class="render-viewer" width="{{width}}" height="{{height}}" src="{{content}}" sandbox="allow-scripts allow-same-origin allow-top-navigation ">
|
5
|
+
Viewer requires iframe.
|
6
|
+
</iframe>
|
7
|
+
{{/model_file}}
|
8
|
+
{{^model_file}}
|
3
9
|
<pre><code class='{{lang}}'>{{content}}</code></pre>
|
10
|
+
{{/model_file}}
|
4
11
|
{{/has_lines}}
|
5
12
|
{{#has_lines}}
|
6
13
|
{{! This is a template comment | Sample rules for this box
|
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.86
|
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: 2019-04-
|
13
|
+
date: 2019-04-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: multi_json
|