onebox 1.8.81 → 1.8.82

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 -154
  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 +1 -1
  80. data/lib/onebox/mixins/twitch_onebox.rb +0 -0
  81. data/lib/onebox/oembed.rb +15 -15
  82. data/lib/onebox/open_graph.rb +90 -90
  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 +1 -1
  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 +3 -4
File without changes
File without changes
@@ -1,24 +1,24 @@
1
- module Onebox
2
- module Engine
3
- class AudioboomOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/audioboom\.com\/posts\/\d+/)
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 AudioboomOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/audioboom\.com\/posts\/\d+/)
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,32 +1,32 @@
1
- module Onebox
2
- module Engine
3
- class BandCampOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/.*\.bandcamp\.com\/(album|track)\//)
8
- always_https
9
-
10
- def placeholder_html
11
- og = get_opengraph
12
- "<img src='#{og.image}' height='#{og.video_height}' #{og.title_attr}>"
13
- end
14
-
15
- def to_html
16
- og = get_opengraph
17
- escaped_src = og.video_secure_url || og.video
18
-
19
- <<-HTML
20
- <iframe src="#{escaped_src}"
21
- width="#{og.video_width}"
22
- height="#{og.video_height}"
23
- scrolling="no"
24
- frameborder="0"
25
- allowfullscreen>
26
- </iframe>
27
- HTML
28
- end
29
-
30
- end
31
- end
32
- end
1
+ module Onebox
2
+ module Engine
3
+ class BandCampOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/.*\.bandcamp\.com\/(album|track)\//)
8
+ always_https
9
+
10
+ def placeholder_html
11
+ og = get_opengraph
12
+ "<img src='#{og.image}' height='#{og.video_height}' #{og.title_attr}>"
13
+ end
14
+
15
+ def to_html
16
+ og = get_opengraph
17
+ escaped_src = og.video_secure_url || og.video
18
+
19
+ <<-HTML
20
+ <iframe src="#{escaped_src}"
21
+ width="#{og.video_width}"
22
+ height="#{og.video_height}"
23
+ scrolling="no"
24
+ frameborder="0"
25
+ allowfullscreen>
26
+ </iframe>
27
+ HTML
28
+ end
29
+
30
+ end
31
+ end
32
+ end
@@ -1,51 +1,51 @@
1
- module Onebox
2
- module Engine
3
- class CloudAppOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/cl\.ly/)
8
- always_https
9
-
10
- def to_html
11
- og = get_opengraph
12
-
13
- if !og.image.nil?
14
- return image_html(og)
15
- elsif og.title.to_s[/\.(mp4|ogv|webm)$/]
16
- return video_html(og)
17
- else
18
- return link_html(og)
19
- end
20
- end
21
-
22
- private
23
-
24
- def link_html(og)
25
- <<-HTML
26
- <a href='#{og.url}' target='_blank'>
27
- #{og.title}
28
- </a>
29
- HTML
30
- end
31
-
32
- def video_html(og)
33
- direct_src = ::Onebox::Helpers.normalize_url_for_output("#{og.get(:url)}/#{og.title}")
34
-
35
- <<-HTML
36
- <video width='480' height='360' #{og.title_attr} controls loop>
37
- <source src='#{direct_src}' type='video/mp4'>
38
- </video>
39
- HTML
40
- end
41
-
42
- def image_html(og)
43
- <<-HTML
44
- <a href='#{og.url}' target='_blank' class='onebox'>
45
- <img src='#{og.image}' #{og.title_attr} alt='CloudApp' width='480'>
46
- </a>
47
- HTML
48
- end
49
- end
50
- end
51
- end
1
+ module Onebox
2
+ module Engine
3
+ class CloudAppOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/cl\.ly/)
8
+ always_https
9
+
10
+ def to_html
11
+ og = get_opengraph
12
+
13
+ if !og.image.nil?
14
+ return image_html(og)
15
+ elsif og.title.to_s[/\.(mp4|ogv|webm)$/]
16
+ return video_html(og)
17
+ else
18
+ return link_html(og)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ def link_html(og)
25
+ <<-HTML
26
+ <a href='#{og.url}' target='_blank'>
27
+ #{og.title}
28
+ </a>
29
+ HTML
30
+ end
31
+
32
+ def video_html(og)
33
+ direct_src = ::Onebox::Helpers.normalize_url_for_output("#{og.get(:url)}/#{og.title}")
34
+
35
+ <<-HTML
36
+ <video width='480' height='360' #{og.title_attr} controls loop>
37
+ <source src='#{direct_src}' type='video/mp4'>
38
+ </video>
39
+ HTML
40
+ end
41
+
42
+ def image_html(og)
43
+ <<-HTML
44
+ <a href='#{og.url}' target='_blank' class='onebox'>
45
+ <img src='#{og.image}' #{og.title_attr} alt='CloudApp' width='480'>
46
+ </a>
47
+ HTML
48
+ end
49
+ end
50
+ end
51
+ end
@@ -1,21 +1,21 @@
1
- module Onebox
2
- module Engine
3
- class CoubOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/coub\.com\/view\//)
8
- always_https
9
-
10
- def placeholder_html
11
- oembed = get_oembed
12
- "<img src='#{oembed.thumbnail_url}' height='#{oembed.thumbnail_height}' width='#{oembed.thumbnail_width}' #{oembed.title_attr}>"
13
- end
14
-
15
- def to_html
16
- get_oembed.html
17
- end
18
-
19
- end
20
- end
21
- end
1
+ module Onebox
2
+ module Engine
3
+ class CoubOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/coub\.com\/view\//)
8
+ always_https
9
+
10
+ def placeholder_html
11
+ oembed = get_oembed
12
+ "<img src='#{oembed.thumbnail_url}' height='#{oembed.thumbnail_height}' width='#{oembed.thumbnail_width}' #{oembed.title_attr}>"
13
+ end
14
+
15
+ def to_html
16
+ get_oembed.html
17
+ end
18
+
19
+ end
20
+ end
21
+ end
File without changes
@@ -1,17 +1,17 @@
1
- module Onebox
2
- module Engine
3
- class FiveHundredPxOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/500px\.com\/photo\/\d+\//)
8
- always_https
9
-
10
- def to_html
11
- og = get_opengraph
12
- "<img src='#{og.image}' width='#{og.image_width}' height='#{og.image_height}' class='onebox' #{og.title_attr}>"
13
- end
14
-
15
- end
16
- end
17
- end
1
+ module Onebox
2
+ module Engine
3
+ class FiveHundredPxOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/500px\.com\/photo\/\d+\//)
8
+ always_https
9
+
10
+ def to_html
11
+ og = get_opengraph
12
+ "<img src='#{og.image}' width='#{og.image_width}' height='#{og.image_height}' class='onebox' #{og.title_attr}>"
13
+ end
14
+
15
+ end
16
+ end
17
+ end
File without changes
File without changes
File without changes
@@ -1,22 +1,22 @@
1
- module Onebox
2
- module Engine
3
- class GiphyOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/(giphy\.com\/gifs|gph\.is)\//)
8
- always_https
9
-
10
- def to_html
11
- oembed = get_oembed
12
-
13
- <<-HTML
14
- <a href="#{oembed.url}" target="_blank" class="onebox">
15
- <img src="#{oembed.url}" width="#{oembed.width}" height="#{oembed.height}" #{oembed.title_attr}>
16
- </a>
17
- HTML
18
- end
19
-
20
- end
21
- end
22
- end
1
+ module Onebox
2
+ module Engine
3
+ class GiphyOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/(giphy\.com\/gifs|gph\.is)\//)
8
+ always_https
9
+
10
+ def to_html
11
+ oembed = get_oembed
12
+
13
+ <<-HTML
14
+ <a href="#{oembed.url}" target="_blank" class="onebox">
15
+ <img src="#{oembed.url}" width="#{oembed.width}" height="#{oembed.height}" #{oembed.title_attr}>
16
+ </a>
17
+ HTML
18
+ end
19
+
20
+ end
21
+ end
22
+ end
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
@@ -1,57 +1,57 @@
1
- module Onebox
2
- module Engine
3
- class GooglePhotosOnebox
4
- include Engine
5
- include StandardEmbed
6
-
7
- matches_regexp(/^https?:\/\/(photos)\.(app\.goo\.gl|google\.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 !og.type.nil? && og.type == "google_photos:photo_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} poster="#{og.get_secure_image}" controls loop>
23
- <source src='#{og.video_secure_url}' type='video/mp4'>
24
- </video>
25
- HTML
26
- end
27
-
28
- def album_html(og)
29
- escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
30
- album_title = og.description.nil? ? og.title : "[#{og.description}] #{og.title}"
31
-
32
- <<-HTML
33
- <div class='onebox google-photos-album'>
34
- <a href='#{escaped_url}' target='_blank'>
35
- <span class='outer-box' style='width:#{og.image_width}px'>
36
- <span class='inner-box'>
37
- <span class='album-title'>#{Onebox::Helpers.truncate(album_title, 80)}</span>
38
- </span>
39
- </span>
40
- <img src='#{og.get_secure_image}' #{og.title_attr} height='#{og.image_height}' width='#{og.image_width}'>
41
- </a>
42
- </div>
43
- HTML
44
- end
45
-
46
- def image_html(og)
47
- escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
48
-
49
- <<-HTML
50
- <a href='#{escaped_url}' target='_blank' class="onebox">
51
- <img src='#{og.get_secure_image}' #{og.title_attr} alt='Google Photos' height='#{og.image_height}' width='#{og.image_width}'>
52
- </a>
53
- HTML
54
- end
55
- end
56
- end
57
- end
1
+ module Onebox
2
+ module Engine
3
+ class GooglePhotosOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^https?:\/\/(photos)\.(app\.goo\.gl|google\.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 !og.type.nil? && og.type == "google_photos:photo_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} poster="#{og.get_secure_image}" controls loop>
23
+ <source src='#{og.video_secure_url}' type='video/mp4'>
24
+ </video>
25
+ HTML
26
+ end
27
+
28
+ def album_html(og)
29
+ escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
30
+ album_title = og.description.nil? ? og.title : "[#{og.description}] #{og.title}"
31
+
32
+ <<-HTML
33
+ <div class='onebox google-photos-album'>
34
+ <a href='#{escaped_url}' target='_blank'>
35
+ <span class='outer-box' style='width:#{og.image_width}px'>
36
+ <span class='inner-box'>
37
+ <span class='album-title'>#{Onebox::Helpers.truncate(album_title, 80)}</span>
38
+ </span>
39
+ </span>
40
+ <img src='#{og.get_secure_image}' #{og.title_attr} height='#{og.image_height}' width='#{og.image_width}'>
41
+ </a>
42
+ </div>
43
+ HTML
44
+ end
45
+
46
+ def image_html(og)
47
+ escaped_url = ::Onebox::Helpers.normalize_url_for_output(url)
48
+
49
+ <<-HTML
50
+ <a href='#{escaped_url}' target='_blank' class="onebox">
51
+ <img src='#{og.get_secure_image}' #{og.title_attr} alt='Google Photos' height='#{og.image_height}' width='#{og.image_width}'>
52
+ </a>
53
+ HTML
54
+ end
55
+ end
56
+ end
57
+ end