onebox 1.8.16 → 1.8.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::CloudAppOnebox do
4
+ before do
5
+ fake("https://cl.ly/0m2a2u2k440O", response("cloudapp-gif"))
6
+ fake("https://cl.ly/0T0c2J3S373X", response("cloudapp-mp4"))
7
+ fake("https://cl.ly/2C0E1V451J0C", response("cloudapp-jpg"))
8
+ fake("https://cl.ly/1x1f2g253l03", response("cloudapp-others"))
9
+ end
10
+
11
+ it "supports gif" do
12
+ expect(Onebox.preview('https://cl.ly/0m2a2u2k440O').to_s).to match(/<img/)
13
+ end
14
+
15
+ it "supports mp4" do
16
+ expect(Onebox.preview('https://cl.ly/0T0c2J3S373X').to_s).to match(/<video/)
17
+ end
18
+
19
+ it "supports jpg" do
20
+ expect(Onebox.preview('https://cl.ly/2C0E1V451J0C').to_s).to match(/<img/)
21
+ end
22
+
23
+ it "links to other formats" do
24
+ expect(Onebox.preview('https://cl.ly/1x1f2g253l03').to_s).to match(/<a/)
25
+ end
26
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::WechatMpOnebox do
4
+
5
+ let(:link) {"https://mp.weixin.qq.com/s?__biz=MjM5NjM4MDAxMg==&mid=2655075181&idx=1&sn=7c58f17de2c687f4763f17359ecc6e72&chksm=bd5fb76e8a283e7856cae30a74e905a18d9511e81c047b6e12390889de15976fb2c297b04106#rd"}
6
+ let(:html) { described_class.new(link).to_html }
7
+
8
+ describe "#to_html" do
9
+ before do
10
+ fake("https://mp.weixin.qq.com/s?__biz=MjM5NjM4MDAxMg==&mid=2655075181&idx=1&sn=7c58f17de2c687f4763f17359ecc6e72&chksm=bd5fb76e8a283e7856cae30a74e905a18d9511e81c047b6e12390889de15976fb2c297b04106", response("wechat-mp"))
11
+ end
12
+
13
+ it "has the article's title" do
14
+ expect(html).to include("不是月光宝盒,但也能回到过去")
15
+ end
16
+
17
+ it "has the article's description" do
18
+ expect(html).to include("你知道吗?从今天起,公众号后台编辑文章时可以……")
19
+ end
20
+
21
+ it "has the article's author" do
22
+ expect(html).to include("微信派")
23
+ end
24
+ end
25
+
26
+ end
@@ -97,20 +97,39 @@ describe Onebox::Engine::WhitelistedGenericOnebox do
97
97
  end
98
98
  end
99
99
 
100
- describe "uses canonical link" do
101
- let(:mobile_url) { "http://m.imdb.com/title/tt0944947" }
102
- let(:canonical_url) { "http://www.imdb.com/title/tt0944947/" }
103
- before do
104
- fake(mobile_url, response('imdb_mobile'))
105
- fake(canonical_url, response('imdb'))
100
+ describe 'canonical link' do
101
+ context 'uses canonical link if available' do
102
+ let(:mobile_url) { "http://m.imdb.com/title/tt0944947" }
103
+ let(:canonical_url) { "http://www.imdb.com/title/tt0944947/" }
104
+ before do
105
+ fake(mobile_url, response('imdb_mobile'))
106
+ fake(canonical_url, response('imdb'))
107
+ end
108
+
109
+ it 'fetches opengraph data from canonical link' do
110
+ onebox = described_class.new(mobile_url)
111
+ expect(onebox.to_html).not_to be_nil
112
+ expect(onebox.to_html).to include("Game of Thrones")
113
+ expect(onebox.to_html).to include("Nine noble families fight for control over the mythical lands of Westeros")
114
+ expect(onebox.to_html).to include("https://images-na.ssl-images-amazon.com/images/M/MV5BMjE3NTQ1NDg1Ml5BMl5BanBnXkFtZTgwNzY2NDA0MjI@._V1_UY1200_CR90,0,630,1200_AL_.jpg")
115
+ end
106
116
  end
107
117
 
108
- it 'fetches opengraph data from canonical link' do
109
- onebox = described_class.new(mobile_url)
110
- expect(onebox.to_html).not_to be_nil
111
- expect(onebox.to_html).to include("Game of Thrones")
112
- expect(onebox.to_html).to include("Nine noble families fight for control over the mythical lands of Westeros")
113
- expect(onebox.to_html).to include("https://images-na.ssl-images-amazon.com/images/M/MV5BMjE3NTQ1NDg1Ml5BMl5BanBnXkFtZTgwNzY2NDA0MjI@._V1_UY1200_CR90,0,630,1200_AL_.jpg")
118
+ context 'does not use canonical link for Discourse topics' do
119
+ let(:discourse_topic_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483" }
120
+ let(:discourse_topic_reply_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483/2" }
121
+ before do
122
+ fake(discourse_topic_url, response('discourse_topic'))
123
+ fake(discourse_topic_reply_url, response('discourse_topic_reply'))
124
+ end
125
+
126
+ it 'fetches opengraph data from original link' do
127
+ onebox = described_class.new(discourse_topic_reply_url)
128
+ expect(onebox.to_html).not_to be_nil
129
+ expect(onebox.to_html).to include("Congratulations, most stars in 2013 GitHub Octoverse!")
130
+ expect(onebox.to_html).to include("Thanks for that link and thank you -- and everyone else who is contributing to the project!")
131
+ expect(onebox.to_html).to include("https://cdn-enterprise.discourse.org/meta/user_avatar/meta.discourse.org/codinghorror/200/5297_1.png")
132
+ end
114
133
  end
115
134
  end
116
135
 
@@ -0,0 +1,4 @@
1
+ <h3><a href='{{link}}' target='_blank'>{{title}}</a></h3>
2
+ {{#by_info}}<b>{{by_info}}</b>{{/by_info}}
3
+ <p>{{description}}</p>
4
+
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.16
4
+ version: 1.8.17
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: 2017-07-20 00:00:00.000000000 Z
13
+ date: 2017-08-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: multi_json
@@ -333,6 +333,7 @@ files:
333
333
  - lib/onebox/engine/audio_onebox.rb
334
334
  - lib/onebox/engine/audioboom_onebox.rb
335
335
  - lib/onebox/engine/bandcamp_onebox.rb
336
+ - lib/onebox/engine/cloudapp_onebox.rb
336
337
  - lib/onebox/engine/coub_onebox.rb
337
338
  - lib/onebox/engine/douban_onebox.rb
338
339
  - lib/onebox/engine/five_hundred_px_onebox.rb
@@ -373,6 +374,7 @@ files:
373
374
  - lib/onebox/engine/typeform_onebox.rb
374
375
  - lib/onebox/engine/video_onebox.rb
375
376
  - lib/onebox/engine/vimeo_onebox.rb
377
+ - lib/onebox/engine/wechat_mp_onebox.rb
376
378
  - lib/onebox/engine/whitelisted_generic_onebox.rb
377
379
  - lib/onebox/engine/wikimedia_onebox.rb
378
380
  - lib/onebox/engine/wikipedia_onebox.rb
@@ -396,7 +398,13 @@ files:
396
398
  - onebox.gemspec
397
399
  - spec/fixtures/amazon-og.response
398
400
  - spec/fixtures/amazon.response
401
+ - spec/fixtures/cloudapp-gif.response
402
+ - spec/fixtures/cloudapp-jpg.response
403
+ - spec/fixtures/cloudapp-mp4.response
404
+ - spec/fixtures/cloudapp-others.response
399
405
  - spec/fixtures/dailymail.response
406
+ - spec/fixtures/discourse_topic.response
407
+ - spec/fixtures/discourse_topic_reply.response
400
408
  - spec/fixtures/douban.response
401
409
  - spec/fixtures/gfycat.response
402
410
  - spec/fixtures/githubblob.response
@@ -418,6 +426,7 @@ files:
418
426
  - spec/fixtures/stackexchange-question.response
419
427
  - spec/fixtures/twitterstatus.response
420
428
  - spec/fixtures/video.response
429
+ - spec/fixtures/wechat-mp.response
421
430
  - spec/fixtures/wikimedia.response
422
431
  - spec/fixtures/wikipedia.response
423
432
  - spec/fixtures/wikipediaredirected.response
@@ -430,6 +439,7 @@ files:
430
439
  - spec/fixtures/youtube.response
431
440
  - spec/lib/onebox/engine/amazon_onebox_spec.rb
432
441
  - spec/lib/onebox/engine/audio_onebox_spec.rb
442
+ - spec/lib/onebox/engine/cloudapp_onebox_spec.rb
433
443
  - spec/lib/onebox/engine/douban_onebox_spec.rb
434
444
  - spec/lib/onebox/engine/gfycat_onebox_spec.rb
435
445
  - spec/lib/onebox/engine/github_blob_onebox_spec.rb
@@ -452,6 +462,7 @@ files:
452
462
  - spec/lib/onebox/engine/twitch_video_onebox_spec.rb
453
463
  - spec/lib/onebox/engine/twitter_status_onebox_spec.rb
454
464
  - spec/lib/onebox/engine/video_onebox_spec.rb
465
+ - spec/lib/onebox/engine/wechat_mp_onebox_spec.rb
455
466
  - spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
456
467
  - spec/lib/onebox/engine/wikimedia_onebox_spec.rb
457
468
  - spec/lib/onebox/engine/wikipedia_onebox_spec.rb
@@ -482,6 +493,7 @@ files:
482
493
  - templates/pubmed.mustache
483
494
  - templates/stackexchange.mustache
484
495
  - templates/twitterstatus.mustache
496
+ - templates/wechatmp.mustache
485
497
  - templates/whitelistedgeneric.mustache
486
498
  - templates/wikimedia.mustache
487
499
  - templates/wikipedia.mustache
@@ -519,7 +531,13 @@ summary: A gem for turning URLs into previews.
519
531
  test_files:
520
532
  - spec/fixtures/amazon-og.response
521
533
  - spec/fixtures/amazon.response
534
+ - spec/fixtures/cloudapp-gif.response
535
+ - spec/fixtures/cloudapp-jpg.response
536
+ - spec/fixtures/cloudapp-mp4.response
537
+ - spec/fixtures/cloudapp-others.response
522
538
  - spec/fixtures/dailymail.response
539
+ - spec/fixtures/discourse_topic.response
540
+ - spec/fixtures/discourse_topic_reply.response
523
541
  - spec/fixtures/douban.response
524
542
  - spec/fixtures/gfycat.response
525
543
  - spec/fixtures/githubblob.response
@@ -541,6 +559,7 @@ test_files:
541
559
  - spec/fixtures/stackexchange-question.response
542
560
  - spec/fixtures/twitterstatus.response
543
561
  - spec/fixtures/video.response
562
+ - spec/fixtures/wechat-mp.response
544
563
  - spec/fixtures/wikimedia.response
545
564
  - spec/fixtures/wikipedia.response
546
565
  - spec/fixtures/wikipediaredirected.response
@@ -553,6 +572,7 @@ test_files:
553
572
  - spec/fixtures/youtube.response
554
573
  - spec/lib/onebox/engine/amazon_onebox_spec.rb
555
574
  - spec/lib/onebox/engine/audio_onebox_spec.rb
575
+ - spec/lib/onebox/engine/cloudapp_onebox_spec.rb
556
576
  - spec/lib/onebox/engine/douban_onebox_spec.rb
557
577
  - spec/lib/onebox/engine/gfycat_onebox_spec.rb
558
578
  - spec/lib/onebox/engine/github_blob_onebox_spec.rb
@@ -575,6 +595,7 @@ test_files:
575
595
  - spec/lib/onebox/engine/twitch_video_onebox_spec.rb
576
596
  - spec/lib/onebox/engine/twitter_status_onebox_spec.rb
577
597
  - spec/lib/onebox/engine/video_onebox_spec.rb
598
+ - spec/lib/onebox/engine/wechat_mp_onebox_spec.rb
578
599
  - spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb
579
600
  - spec/lib/onebox/engine/wikimedia_onebox_spec.rb
580
601
  - spec/lib/onebox/engine/wikipedia_onebox_spec.rb