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
File without changes
File without changes
File without changes
@@ -1,65 +1,65 @@
1
- module Onebox
2
- module Engine
3
- class ImgurOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/(www\.)?imgur\.com/)
8
- always_https
9
-
10
- def to_html
11
- og = get_opengraph
12
- return video_html(og) if !og.video_secure_url.nil?
13
- return album_html(og) if is_album?
14
- return image_html(og) if !og.image.nil?
15
- nil
16
- end
17
-
18
- private
19
-
20
- def video_html(og)
21
- <<-HTML
22
- <video width='#{og.video_width}' height='#{og.video_height}' #{og.title_attr} controls loop>
23
- <source src='#{og.video_secure_url}' type='video/mp4'>
24
- <source src='#{og.video_secure_url.gsub('mp4', 'webm')}' type='video/webm'>
25
- </video>
26
- HTML
27
- end
28
-
29
- def album_html(og)
30
- escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
31
- album_title = "[Album] #{og.title}"
32
-
33
- <<-HTML
34
- <div class='onebox imgur-album'>
35
- <a href='#{escaped_url}' target='_blank'>
36
- <span class='outer-box' style='width:#{og.image_width}px'>
37
- <span class='inner-box'>
38
- <span class='album-title'>#{album_title}</span>
39
- </span>
40
- </span>
41
- <img src='#{og.get_secure_image}' #{og.title_attr} height='#{og.image_height}' width='#{og.image_width}'>
42
- </a>
43
- </div>
44
- HTML
45
- end
46
-
47
- def is_album?
48
- response = Onebox::Helpers.fetch_response("https://api.imgur.com/oembed.json?url=#{url}") rescue "{}"
49
- oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
50
- imgur_data_id = Nokogiri::HTML(oembed_data[:html]).xpath("//blockquote").attr("data-id")
51
- imgur_data_id.to_s[/a\//]
52
- end
53
-
54
- def image_html(og)
55
- escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
56
-
57
- <<-HTML
58
- <a href='#{escaped_url}' target='_blank' class="onebox">
59
- <img src='#{og.get_secure_image}' #{og.title_attr} alt='Imgur' height='#{og.image_height}' width='#{og.image_width}'>
60
- </a>
61
- HTML
62
- end
63
- end
64
- end
65
- end
1
+ module Onebox
2
+ module Engine
3
+ class ImgurOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/(www\.)?imgur\.com/)
8
+ always_https
9
+
10
+ def to_html
11
+ og = get_opengraph
12
+ return video_html(og) if !og.video_secure_url.nil?
13
+ return album_html(og) if is_album?
14
+ return image_html(og) if !og.image.nil?
15
+ nil
16
+ end
17
+
18
+ private
19
+
20
+ def video_html(og)
21
+ <<-HTML
22
+ <video width='#{og.video_width}' height='#{og.video_height}' #{og.title_attr} controls loop>
23
+ <source src='#{og.video_secure_url}' type='video/mp4'>
24
+ <source src='#{og.video_secure_url.gsub('mp4', 'webm')}' type='video/webm'>
25
+ </video>
26
+ HTML
27
+ end
28
+
29
+ def album_html(og)
30
+ escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
31
+ album_title = "[Album] #{og.title}"
32
+
33
+ <<-HTML
34
+ <div class='onebox imgur-album'>
35
+ <a href='#{escaped_url}' target='_blank'>
36
+ <span class='outer-box' style='width:#{og.image_width}px'>
37
+ <span class='inner-box'>
38
+ <span class='album-title'>#{album_title}</span>
39
+ </span>
40
+ </span>
41
+ <img src='#{og.get_secure_image}' #{og.title_attr} height='#{og.image_height}' width='#{og.image_width}'>
42
+ </a>
43
+ </div>
44
+ HTML
45
+ end
46
+
47
+ def is_album?
48
+ response = Onebox::Helpers.fetch_response("https://api.imgur.com/oembed.json?url=#{url}") rescue "{}"
49
+ oembed_data = Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
50
+ imgur_data_id = Nokogiri::HTML(oembed_data[:html]).xpath("//blockquote").attr("data-id")
51
+ imgur_data_id.to_s[/a\//]
52
+ end
53
+
54
+ def image_html(og)
55
+ escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
56
+
57
+ <<-HTML
58
+ <a href='#{escaped_url}' target='_blank' class="onebox">
59
+ <img src='#{og.get_secure_image}' #{og.title_attr} alt='Imgur' height='#{og.image_height}' width='#{og.image_width}'>
60
+ </a>
61
+ HTML
62
+ end
63
+ end
64
+ end
65
+ end
@@ -1,32 +1,32 @@
1
- require 'htmlentities'
2
-
3
- module Onebox
4
- module Engine
5
- class InstagramOnebox
6
- include Engine
7
- include StandardEmbed
8
- include LayoutSupport
9
-
10
- matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/p\//)
11
- always_https
12
-
13
- def data
14
- og = get_opengraph
15
- title = og.title.split(":")[0].strip.gsub(" on Instagram", "")
16
-
17
- json_data = html_doc.xpath('//script[contains(text(),"window._sharedData")]').text.to_s
18
- title = "[Album] #{title}" if json_data =~ /"edge_sidecar_to_children"/
19
-
20
- result = { link: og.url,
21
- title: Onebox::Helpers.truncate(title, 80),
22
- description: og.description(250)
23
- }
24
-
25
- result[:image] = og.image if !og.image.nil?
26
- result[:video_link] = og.url if !og.video_secure_url.nil?
27
-
28
- result
29
- end
30
- end
31
- end
32
- end
1
+ require 'htmlentities'
2
+
3
+ module Onebox
4
+ module Engine
5
+ class InstagramOnebox
6
+ include Engine
7
+ include StandardEmbed
8
+ include LayoutSupport
9
+
10
+ matches_regexp(/^https?:\/\/(?:www\.)?(?:instagram\.com|instagr\.am)\/p\//)
11
+ always_https
12
+
13
+ def data
14
+ og = get_opengraph
15
+ title = og.title.split(":")[0].strip.gsub(" on Instagram", "")
16
+
17
+ json_data = html_doc.xpath('//script[contains(text(),"window._sharedData")]').text.to_s
18
+ title = "[Album] #{title}" if json_data =~ /"edge_sidecar_to_children"/
19
+
20
+ result = { link: og.url,
21
+ title: Onebox::Helpers.truncate(title, 80),
22
+ description: og.description(250)
23
+ }
24
+
25
+ result[:image] = og.image if !og.image.nil?
26
+ result[:video_link] = og.url if !og.video_secure_url.nil?
27
+
28
+ result
29
+ end
30
+ end
31
+ end
32
+ end
File without changes
@@ -1,31 +1,31 @@
1
- module Onebox
2
- module Engine
3
- class KalturaOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- always_https
8
- matches_regexp(/^https?:\/\/[a-z0-9]+\.kaltura\.com\/id\/[a-zA-Z0-9]+/)
9
-
10
- def preview_html
11
- og = get_opengraph
12
-
13
- <<~HTML
14
- <img src="#{og.image_secure_url}" width="#{og.video_width}" height="#{og.video_height}" >
15
- HTML
16
- end
17
-
18
- def to_html
19
- og = get_opengraph
20
-
21
- <<~HTML
22
- <iframe src="#{og.video_secure_url}"
23
- width="#{og.video_width}" height="#{og.video_height}"
24
- frameborder='0'
25
- allowfullscreen >
26
- </iframe>
27
- HTML
28
- end
29
- end
30
- end
31
- end
1
+ module Onebox
2
+ module Engine
3
+ class KalturaOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ always_https
8
+ matches_regexp(/^https?:\/\/[a-z0-9]+\.kaltura\.com\/id\/[a-zA-Z0-9]+/)
9
+
10
+ def preview_html
11
+ og = get_opengraph
12
+
13
+ <<~HTML
14
+ <img src="#{og.image_secure_url}" width="#{og.video_width}" height="#{og.video_height}" >
15
+ HTML
16
+ end
17
+
18
+ def to_html
19
+ og = get_opengraph
20
+
21
+ <<~HTML
22
+ <iframe src="#{og.video_secure_url}"
23
+ width="#{og.video_width}" height="#{og.video_height}"
24
+ frameborder='0'
25
+ allowfullscreen >
26
+ </iframe>
27
+ HTML
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,20 +1,20 @@
1
- module Onebox
2
- module Engine
3
- class MixcloudOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/www\.mixcloud\.com\//)
8
- always_https
9
-
10
- def placeholder_html
11
- oembed = get_oembed
12
- "<img src='#{oembed.image}' height='#{oembed.height}' #{oembed.title_attr}>"
13
- end
14
-
15
- def to_html
16
- get_oembed.html
17
- end
18
- end
19
- end
20
- end
1
+ module Onebox
2
+ module Engine
3
+ class MixcloudOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/www\.mixcloud\.com\//)
8
+ always_https
9
+
10
+ def placeholder_html
11
+ oembed = get_oembed
12
+ "<img src='#{oembed.image}' height='#{oembed.height}' #{oembed.title_attr}>"
13
+ end
14
+
15
+ def to_html
16
+ get_oembed.html
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,12 +1,12 @@
1
- module Onebox
2
- module Engine
3
- module OpengraphImage
4
-
5
- def to_html
6
- og = get_opengraph
7
- "<img src='#{og.image}' width='#{og.image_width}' height='#{og.image_height}' class='onebox' #{og.title_attr}>"
8
- end
9
-
10
- end
11
- end
12
- end
1
+ module Onebox
2
+ module Engine
3
+ module OpengraphImage
4
+
5
+ def to_html
6
+ og = get_opengraph
7
+ "<img src='#{og.image}' width='#{og.image_width}' height='#{og.image_height}' class='onebox' #{og.title_attr}>"
8
+ end
9
+
10
+ end
11
+ end
12
+ end
File without changes
File without changes
File without changes
@@ -1,24 +1,24 @@
1
- module Onebox
2
- module Engine
3
- class ReplitOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/repl\.it\/.+/)
8
- always_https
9
-
10
- def placeholder_html
11
- oembed = get_oembed
12
-
13
- <<-HTML
14
- <img src="#{oembed.thumbnail_url}" style="max-width: #{oembed.width}px; max-height: #{oembed.height}px;" #{oembed.title_attr}>
15
- HTML
16
- end
17
-
18
- def to_html
19
- get_oembed.html
20
- end
21
-
22
- end
23
- end
24
- end
1
+ module Onebox
2
+ module Engine
3
+ class ReplitOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/repl\.it\/.+/)
8
+ always_https
9
+
10
+ def placeholder_html
11
+ oembed = get_oembed
12
+
13
+ <<-HTML
14
+ <img src="#{oembed.thumbnail_url}" style="max-width: #{oembed.width}px; max-height: #{oembed.height}px;" #{oembed.title_attr}>
15
+ HTML
16
+ end
17
+
18
+ def to_html
19
+ get_oembed.html
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -1,31 +1,31 @@
1
- module Onebox
2
- module Engine
3
- class SketchFabOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/sketchfab\.com\/(?:models\/|3d-models\/(?:[^\/\s]+-)?)([a-z0-9]{32})/)
8
- always_https
9
-
10
- def to_html
11
- og = get_opengraph
12
- src = og.video_url.gsub("autostart=1", "")
13
-
14
- <<-HTML
15
- <iframe src="#{src}"
16
- width="#{og.video_width}"
17
- height="#{og.video_height}"
18
- scrolling="no"
19
- frameborder="0"
20
- allowfullscreen>
21
- </iframe>
22
- HTML
23
- end
24
-
25
- def placeholder_html
26
- "<img src='#{get_opengraph.image}'>"
27
- end
28
-
29
- end
30
- end
31
- end
1
+ module Onebox
2
+ module Engine
3
+ class SketchFabOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/sketchfab\.com\/(?:models\/|3d-models\/(?:[^\/\s]+-)?)([a-z0-9]{32})/)
8
+ always_https
9
+
10
+ def to_html
11
+ og = get_opengraph
12
+ src = og.video_url.gsub("autostart=1", "")
13
+
14
+ <<-HTML
15
+ <iframe src="#{src}"
16
+ width="#{og.video_width}"
17
+ height="#{og.video_height}"
18
+ scrolling="no"
19
+ frameborder="0"
20
+ allowfullscreen>
21
+ </iframe>
22
+ HTML
23
+ end
24
+
25
+ def placeholder_html
26
+ "<img src='#{get_opengraph.image}'>"
27
+ end
28
+
29
+ end
30
+ end
31
+ end