Skip to content

Commit 282f73b

Browse files
committed
Merge pull request #81 from mburtscher/sassmeister
Sassmeister support
2 parents afa62af + ec067d2 commit 282f73b

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

src/Adapters/Sassmeister.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/**
4+
* Adapter to generate embed code from SassMeister.
5+
*/
6+
namespace Embed\Adapters;
7+
8+
use Embed\Request;
9+
10+
class Sassmeister extends Webpage implements AdapterInterface
11+
{
12+
/**
13+
* {@inheritdoc}
14+
*/
15+
public static function check(Request $request)
16+
{
17+
return $request->isValid() && $request->match([
18+
'http://sassmeister.com/gist/*',
19+
]);
20+
}
21+
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
public function getCode()
26+
{
27+
$id = $this->request->getDirectoryPosition(1);
28+
29+
return "<p class=\"sassmeister\" data-gist-id=\"{$id}\" data-height=\"480\" data-theme=\"tomorrow\">" .
30+
"<a href=\"http://sassmeister.com/gist/{$id}\">Play with this gist on SassMeister.</a>" .
31+
"</p>" .
32+
"<script src=\"http://cdn.sassmeister.com/js/embed.js\" async></script>";
33+
}
34+
}

tests/SassmeisterTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
class SassmeisterTest extends TestCaseBase
4+
{
5+
public function testGist()
6+
{
7+
$this->assertEmbed(
8+
'http://sassmeister.com/gist/1122e441f0434ec6eb2a',
9+
[
10+
'title' => 'SassMeister | The Sass Playground!',
11+
'imageWidth' => 240,
12+
'imageHeight' => 240,
13+
'type' => 'rich',
14+
'providerName' => 'sassmeister',
15+
]
16+
);
17+
}
18+
}

0 commit comments

Comments
 (0)