Mojolicious-Plugin-Export
view release on metacpan or search on metacpan
t/command.t view on Meta::CPAN
ok -e $tmp->child( 'about', 'index.html' ), '/about exists (relative link)';
$dom = Mojo::DOM->new( $tmp->child( 'about', 'index.html' )->slurp );
ok $dom->at( 'a[href=/base]' ), 'absolute url (/) on /about is rewritten';
ok -e $tmp->child( 'docs', 'more', 'index.html' ), '/docs/more exists (relative link)';
ok -e $tmp->child( 'logo-white-2x.png' ), 'image is exported';
chdir $home;
my $tmp_to = tempdir;
$cmd->run( '--to', $tmp_to );
ok -e $tmp_to->child( 'index.html' ), 'root exists';
ok -e $tmp_to->child( 'docs', 'index.html' ), '/docs exists (absolute link)';
ok -e $tmp_to->child( 'about', 'index.html' ), '/about exists (relative link)';
ok -e $tmp_to->child( 'logo-white-2x.png' ), 'image is exported';
# Test default settings from config
my $config_to = tempdir;
my %config = (
export => {
pages => [ '/docs' ],
to => "$config_to",
base => '/base',
},
);
$app->plugin( Config => { default => \%config } );
$cmd->run();
ok !-e $config_to->child( 'index.html' ), 'root does not exist';
ok -e $config_to->child( 'docs', 'index.html' ), '/docs exists (page requested)';
$dom = Mojo::DOM->new( $config_to->child( 'docs', 'index.html' )->slurp );
ok $dom->at( 'a[href=/base/docs/more]' ), 'absolute url is rewritten'
or diag $dom;
ok -e $config_to->child( 'docs', 'more', 'index.html' ), '/docs/more exists (link on page)';
ok !-e $config_to->child( 'about', 'index.html' ), '/about does not exist';
ok !-e $config_to->child( 'logo-white-2x.png' ), 'image is not exported';
done_testing;
__DATA__
@@ index.html.ep
<head>
<link rel="stylesheet" href="//cdnjs.org/bootstrap.css">
</head>
<h1>Export</h1>
<a href="http://mojolicious.org"><img src="logo-white-2x.png"></a>
<a href="/docs">Absolute</a>
<a href="about#foo">Relative</a>
<a href="NOT_FOUND">Not found</a>
<a href="/redirect">Redirect</a>
<a href="#foo">Fragment</a>
<a href="mailto:doug@example.com">E-mail me!</a>
@@ docs.html.ep
<h1>Docs</h1>
<a href="/docs/more">More Docs</a>
@@ about.html.ep
<h1>About</h1>
<a href="/">Back to home</a>
@@ logo-white-2x.png (base64)
iVBORw0KGgoAAAANSUhEUgAAAUIAAABMCAYAAAAY0L5YAAABG2lUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4KPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iWE1QIENvcmUgNS41LjAiPgogPHJkZjpSRE...
( run in 1.704 second using v1.01-cache-2.11-cpan-df04353d9ac )