onebox 1.8.80 → 1.8.81

Sign up to get free protection for your applications and to get access to all the features.
Files changed (114) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -0
  3. data/.rspec +0 -0
  4. data/.rubocop.yml +0 -0
  5. data/.ruby-gemset +0 -0
  6. data/.travis.yml +0 -0
  7. data/CHANGELOG.md +26 -26
  8. data/Gemfile +0 -0
  9. data/Gemfile.lock +154 -152
  10. data/Guardfile +0 -0
  11. data/LICENSE.txt +0 -0
  12. data/README.md +223 -223
  13. data/Rakefile +0 -0
  14. data/lib/onebox.rb +0 -0
  15. data/lib/onebox/engine.rb +188 -188
  16. data/lib/onebox/engine/amazon_onebox.rb +167 -167
  17. data/lib/onebox/engine/asciinema_onebox.rb +0 -0
  18. data/lib/onebox/engine/audio_onebox.rb +0 -0
  19. data/lib/onebox/engine/audioboom_onebox.rb +24 -24
  20. data/lib/onebox/engine/bandcamp_onebox.rb +32 -32
  21. data/lib/onebox/engine/cloudapp_onebox.rb +51 -51
  22. data/lib/onebox/engine/coub_onebox.rb +21 -21
  23. data/lib/onebox/engine/douban_onebox.rb +0 -0
  24. data/lib/onebox/engine/five_hundred_px_onebox.rb +17 -17
  25. data/lib/onebox/engine/flickr_onebox.rb +0 -0
  26. data/lib/onebox/engine/flickr_shortened_onebox.rb +0 -0
  27. data/lib/onebox/engine/gfycat_onebox.rb +0 -0
  28. data/lib/onebox/engine/giphy_onebox.rb +22 -22
  29. data/lib/onebox/engine/github_blob_onebox.rb +0 -0
  30. data/lib/onebox/engine/github_commit_onebox.rb +0 -0
  31. data/lib/onebox/engine/github_gist_onebox.rb +0 -0
  32. data/lib/onebox/engine/github_issue_onebox.rb +0 -0
  33. data/lib/onebox/engine/github_pullrequest_onebox.rb +0 -0
  34. data/lib/onebox/engine/gitlab_blob_onebox.rb +0 -0
  35. data/lib/onebox/engine/google_calendar_onebox.rb +0 -0
  36. data/lib/onebox/engine/google_docs_onebox.rb +0 -0
  37. data/lib/onebox/engine/google_maps_onebox.rb +0 -0
  38. data/lib/onebox/engine/google_photos_onebox.rb +57 -57
  39. data/lib/onebox/engine/google_play_app_onebox.rb +0 -0
  40. data/lib/onebox/engine/html.rb +0 -0
  41. data/lib/onebox/engine/image_onebox.rb +0 -0
  42. data/lib/onebox/engine/imgur_onebox.rb +65 -65
  43. data/lib/onebox/engine/instagram_onebox.rb +32 -32
  44. data/lib/onebox/engine/json.rb +0 -0
  45. data/lib/onebox/engine/kaltura_onebox.rb +31 -31
  46. data/lib/onebox/engine/mixcloud_onebox.rb +20 -20
  47. data/lib/onebox/engine/opengraph_image.rb +12 -12
  48. data/lib/onebox/engine/pastebin_onebox.rb +0 -0
  49. data/lib/onebox/engine/pdf_onebox.rb +0 -0
  50. data/lib/onebox/engine/pubmed_onebox.rb +0 -0
  51. data/lib/onebox/engine/replit_onebox.rb +24 -24
  52. data/lib/onebox/engine/sketchfab_onebox.rb +31 -31
  53. data/lib/onebox/engine/slides_onebox.rb +0 -0
  54. data/lib/onebox/engine/soundcloud_onebox.rb +31 -31
  55. data/lib/onebox/engine/stack_exchange_onebox.rb +0 -0
  56. data/lib/onebox/engine/standard_embed.rb +145 -145
  57. data/lib/onebox/engine/steam_store_onebox.rb +37 -37
  58. data/lib/onebox/engine/trello_onebox.rb +0 -0
  59. data/lib/onebox/engine/twitch_clips_onebox.rb +0 -0
  60. data/lib/onebox/engine/twitch_stream_onebox.rb +0 -0
  61. data/lib/onebox/engine/twitch_video_onebox.rb +0 -0
  62. data/lib/onebox/engine/twitter_status_onebox.rb +0 -0
  63. data/lib/onebox/engine/typeform_onebox.rb +41 -41
  64. data/lib/onebox/engine/video_onebox.rb +0 -0
  65. data/lib/onebox/engine/vimeo_onebox.rb +20 -20
  66. data/lib/onebox/engine/wechat_mp_onebox.rb +0 -0
  67. data/lib/onebox/engine/whitelisted_generic_onebox.rb +366 -366
  68. data/lib/onebox/engine/wikimedia_onebox.rb +0 -0
  69. data/lib/onebox/engine/wikipedia_onebox.rb +0 -0
  70. data/lib/onebox/engine/wistia_onebox.rb +27 -27
  71. data/lib/onebox/engine/xkcd_onebox.rb +0 -0
  72. data/lib/onebox/engine/youku_onebox.rb +0 -0
  73. data/lib/onebox/engine/youtube_onebox.rb +163 -163
  74. data/lib/onebox/file_type_finder.rb +0 -0
  75. data/lib/onebox/helpers.rb +188 -188
  76. data/lib/onebox/layout.rb +0 -0
  77. data/lib/onebox/layout_support.rb +0 -0
  78. data/lib/onebox/matcher.rb +0 -0
  79. data/lib/onebox/mixins/git_blob_onebox.rb +0 -0
  80. data/lib/onebox/mixins/twitch_onebox.rb +0 -0
  81. data/lib/onebox/oembed.rb +15 -12
  82. data/lib/onebox/open_graph.rb +90 -88
  83. data/lib/onebox/preview.rb +0 -0
  84. data/lib/onebox/sanitize_config.rb +0 -0
  85. data/lib/onebox/status_check.rb +0 -0
  86. data/lib/onebox/template_support.rb +0 -0
  87. data/lib/onebox/version.rb +5 -5
  88. data/lib/onebox/view.rb +0 -0
  89. data/lib/onebox/web.rb +0 -0
  90. data/lib/onebox/web_helpers.rb +0 -0
  91. data/onebox.gemspec +0 -0
  92. data/templates/_layout.mustache +0 -0
  93. data/templates/amazon.mustache +0 -0
  94. data/templates/douban.mustache +0 -0
  95. data/templates/githubblob.mustache +0 -0
  96. data/templates/githubcommit.mustache +0 -0
  97. data/templates/githubgist.mustache +0 -0
  98. data/templates/githubissue.mustache +0 -0
  99. data/templates/githubpullrequest.mustache +0 -0
  100. data/templates/gitlabblob.mustache +0 -0
  101. data/templates/googledocs.mustache +0 -0
  102. data/templates/googleplayapp.mustache +0 -0
  103. data/templates/instagram.mustache +0 -0
  104. data/templates/pastebin.mustache +0 -0
  105. data/templates/pdf.mustache +0 -0
  106. data/templates/pubmed.mustache +0 -0
  107. data/templates/stackexchange.mustache +0 -0
  108. data/templates/twitterstatus.mustache +0 -0
  109. data/templates/wechatmp.mustache +0 -0
  110. data/templates/whitelistedgeneric.mustache +0 -0
  111. data/templates/wikimedia.mustache +0 -0
  112. data/templates/wikipedia.mustache +0 -0
  113. data/templates/xkcd.mustache +0 -0
  114. metadata +4 -3
data/lib/onebox/layout.rb CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
data/lib/onebox/oembed.rb CHANGED
@@ -1,12 +1,15 @@
1
- module Onebox
2
- class Oembed < OpenGraph
3
-
4
- def initialize(response)
5
- @data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
6
-
7
- # never use oembed from WordPress 4.4 (it's broken)
8
- data.delete(:html) if data[:html] && data[:html]["wp-embedded-content"]
9
- end
10
-
11
- end
12
- end
1
+ module Onebox
2
+ class Oembed < OpenGraph
3
+
4
+ def initialize(response)
5
+ @data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
6
+
7
+ # never use oembed from WordPress 4.4 (it's broken)
8
+ data.delete(:html) if data[:html] && data[:html]["wp-embedded-content"]
9
+ end
10
+
11
+ def html
12
+ get(:html, nil, false)
13
+ end
14
+ end
15
+ end
@@ -1,88 +1,90 @@
1
- module Onebox
2
- class OpenGraph
3
-
4
- attr_reader :data
5
-
6
- def initialize(doc)
7
- @data = extract(doc)
8
- end
9
-
10
- def title
11
- get(:title, 80)
12
- end
13
-
14
- def title_attr
15
- !title.nil? ? "title='#{title}'" : ""
16
- end
17
-
18
- def get_secure_image
19
- secure_link = URI(get(:image))
20
- secure_link.scheme = 'https'
21
- secure_link.to_s
22
- end
23
-
24
- def method_missing(attr, *args, &block)
25
- value = get(attr, *args)
26
-
27
- return nil if Onebox::Helpers::blank?(value)
28
-
29
- method_name = attr.to_s
30
- if method_name.end_with?(*integer_suffixes)
31
- value.to_i
32
- elsif method_name.end_with?(*url_suffixes)
33
- ::Onebox::Helpers.normalize_url_for_output(value)
34
- else
35
- value
36
- end
37
- end
38
-
39
- def get(attr, length = nil)
40
- return nil if Onebox::Helpers::blank?(data)
41
-
42
- value = data[attr]
43
-
44
- return nil if Onebox::Helpers::blank?(value)
45
-
46
- value = Sanitize.fragment(html_entities.decode(value)).strip
47
- value = Onebox::Helpers.truncate(value, length) unless length.nil?
48
-
49
- value
50
- end
51
-
52
- private
53
-
54
- def integer_suffixes
55
- ['width', 'height']
56
- end
57
-
58
- def url_suffixes
59
- ['url', 'image', 'video']
60
- end
61
-
62
- def html_entities
63
- @html_entities ||= HTMLEntities.new
64
- end
65
-
66
- def extract(doc)
67
- return {} if Onebox::Helpers::blank?(doc)
68
-
69
- data = {}
70
-
71
- doc.css('meta').each do |m|
72
- if (m["property"] && m["property"][/^(?:og|article|product):(.+)$/i]) || (m["name"] && m["name"][/^(?:og|article|product):(.+)$/i])
73
- value = (m["content"] || m["value"]).to_s
74
- data[$1.tr('-:', '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
75
- end
76
- end
77
-
78
- # Attempt to retrieve the title from the meta tag
79
- title_element = doc.at_css('title')
80
- if title_element && title_element.text
81
- data[:title] ||= title_element.text unless Onebox::Helpers.blank?(title_element.text)
82
- end
83
-
84
- data
85
- end
86
-
87
- end
88
- end
1
+ module Onebox
2
+ class OpenGraph
3
+
4
+ attr_reader :data
5
+
6
+ def initialize(doc)
7
+ @data = extract(doc)
8
+ end
9
+
10
+ def title
11
+ get(:title, 80)
12
+ end
13
+
14
+ def title_attr
15
+ !title.nil? ? "title='#{title}'" : ""
16
+ end
17
+
18
+ def get_secure_image
19
+ secure_link = URI(get(:image))
20
+ secure_link.scheme = 'https'
21
+ secure_link.to_s
22
+ end
23
+
24
+ def method_missing(attr, *args, &block)
25
+ value = get(attr, *args)
26
+
27
+ return nil if Onebox::Helpers::blank?(value)
28
+
29
+ method_name = attr.to_s
30
+ if method_name.end_with?(*integer_suffixes)
31
+ value.to_i
32
+ elsif method_name.end_with?(*url_suffixes)
33
+ ::Onebox::Helpers.normalize_url_for_output(value)
34
+ else
35
+ value
36
+ end
37
+ end
38
+
39
+ def get(attr, length = nil, sanitize = true)
40
+ return nil if Onebox::Helpers::blank?(data)
41
+
42
+ value = data[attr]
43
+
44
+ return nil if Onebox::Helpers::blank?(value)
45
+
46
+ value = html_entities.decode(value)
47
+ value = Sanitize.fragment(value) if sanitize
48
+ value.strip!
49
+ value = Onebox::Helpers.truncate(value, length) unless length.nil?
50
+
51
+ value
52
+ end
53
+
54
+ private
55
+
56
+ def integer_suffixes
57
+ ['width', 'height']
58
+ end
59
+
60
+ def url_suffixes
61
+ ['url', 'image', 'video']
62
+ end
63
+
64
+ def html_entities
65
+ @html_entities ||= HTMLEntities.new
66
+ end
67
+
68
+ def extract(doc)
69
+ return {} if Onebox::Helpers::blank?(doc)
70
+
71
+ data = {}
72
+
73
+ doc.css('meta').each do |m|
74
+ if (m["property"] && m["property"][/^(?:og|article|product):(.+)$/i]) || (m["name"] && m["name"][/^(?:og|article|product):(.+)$/i])
75
+ value = (m["content"] || m["value"]).to_s
76
+ data[$1.tr('-:', '_').to_sym] ||= value unless Onebox::Helpers::blank?(value)
77
+ end
78
+ end
79
+
80
+ # Attempt to retrieve the title from the meta tag
81
+ title_element = doc.at_css('title')
82
+ if title_element && title_element.text
83
+ data[:title] ||= title_element.text unless Onebox::Helpers.blank?(title_element.text)
84
+ end
85
+
86
+ data
87
+ end
88
+
89
+ end
90
+ end
File without changes
File without changes
File without changes
File without changes
@@ -1,5 +1,5 @@
1
- # frozen_string_literal: true
2
-
3
- module Onebox
4
- VERSION = "1.8.80"
5
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Onebox
4
+ VERSION = "1.8.81"
5
+ end
data/lib/onebox/view.rb CHANGED
File without changes
data/lib/onebox/web.rb CHANGED
File without changes
File without changes
data/onebox.gemspec CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
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.80
4
+ version: 1.8.81
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-03-05 00:00:00.000000000 Z
13
+ date: 2019-03-06 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -418,7 +418,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
418
418
  - !ruby/object:Gem::Version
419
419
  version: '0'
420
420
  requirements: []
421
- rubygems_version: 3.0.2
421
+ rubyforge_project:
422
+ rubygems_version: 2.7.8
422
423
  signing_key:
423
424
  specification_version: 4
424
425
  summary: A gem for generating embeddable HTML previews from URLs.