onebox 1.5.32 → 1.5.33

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: aa9168446ef3d1d26838bbd529dedc3a15f583ea
4
- data.tar.gz: d2e3b70b361f78002adef13326e492a73b60aeab
3
+ metadata.gz: f2fc1af73126033c75ddb252a9a3ccb849812734
4
+ data.tar.gz: 9baf00da44e4f046b326a126e39da5afa9a46277
5
5
  SHA512:
6
- metadata.gz: c047b42a97d0c327081370fcacbc5cf5164ba8af9d22538bcc2002ccdf410f8c967e60605053b995b5ca2d65d57b3042dc1d762a9da9c5d0ee1659a9278f8baf
7
- data.tar.gz: fb64aeff91145d2d9f8ee23fc9f5d281fc40c7a8c1aea423fbdb114f9a4fa1be53bf13e327d641a06ae59fc8648dd7a34e65cfa9283eb4e863e9c8c51982e3c1
6
+ metadata.gz: 23b0f516207ac63e888df9ddbc8848758edba4ea371c36c0685d2f7a76eb723508c7caf7df596bf506a98a7f28d7a3b8106c01fc5fa414ffb06a0433fd2a7e5d
7
+ data.tar.gz: 86baadd2e7c9c238236c4d3c29d6ad1d8fe544df3b810b7fcbf1cec154ae51f879c4e9a760d6bb99c5ce3cb89dff58e025ba44bbddad79c1a2c3727b6c9169bf
data/lib/onebox/engine.rb CHANGED
@@ -162,3 +162,4 @@ require_relative "engine/pubmed_onebox"
162
162
  require_relative "engine/soundcloud_onebox"
163
163
  require_relative "engine/imgur_onebox"
164
164
  require_relative "engine/steam_store_widget_onebox"
165
+ require_relative "engine/pastebin_onebox"
@@ -0,0 +1,37 @@
1
+ module Onebox
2
+ module Engine
3
+ class PastebinOnebox
4
+ include Engine
5
+ include StandardEmbed
6
+
7
+ matches_regexp(/^http?:\/\/pastebin\.com/)
8
+
9
+ def paste_key
10
+ if uri.path =~ /\/raw\//
11
+ match = uri.path.match(/\/raw\/([^\/]+)/)
12
+ return match[1] if match && match[1]
13
+ elsif uri.path =~ /\/download\//
14
+ match = uri.path.match(/\/download\/([^\/]+)/)
15
+ return match[1] if match && match[1]
16
+ elsif uri.path =~ /\/embed\//
17
+ match = uri.path.match(/\/embed\/([^\/]+)/)
18
+ return match[1] if match && match[1]
19
+ else
20
+ match = uri.path.match(/\/([^\/]+)/)
21
+ return match[1] if match && match[1]
22
+ end
23
+
24
+ nil
25
+ rescue
26
+ return nil
27
+ end
28
+
29
+ def to_html
30
+ return nil unless paste_key
31
+ response = Onebox::Helpers.fetch_response("http://pastebin.com/raw/#{paste_key}", 1)
32
+ return nil unless response && response.code.to_i == 200
33
+ return "<iframe src='//pastebin.com/embed_iframe/#{paste_key}' style='border:none;width:100%;max-height:100px;'></iframe>"
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,3 +1,3 @@
1
1
  module Onebox
2
- VERSION = "1.5.32"
2
+ VERSION = "1.5.33"
3
3
  end
@@ -0,0 +1,3 @@
1
+ Discourse Pastebin Onebox!
2
+
3
+ by @techAPJ
@@ -0,0 +1,23 @@
1
+ require "spec_helper"
2
+
3
+ describe Onebox::Engine::PastebinOnebox do
4
+ before do
5
+ fake("http://pastebin.com/raw/YH8wQDi8", response("pastebin.response"))
6
+ end
7
+
8
+ it "returns iframe with pastebin embed URL" do
9
+ expect(Onebox.preview('http://pastebin.com/YH8wQDi8').to_s).to match("<iframe src='//pastebin.com/embed_iframe/YH8wQDi8' style='border:none;width:100%;max-height:100px;'></iframe>")
10
+ end
11
+
12
+ it "supports pastebin raw link" do
13
+ expect(Onebox.preview('http://pastebin.com/raw/YH8wQDi8').to_s).to match(/pastebin.com\/embed_iframe\/YH8wQDi8/)
14
+ end
15
+
16
+ it "supports pastebin download link" do
17
+ expect(Onebox.preview('http://pastebin.com/download/YH8wQDi8').to_s).to match(/pastebin.com\/embed_iframe\/YH8wQDi8/)
18
+ end
19
+
20
+ it "supports pastebin embed link" do
21
+ expect(Onebox.preview('http://pastebin.com/embed/YH8wQDi8').to_s).to match(/pastebin.com\/embed_iframe\/YH8wQDi8/)
22
+ end
23
+ 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.5.32
4
+ version: 1.5.33
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-01-17 00:00:00.000000000 Z
13
+ date: 2016-01-18 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/engine/image_onebox.rb
316
316
  - lib/onebox/engine/imgur_onebox.rb
317
317
  - lib/onebox/engine/json.rb
318
+ - lib/onebox/engine/pastebin_onebox.rb
318
319
  - lib/onebox/engine/pubmed_onebox.rb
319
320
  - lib/onebox/engine/soundcloud_onebox.rb
320
321
  - lib/onebox/engine/stack_exchange_onebox.rb
@@ -349,6 +350,7 @@ files:
349
350
  - spec/fixtures/googleplayapp.response
350
351
  - spec/fixtures/image.response
351
352
  - spec/fixtures/meetup.response
353
+ - spec/fixtures/pastebin.response
352
354
  - spec/fixtures/pubmed-xml.response
353
355
  - spec/fixtures/pubmed.response
354
356
  - spec/fixtures/stackexchange.response
@@ -374,6 +376,7 @@ files:
374
376
  - spec/lib/onebox/engine/html_spec.rb
375
377
  - spec/lib/onebox/engine/image_onebox_spec.rb
376
378
  - spec/lib/onebox/engine/json_spec.rb
379
+ - spec/lib/onebox/engine/pastebin_onebox.spec.rb
377
380
  - spec/lib/onebox/engine/pubmed_onebox_spec.rb
378
381
  - spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
379
382
  - spec/lib/onebox/engine/steam_store_widget_onebox_spec.rb
@@ -446,6 +449,7 @@ test_files:
446
449
  - spec/fixtures/googleplayapp.response
447
450
  - spec/fixtures/image.response
448
451
  - spec/fixtures/meetup.response
452
+ - spec/fixtures/pastebin.response
449
453
  - spec/fixtures/pubmed-xml.response
450
454
  - spec/fixtures/pubmed.response
451
455
  - spec/fixtures/stackexchange.response
@@ -471,6 +475,7 @@ test_files:
471
475
  - spec/lib/onebox/engine/html_spec.rb
472
476
  - spec/lib/onebox/engine/image_onebox_spec.rb
473
477
  - spec/lib/onebox/engine/json_spec.rb
478
+ - spec/lib/onebox/engine/pastebin_onebox.spec.rb
474
479
  - spec/lib/onebox/engine/pubmed_onebox_spec.rb
475
480
  - spec/lib/onebox/engine/stack_exchange_onebox_spec.rb
476
481
  - spec/lib/onebox/engine/steam_store_widget_onebox_spec.rb