onebox 1.5.50 → 1.5.60

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ {"month": "10", "num": 327, "link": "", "year": "2007", "news": "", "safe_title": "Exploits of a Mom", "transcript": "[[A woman is talking on the phone, holding a cup]]\nPhone: Hi, this is your son's school. We're having some computer trouble.\nMom: Oh dear\u00c3\u00a2\u00c2\u0080\u00c2\u0094did he break something?\nPhone: In a way\u00c3\u00a2\u00c2\u0080\u00c2\u0094\nPhone: Did you really name your son \"Robert'); DROP TABLE Students;--\" ?\nMom: Oh, yes. Little Bobby Tables, we call him.\nPhone: Well, we've lost this year's student records. I hope you're happy.\nMom: And I hope you've learned to sanitize your database inputs.\n{{title-text: Her daughter is named Help I'm trapped in a driver's license factory.}}", "alt": "Her daughter is named Help I'm trapped in a driver's license factory.", "img": "http:\/\/imgs.xkcd.com\/comics\/exploits_of_a_mom.png", "title": "Exploits of a Mom", "day": "10"}
@@ -11,15 +11,14 @@ describe Onebox::Engine::SlidesOnebox do
11
11
 
12
12
  describe "#placeholder_html" do
13
13
  it "returns an image as the placeholder" do
14
- expect(Onebox.preview(link)
15
- .placeholder_html).to include("//s3.amazonaws.com/media-p.slid.es/thumbnails/secure/cff7c3/decks.jpg")
14
+ expect(Onebox.preview(link).placeholder_html).to include("//s3.amazonaws.com/media-p.slid.es/thumbnails/secure/cff7c3/decks.jpg")
16
15
  end
17
16
  end
18
17
 
19
18
  describe "#to_html" do
20
19
  it "returns iframe embed" do
21
20
  expect(html).to include(URI(link).path)
22
- expect(html).to include("iframe")
21
+ expect(html).to include("iframe")
23
22
  end
24
23
  end
25
24
  end
@@ -66,9 +66,11 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
66
66
  end
67
67
 
68
68
  describe 'oembed_providers' do
69
+ let(:url) { "http://www.meetup.com/Toronto-Ember-JS-Meetup/events/219939537" }
70
+
69
71
  before do
70
- fake("http://api.meetup.com/oembed?url=http://www.meetup.com/Toronto-Ember-JS-Meetup/events/219939537",
71
- response('meetup'))
72
+ fake(url, response('meetup'))
73
+ fake("http://api.meetup.com/oembed?url=#{url}", response('meetup_oembed'))
72
74
  end
73
75
 
74
76
  it 'uses the endpoint for the url' do
@@ -0,0 +1,27 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::XkcdOnebox do
4
+ let(:link) { "https://xkcd.com/327/" }
5
+ let(:api_link) { "https://xkcd.com/327/info.0.json" }
6
+ let(:html) { described_class.new(link).to_html }
7
+
8
+ before do
9
+ fake(api_link, response("xkcd"))
10
+ end
11
+
12
+ it "has the comic's description" do
13
+ expect(html).to include("Her daughter is named Help")
14
+ end
15
+
16
+ it "has the comic's title" do
17
+ expect(html).to include("Exploits of a Mom")
18
+ end
19
+
20
+ it "has the permalink to the comic" do
21
+ expect(html).to include(link)
22
+ end
23
+
24
+ it "has the comic image" do
25
+ expect(html).to include("http://imgs.xkcd.com/comics/exploits_of_a_mom.png")
26
+ end
27
+ end
@@ -8,32 +8,25 @@ describe Onebox::Engine::YoutubeOnebox do
8
8
  end
9
9
 
10
10
  it "adds wmode=opaque" do
11
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
12
- .to_s).to match(/wmode=opaque/)
11
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo').to_s).to match(/wmode=opaque/)
13
12
  end
14
13
 
15
14
  it "rewrites URLs for videos to be HTTPS" do
16
15
  # match: plain HTTP and protocol agnostic
17
16
  regex = /(http:|["']\/\/)/
18
17
 
19
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
20
- .to_s).not_to match(regex)
21
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
22
- .placeholder_html).not_to match(regex)
23
- expect(Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ')
24
- .to_s).not_to match(regex)
18
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo').to_s).not_to match(regex)
19
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo').placeholder_html).not_to match(regex)
20
+ expect(Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ').to_s).not_to match(regex)
25
21
  end
26
22
 
27
23
  it "can onebox a channel page" do
28
- expect(Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ')
29
- .to_s).to match(/Google Chrome/)
24
+ expect(Onebox.preview('https://www.youtube.com/channel/UCL8ZULXASCc1I_oaOT0NaOQ').to_s).to match(/Google Chrome/)
30
25
  end
31
26
 
32
27
  it "can onebox a playlist" do
33
- pending('no opengraph on playlists, needs special handling')
34
-
35
- expect(Onebox.preview('https://www.youtube.com/playlist?list=PL5308B2E5749D1696')
36
- .to_s).to match(/Dear Sophie/)
28
+ expect(Onebox.preview('https://www.youtube.com/playlist?list=PL5308B2E5749D1696').to_s).to match(/iframe/)
29
+ expect(Onebox.preview('https://www.youtube.com/playlist?list=PL5308B2E5749D1696').placeholder_html).to match(/<img/)
37
30
  end
38
31
 
39
32
  it "does not make HTTP requests unless necessary" do
@@ -43,37 +36,27 @@ describe Onebox::Engine::YoutubeOnebox do
43
36
  end
44
37
 
45
38
  it "does not fail if we cannot get the video ID from the URL" do
46
- # TODO this test no longer makes sense - the video ID is successfully retrieved and no fakeweb request is made
47
- expect(Onebox.preview('http://www.youtube.com/watch?feature=player_embedded&v=21Lk4YiASMo')
48
- .to_s).to match(/embed/)
39
+ expect(Onebox.preview('http://www.youtube.com/watch?feature=player_embedded&v=21Lk4YiASMo').to_s).to match(/embed/)
49
40
  end
50
41
 
51
42
  it "returns an image as the placeholder" do
52
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo')
53
- .placeholder_html).to match(/<img/)
43
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo').placeholder_html).to match(/<img/)
54
44
  end
55
45
 
56
46
  it "passes the playlist ID through" do
57
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&list=UUQau-O2C0kGJpR3_CHBTGbw&index=1')
58
- .to_s).to match(/UUQau-O2C0kGJpR3_CHBTGbw/)
47
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&list=UUQau-O2C0kGJpR3_CHBTGbw&index=1').to_s).to match(/UUQau-O2C0kGJpR3_CHBTGbw/)
59
48
  end
60
49
 
61
50
  it "filters out nonsense parameters" do
62
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&potential[]=exploit&potential[]=fun')
63
- .to_s).not_to match(/potential|exploit|fun/)
51
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&potential[]=exploit&potential[]=fun').to_s).not_to match(/potential|exploit|fun/)
64
52
  end
65
53
 
66
54
  it "converts time strings into a &start= parameter" do
67
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=3782')
68
- .to_s).to match(/start=3782/)
69
- expect(Onebox.preview('https://www.youtube.com/watch?start=1h3m2s&v=21Lk4YiASMo')
70
- .to_s).to match(/start=3782/)
71
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&t=1h3m2s')
72
- .to_s).to match(/start=3782/)
73
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=1h3m2s')
74
- .to_s).to match(/start=3782/)
75
- expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo#t=1h3m2s')
76
- .to_s).to match(/start=3782/)
55
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=3782').to_s).to match(/start=3782/)
56
+ expect(Onebox.preview('https://www.youtube.com/watch?start=1h3m2s&v=21Lk4YiASMo').to_s).to match(/start=3782/)
57
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&t=1h3m2s').to_s).to match(/start=3782/)
58
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo&start=1h3m2s').to_s).to match(/start=3782/)
59
+ expect(Onebox.preview('https://www.youtube.com/watch?v=21Lk4YiASMo#t=1h3m2s').to_s).to match(/start=3782/)
77
60
  end
78
61
 
79
62
  it "allows both start and end" do
@@ -88,4 +71,3 @@ describe Onebox::Engine::YoutubeOnebox do
88
71
  preview.to match(/playlist=21Lk4YiASMo/)
89
72
  end
90
73
  end
91
-
@@ -1,16 +1,13 @@
1
1
  <aside class="onebox {{subname}}">
2
2
  <header class="source">
3
- <a href="{{{link}}}" target='_blank' >
4
- {{#repository_path}}{{repository_path}}{{/repository_path}}
5
- {{^repository_path}}{{domain}}{{/repository_path}}
6
- </a>
3
+ <a href="{{{link}}}" target='_blank'>{{domain}}</a>
7
4
  </header>
8
5
  <article class="onebox-body">
9
6
  {{{view}}}
10
7
  </article>
11
8
  <div class="onebox-metadata">
12
- {{#twitter_label1}}<span style="float: left;">{{twitter_label1}}: {{twitter_data1}}</span>{{/twitter_label1}}
13
- {{#twitter_label2}}<span style="float: right;">{{twitter_label2}}: {{twitter_data2}}</span>{{/twitter_label2}}
9
+ {{#metadata_1_label}}<span style="float: left;">{{metadata_1_label}}: {{metadata_1_value}}</span>{{/metadata_1_label}}
10
+ {{#metadata_2_label}}<span style="float: right;">{{metadata_2_label}}: {{metadata_2_value}}</span>{{/metadata_2_label}}
14
11
  </div>
15
12
  <div style="clear: both"></div>
16
13
  </aside>
@@ -0,0 +1,8 @@
1
+ <div class="onebox">
2
+ <a href="{{url}}">
3
+ <h1>{{name}}</h1>
4
+ <h2 class="host">xkcd.com</h2>
5
+ <img src="{{image}}" />
6
+ <p>{{description}}</p>
7
+ </a>
8
+ </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.5.50
4
+ version: 1.5.60
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-10-09 00:00:00.000000000 Z
13
+ date: 2016-11-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -326,6 +326,7 @@ files:
326
326
  - lib/onebox/engine/video_onebox.rb
327
327
  - lib/onebox/engine/whitelisted_generic_onebox.rb
328
328
  - lib/onebox/engine/wikipedia_onebox.rb
329
+ - lib/onebox/engine/xkcd_onebox.rb
329
330
  - lib/onebox/engine/youku_onebox.rb
330
331
  - lib/onebox/engine/youtube_onebox.rb
331
332
  - lib/onebox/file_type_finder.rb
@@ -350,7 +351,8 @@ files:
350
351
  - spec/fixtures/githubpullrequest.response
351
352
  - spec/fixtures/googleplayapp.response
352
353
  - spec/fixtures/image.response
353
- - spec/fixtures/meetup.response
354
+ - spec/fixtures/meetup.response.html
355
+ - spec/fixtures/meetup_oembed.response
354
356
  - spec/fixtures/pubmed-xml.response
355
357
  - spec/fixtures/pubmed.response
356
358
  - spec/fixtures/slides.response
@@ -361,6 +363,7 @@ files:
361
363
  - spec/fixtures/video.response
362
364
  - spec/fixtures/wikipedia.response
363
365
  - spec/fixtures/wikipediaredirected.response
366
+ - spec/fixtures/xkcd.response
364
367
  - spec/fixtures/youku-meta.response
365
368
  - spec/fixtures/youku.response
366
369
  - spec/fixtures/youtube-channel.response
@@ -386,6 +389,7 @@ files:
386
389
  - spec/lib/onebox/engine/video_onebox_spec.rb
387
390
  - spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
388
391
  - spec/lib/onebox/engine/wikipedia_onebox_spec.rb
392
+ - spec/lib/onebox/engine/xkcd_spec.rb
389
393
  - spec/lib/onebox/engine/youku_onebox_spec.rb
390
394
  - spec/lib/onebox/engine/youtube_onebox_spec.rb
391
395
  - spec/lib/onebox/engine_spec.rb
@@ -412,6 +416,7 @@ files:
412
416
  - templates/twitterstatus.mustache
413
417
  - templates/whitelistedgeneric.mustache
414
418
  - templates/wikipedia.mustache
419
+ - templates/xkcd.mustache
415
420
  - web/assets/javascripts/jquery.js
416
421
  - web/assets/javascripts/main.js
417
422
  - web/assets/stylesheets/normalize.css
@@ -452,7 +457,8 @@ test_files:
452
457
  - spec/fixtures/githubpullrequest.response
453
458
  - spec/fixtures/googleplayapp.response
454
459
  - spec/fixtures/image.response
455
- - spec/fixtures/meetup.response
460
+ - spec/fixtures/meetup.response.html
461
+ - spec/fixtures/meetup_oembed.response
456
462
  - spec/fixtures/pubmed-xml.response
457
463
  - spec/fixtures/pubmed.response
458
464
  - spec/fixtures/slides.response
@@ -463,6 +469,7 @@ test_files:
463
469
  - spec/fixtures/video.response
464
470
  - spec/fixtures/wikipedia.response
465
471
  - spec/fixtures/wikipediaredirected.response
472
+ - spec/fixtures/xkcd.response
466
473
  - spec/fixtures/youku-meta.response
467
474
  - spec/fixtures/youku.response
468
475
  - spec/fixtures/youtube-channel.response
@@ -488,6 +495,7 @@ test_files:
488
495
  - spec/lib/onebox/engine/video_onebox_spec.rb
489
496
  - spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
490
497
  - spec/lib/onebox/engine/wikipedia_onebox_spec.rb
498
+ - spec/lib/onebox/engine/xkcd_spec.rb
491
499
  - spec/lib/onebox/engine/youku_onebox_spec.rb
492
500
  - spec/lib/onebox/engine/youtube_onebox_spec.rb
493
501
  - spec/lib/onebox/engine_spec.rb