Skip to content

Commit 8e69d69

Browse files
committed
added Thematic adapter #129
1 parent a378490 commit 8e69d69

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/Adapters/Thematic.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php
2+
3+
namespace Embed\Adapters;
4+
5+
use Embed\Request;
6+
use Embed\Providers;
7+
use Embed\Utils;
8+
9+
/**
10+
* Adapter to provide information from thematic
11+
*/
12+
class Thematic extends Webpage implements AdapterInterface
13+
{
14+
/**
15+
* {@inheritdoc}
16+
*/
17+
public static function check(Request $request)
18+
{
19+
return $request->isValid() && $request->match([
20+
'https?://www.thematic.co/stories/*',
21+
]);
22+
}
23+
24+
/**
25+
* {@inheritdoc}
26+
*/
27+
public function getCode()
28+
{
29+
return Utils::iframe($this->request->getStartingUrl()->withDirectoryPosition(0, 'embed'), $this->width, $this->height);
30+
}
31+
32+
/**
33+
* {@inheritdoc}
34+
*/
35+
public function getWidth()
36+
{
37+
return 600;
38+
}
39+
40+
/**
41+
* {@inheritdoc}
42+
*/
43+
public function getHeight()
44+
{
45+
return 300;
46+
}
47+
}

src/Request.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,16 @@ public function getUrl()
8181
return parent::getUrl();
8282
}
8383

84+
/**
85+
* Returns the starting url
86+
*
87+
* @return Url
88+
*/
89+
public function getStartingUrl()
90+
{
91+
return $this->startingUrl;
92+
}
93+
8494
/**
8595
* Creates and returns an Url clone.
8696
*

tests/ThematicTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
class ThematicTest extends TestCaseBase
4+
{
5+
public function testOne()
6+
{
7+
$this->assertEmbed(
8+
'http://www.thematic.co/stories/9m3-the-road-to-aberdeen',
9+
[
10+
'title' => 'the Road to Aberdeen',
11+
'width' => 600,
12+
'height' => 300,
13+
'type' => 'rich',
14+
'code' => '<iframe src="http://www.thematic.co/embed/9m3-the-road-to-aberdeen" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:600px;height:300px;"></iframe>',
15+
]
16+
);
17+
}
18+
}

0 commit comments

Comments
 (0)