Skip to content

Commit becaa40

Browse files
committed
Added jsbin.com support #156
1 parent ddf04d0 commit becaa40

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

src/Providers/OEmbed/Jsbin.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Embed\Providers\OEmbed;
4+
5+
use Embed\Url;
6+
7+
class Jsbin extends OEmbedImplementation
8+
{
9+
/**
10+
* {@inheritdoc}
11+
*/
12+
public static function getEndPoint(Url $url)
13+
{
14+
return 'http://jsbin.com/oembed';
15+
}
16+
17+
/**
18+
* {@inheritdoc}
19+
*/
20+
public static function getParams(Url $url)
21+
{
22+
return [
23+
'url' => $url->createUrl()
24+
->withDirectoryPosition(2, 'embed')
25+
->getUrl(),
26+
];
27+
}
28+
29+
/**
30+
* {@inheritdoc}
31+
*/
32+
public static function getPatterns()
33+
{
34+
return [
35+
'http?://output.jsbin.com/*',
36+
];
37+
}
38+
}

tests/JsbinTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
class JsbinTest extends TestCaseBase
4+
{
5+
public function testOne()
6+
{
7+
$this->assertEmbed(
8+
'http://output.jsbin.com/vonesu/10',
9+
[
10+
'title' => 'JS Bin',
11+
'type' => 'rich',
12+
'providerName' => 'jsbin',
13+
'providerUrl' => 'http://jsbin.com',
14+
'code' => '<iframe src="http://jsbin.com/vonesu/10/embed" width="640" height="480" frameborder="0"></iframe>'
15+
]
16+
);
17+
}
18+
}

tests/TestCaseBase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ private function assertOembedAutodiscover(Request $request)
9090
$className = $request->getClassNameForDomain();
9191

9292
//exceptions
93-
if (in_array($className, ['Wordpress', 'Youtube'])) {
93+
if (in_array($className, ['Wordpress', 'Youtube', 'Jsbin'])) {
9494
return;
9595
}
9696

0 commit comments

Comments
 (0)