onebox 1.6.8 → 1.6.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a12d23bfa68fd516d78c674b2ad5918197b562aa
4
- data.tar.gz: d7da2b8da8e5155e30ae469470e8054603314b5d
3
+ metadata.gz: 36f15273d10858172cd6d0b0668c25395658e891
4
+ data.tar.gz: 7d0c3595d380b65c8d9295af3bf7e7776a880130
5
5
  SHA512:
6
- metadata.gz: f6600bba536e0e346696272c3cabfed3f946a0a7596e8400b25c76d727a31efea9209bc88fb8b08d4933467085d7a267f3b6e963afc91a48dbe77a2f8f938f39
7
- data.tar.gz: 5eeb57535bdd8d624b417458890d4f5a5efa8b74d624b0519d001bfff85f9038d81d32920bc7a0f4782810697b0887ce4db344ffaf90b6406aa77efa3ff93218
6
+ metadata.gz: cfba0462966d9fe253e909068eb9f0d44544241e9e5cfc854f88559aa05d798b3dbe0e6780df4a2a77809de1532c343579edeb237e1dfa23f335fa11748016a5
7
+ data.tar.gz: be7b95948b00676be78a720158ed51fe446ec845c4f7a4e04e4959299d2050f2a013c2843ed76630f96f1ecf4ff4e8619c562b23c30496ea4fc79cc70e1b27c5
data/lib/onebox/engine.rb CHANGED
@@ -166,3 +166,5 @@ require_relative "engine/vimeo_onebox"
166
166
  require_relative "engine/steam_store_onebox"
167
167
  require_relative "engine/sketchfab_onebox"
168
168
  require_relative "engine/audioboom_onebox"
169
+ require_relative "engine/replit_onebox"
170
+ require_relative "engine/asciinema_onebox"
@@ -0,0 +1,26 @@
1
+ module Onebox
2
+ module Engine
3
+ class AsciinemaOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ always_https
8
+
9
+ matches_regexp(/^https?:\/\/asciinema\.org\/a\/[\p{Alnum}_\-]+$/)
10
+
11
+ def to_html
12
+ "<script type='text/javascript' src='https://asciinema.org/a/#{match[:asciinema_id]}.js' id='asciicast-#{match[:asciinema_id]}' async></script>"
13
+ end
14
+
15
+ def placeholder_html
16
+ "<img src='https://asciinema.org/a/#{match[:asciinema_id]}.png'>"
17
+ end
18
+
19
+ private
20
+
21
+ def match
22
+ @match ||= @url.match(/asciinema\.org\/a\/(?<asciinema_id>[\p{Alnum}_\-]+)$/)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,27 @@
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
+ # we want the image to have the same dimensions as the embedded html
14
+
15
+ <<-HTML
16
+ <img src="#{oembed[:thumbnail_url]}" style="max-width: #{oembed[:width]}px; max-height: #{oembed[:height]}px;" #{Helpers.title_attr(oembed)}>
17
+ HTML
18
+ end
19
+
20
+ def to_html
21
+ oembed = get_oembed
22
+ oembed[:html]
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -205,6 +205,10 @@ module Onebox
205
205
  if !Onebox::Helpers.blank?(d[:description])
206
206
  d[:description] = html_entities.decode(Onebox::Helpers.truncate(d[:description].strip, 250))
207
207
  end
208
+ if !Onebox::Helpers.blank?(d[:domain])
209
+ d[:domain] = "http://#{d[:domain]}" unless d[:domain] =~ /^https?:\/\//
210
+ d[:domain] = URI(d[:domain]).host.to_s.sub(/^www\./, '')
211
+ end
208
212
  d
209
213
  end
210
214
  end
@@ -275,6 +279,7 @@ module Onebox
275
279
  end
276
280
 
277
281
  def video_html
282
+ video_url = !Onebox::Helpers.blank?(data[:video_secure_url]) ? data[:video_secure_url] : data[:video]
278
283
  if data[:video_type] == "video/mp4"
279
284
  <<-HTML
280
285
  <video title='#{data[:title]}'
@@ -282,12 +287,12 @@ module Onebox
282
287
  height='#{data[:video_height]}'
283
288
  style='max-width:100%'
284
289
  controls=''>
285
- <source src='#{data[:video]}'>
290
+ <source src='#{video_url}'>
286
291
  </video>
287
292
  HTML
288
293
  else
289
294
  <<-HTML
290
- <iframe src='#{data[:video]}'
295
+ <iframe src='#{video_url}'
291
296
  title='#{data[:title]}'
292
297
  width='#{data[:video_width]}'
293
298
  height='#{data[:video_height]}'
data/lib/onebox/layout.rb CHANGED
@@ -46,7 +46,7 @@ module Onebox
46
46
  end
47
47
 
48
48
  def domain
49
- record[:domain] || URI(link || '').host
49
+ record[:domain] || URI(link || '').host.to_s.sub(/^www\./, '')
50
50
  end
51
51
 
52
52
  def metadata_1_label
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.6.8"
2
+ VERSION = "1.6.9"
3
3
  end
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.6.8
4
+ version: 1.6.9
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: 2016-12-21 00:00:00.000000000 Z
13
+ date: 2017-01-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -315,6 +315,7 @@ files:
315
315
  - lib/onebox.rb
316
316
  - lib/onebox/engine.rb
317
317
  - lib/onebox/engine/amazon_onebox.rb
318
+ - lib/onebox/engine/asciinema_onebox.rb
318
319
  - lib/onebox/engine/audio_onebox.rb
319
320
  - lib/onebox/engine/audioboom_onebox.rb
320
321
  - lib/onebox/engine/douban_onebox.rb
@@ -335,6 +336,7 @@ files:
335
336
  - lib/onebox/engine/json.rb
336
337
  - lib/onebox/engine/pastebin_onebox.rb
337
338
  - lib/onebox/engine/pubmed_onebox.rb
339
+ - lib/onebox/engine/replit_onebox.rb
338
340
  - lib/onebox/engine/sketchfab_onebox.rb
339
341
  - lib/onebox/engine/slides_onebox.rb
340
342
  - lib/onebox/engine/soundcloud_onebox.rb
@@ -464,7 +466,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
464
466
  version: '0'
465
467
  requirements: []
466
468
  rubyforge_project:
467
- rubygems_version: 2.5.1
469
+ rubygems_version: 2.6.8
468
470
  signing_key:
469
471
  specification_version: 4
470
472
  summary: A gem for turning URLs into previews.