File tree Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Expand file tree Collapse file tree 2 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Embed \Adapters ;
4
+
5
+ use Embed \Request ;
6
+ use Embed \Utils ;
7
+
8
+ /**
9
+ * Adapter to generate embed code from snipplr.com.
10
+ */
11
+ class Snipplr extends Webpage implements AdapterInterface
12
+ {
13
+ /**
14
+ * {@inheritdoc}
15
+ */
16
+ public static function check (Request $ request )
17
+ {
18
+ return $ request ->isValid () && $ request ->match ([
19
+ 'https?://snipplr.com/view/* ' ,
20
+ ]);
21
+ }
22
+
23
+ /**
24
+ * {@inheritdoc}
25
+ */
26
+ public function getCode ()
27
+ {
28
+ $ this ->width = null ;
29
+ $ this ->height = null ;
30
+
31
+ $ id = $ this ->request ->getDirectoryPosition (1 );
32
+
33
+ return <<<CODE
34
+ <div id="snipplr_embed_ {$ id }" class="snipplr_embed"><a target_"blank" href="http://snipplr.com/view/ {$ id }">View this snippet</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/ {$ id }"></script>
35
+ CODE ;
36
+ }
37
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ class SnipplrTest extends TestCaseBase
4
+ {
5
+ public function testOne ()
6
+ {
7
+ $ this ->assertEmbed (
8
+ 'http://snipplr.com/view/72914/better-html-5-basic-starter-template ' ,
9
+ [
10
+ 'title ' => 'Better HTML 5 basic starter template - HTML - Snipplr Social Snippet Repository ' ,
11
+ 'type ' => 'rich ' ,
12
+ 'providerName ' => 'snipplr ' ,
13
+ 'providerUrl ' => 'http://snipplr.com ' ,
14
+ 'code ' => '<div id="snipplr_embed_72914" class="snipplr_embed"><a target_"blank" href="http://snipplr.com/view/72914">View this snippet</a> on Snipplr</div><script type="text/javascript" src="http://snipplr.com/js/embed.js"></script><script type="text/javascript" src="http://snipplr.com/json/72914"></script> '
15
+ ]
16
+ );
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments