onebox 1.8.68 → 1.8.69

Sign up to get free protection for your applications and to get access to all the features.
@@ -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" => "tex",
15
- ".html.hbs" => "handlebars",
14
+ ".bib" => "tex",
15
+ ".html.hbs" => "handlebars",
16
16
  ".html.handlebars" => "handlebars",
17
- ".latex" => "tex",
18
- ".ru" => "rb",
19
- ".simplecov" => "rb", # Not official, but seems commonly found
20
- ".sty" => "tex"
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" => "cmake",
30
+ "cmake.in" => "cmake",
31
31
 
32
- "gruntfile" => "js",
33
- "gulpfile" => "js",
32
+ "gruntfile" => "js",
33
+ "gulpfile" => "js",
34
34
 
35
- "artisan" => "php",
35
+ "artisan" => "php",
36
36
 
37
- "berksfile" => "rb",
38
- "capfile" => "rb",
39
- "cheffile" => "rb",
37
+ "berksfile" => "rb",
38
+ "capfile" => "rb",
39
+ "cheffile" => "rb",
40
40
  "cheffile.lock" => "rb",
41
- "gemfile" => "rb",
42
- "guardfile" => "rb",
43
- "rakefile" => "rb",
44
- "thorfile" => "rb",
45
- "vagrantfile" => "rb",
41
+ "gemfile" => "rb",
42
+ "guardfile" => "rb",
43
+ "rakefile" => "rb",
44
+ "thorfile" => "rb",
45
+ "vagrantfile" => "rb",
46
46
 
47
- "boxfile" => "yaml" # Not currently (2014-11) in Highlight.js
47
+ "boxfile" => "yaml" # Not currently (2014-11) in Highlight.js
48
48
  }
49
49
 
50
50
  def self.from_file_name(file_name)
@@ -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
@@ -33,37 +33,37 @@ module Onebox
33
33
 
34
34
  private
35
35
 
36
- def uri
37
- @uri = URI(link)
38
- end
36
+ def uri
37
+ @uri = URI(link)
38
+ end
39
39
 
40
- def checksum
41
- @md5.hexdigest("#{VERSION}:#{link}")
42
- end
40
+ def checksum
41
+ @md5.hexdigest("#{VERSION}:#{link}")
42
+ end
43
43
 
44
- def link
45
- ::Onebox::Helpers.normalize_url_for_output(record[:link])
46
- end
44
+ def link
45
+ ::Onebox::Helpers.normalize_url_for_output(record[:link])
46
+ end
47
47
 
48
- def domain
49
- record[:domain] || URI(link || '').host.to_s.sub(/^www\./, '')
50
- end
48
+ def domain
49
+ record[:domain] || URI(link || '').host.to_s.sub(/^www\./, '')
50
+ end
51
51
 
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
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: @selected_lines_array ,
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,
@@ -33,48 +33,48 @@ module Onebox
33
33
 
34
34
  private
35
35
 
36
- def engine_html
37
- engine.to_html
38
- end
36
+ def engine_html
37
+ engine.to_html
38
+ end
39
39
 
40
- def process_html(html)
41
- return "" unless html
40
+ def process_html(html)
41
+ return "" unless html
42
42
 
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
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
- 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
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
- def sanitize(html)
66
- Sanitize.fragment(html, @options[:sanitize_config] || Sanitize::Config::ONEBOX)
67
- end
62
+ html
63
+ end
68
64
 
69
- def engine
70
- return nil unless @engine_class
71
- return @engine if @engine
65
+ def sanitize(html)
66
+ Sanitize.fragment(html, @options[:sanitize_config] || Sanitize::Config::ONEBOX)
67
+ end
72
68
 
73
- @engine = @engine_class.new(@url, cache)
74
- @engine.options = @options
75
- @engine
76
- end
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
- class InvalidURI < StandardError; end
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' => RELAXED[:attributes]['a'] + %w(target),
11
- 'audio' => %w[controls],
12
- 'embed' => %w[height src type width],
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' => %w[controls height loop width autoplay muted poster],
16
- 'div' => [:data], # any data-* attributes
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' => { 'src' => HTTP_PROTOCOLS },
43
+ 'embed' => { 'src' => HTTP_PROTOCOLS },
42
44
  'iframe' => { 'src' => HTTP_PROTOCOLS },
43
45
  'source' => { 'src' => HTTP_PROTOCOLS },
44
46
  },
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Onebox
4
- VERSION = "1.8.68"
4
+ VERSION = "1.8.69"
5
5
  end
@@ -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"><i class="fa fa-heart"></i> {{likes}}</span>
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"><i class="fa fa-retweet"></i> {{retweets}}</span>
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.68
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-11-17 00:00:00.000000000 Z
13
+ date: 2018-12-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json