Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add paste.debian.net support (closes #19) #28

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/LinkEmbedder/Link/Basic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ sub _learn_from_dom {
}

# Mojopaste, Perlbot and other pages with <pre> tags
if ($tmp = $dom->at('pre#paste') || $dom->at('pre.paste') || $dom->at('body > pre') || $dom->at('body > div > pre')) {
$self->{paste} = $tmp->text;
if ($tmp = $dom->at('pre#paste') || $dom->at('pre.paste') || $dom->at('body > pre') || $dom->at('body > div > pre') || $dom->at('.code')) {
$self->{paste} = $tmp->all_text;
$self->template->[1] = 'paste.html.ep';
}

Expand Down
46 changes: 46 additions & 0 deletions t/paste-debian.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use Mojo::Base -strict;
use Test::More;
use LinkEmbedder;

plan skip_all => 'TEST_ONLINE=1' unless $ENV{TEST_ONLINE};
plan skip_all => 'cpanm IO::Socket::SSL' unless LinkEmbedder::TLS;

LinkEmbedder->new->test_ok(
'https://paste.debian.net/?show=1186554' => {
cache_age => 0,
class => 'le-paste le-provider-debian le-rich',
html => paste_debian_html(),
isa => 'LinkEmbedder::Link::Basic',
provider_name => 'Debian',
provider_url => 'https://paste.debian.net/?show=1186554',
title => 'debian Pastezone',
type => 'rich',
url => 'https://paste.debian.net/?show=1186554',
version => '1.0'
}
);

done_testing;

sub paste_debian_html {
return <<'HERE';
<div class="le-paste le-provider-debian le-rich">
<div class="le-meta">
<span class="le-provider-link"><a href="https://paste.debian.net/?show=1186554">Debian</a></span>
<span class="le-goto-link"><a href="https://paste.debian.net/?show=1186554" title="debian Pastezone">View</a></span>
</div>
<pre>#!/bin/bash
theIp=$(printf &quot;&lt;redacted IPv6 prefix&gt;$(echo -n $1 | sha1sum | head -c 16 | sed &#39;s/..../:&amp;/g&#39;)\n&quot;)
echo &quot;User: $1&quot;
echo &quot;\&quot;$theIp/64\&quot;&quot;

## Example output
$ bash genip.sh Batman
User: Batman
&quot;&lt;redacted IPv6 prefix&gt;:32b2:6a27:1530:f105/64&quot;

</pre>
</div>
HERE
}