Skip to content

Commit

Permalink
Add support for https://perlbot.pl, closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Henning Thorsen committed Sep 26, 2018
1 parent 7f384f3 commit f144836
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ Revision history for perl distribution LinkEmbedder

1.01 Not Released
- Forgot to remove Carp::Always
- Add support for https://perlbot.pl #1
- Add support for https://paste.fedoraproject.org #2
- Add support for https://bitbucket.org #3
- Add support for https://paste.fedoraproject.org #22

1.00 2018-09-26T01:22:18+0900
- Compatible with Mojolicious 8.00
Expand Down
4 changes: 2 additions & 2 deletions lib/LinkEmbedder/Link/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ sub _learn_from_dom {
$self->template->[1] = 'paste.html.ep';
}

# Mojopaste hack
$tmp = $dom->at('body > pre');
# Mojopaste and Perlbot hack
$tmp = $dom->at('body > pre') || $dom->at('pre#paste') || $dom->at('pre.paste');
if ($tmp and !@{$tmp->children}) {
$self->{paste} = $tmp->text;
$self->template->[1] = 'paste.html.ep';
Expand Down
2 changes: 1 addition & 1 deletion t/fpaste.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ my $embedder = LinkEmbedder->new;

my $link;
$embedder->get_p('https://paste.fedoraproject.org/paste/9qkGGjN-D3fL2M-bimrwNQ')->then(sub { $link = shift })->wait;
isa_ok($link, 'LinkEmbedder::Link::Basic');
isa_ok($link, 'LinkEmbedder::Link::Fpaste');
cmp_deeply(
$link->TO_JSON,
{
Expand Down
28 changes: 28 additions & 0 deletions t/perlbot.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use Mojo::Base -strict;
use Test::Deep;
use Test::More;
use LinkEmbedder;

plan skip_all => 'TEST_ONLINE=1' unless $ENV{TEST_ONLINE};

my $embedder = LinkEmbedder->new;

my $link;
$embedder->get_p('https://perlbot.pl/p/mgyz68')->then(sub { $link = shift })->wait;
isa_ok($link, 'LinkEmbedder::Link::Basic');
cmp_deeply(
$link->TO_JSON,
{
cache_age => 0,
html => re(qr{<pre>my \$link;}),
provider_name => 'Perlbot',
provider_url => 'https://perlbot.pl/',
title => re(qr{Perlbot Pastebin}),
type => 'rich',
url => 'https://perlbot.pl/p/mgyz68',
version => '1.0',
},
'https://perlbot.pl'
) or note $link->_dump;

done_testing;

0 comments on commit f144836

Please sign in to comment.