App-Aphra
view release on metacpan or search on metacpan
lib/App/Aphra.pm view on Meta::CPAN
app => $self, filename => $_,
});
$f->process;
};
}
sub make_redirects {
my $self = shift;
my $redirects = $self->site_vars->{redirects};
return if !$redirects;
return if !@$redirects;
my $target = $self->config->{target};
for (@$redirects) {
my $from = $_->{from};
$from .= 'index.html' if $from =~ m|/$|;
my $to = $_->{to};
my $outdir = path("$target$from")->dirname;
path($outdir)->mkdir;
open my $out_fh, '>', "$target$from"
or die "Cannot open '$target$from' for writing: $!\n";
print $out_fh <<EOF;
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url=$to">
</head>
</html>
EOF
close $out_fh;
}
}
sub serve {
my $self = shift;
require App::HTTPThis;
if ($@) {
croak "App::HTTPThis must be installed for 'serve' command";
}
local @ARGV = $self->config->{target};
App::HTTPThis->new->run;
}
has ver => (
is => 'ro',
default => $VERSION,
);
sub version {
my $me = path($0)->basename;
say "\n$me version: $VERSION\n";
}
sub help {
my $self = shift;
my $me = path($0)->basename;
$self->version;
say <<ENDOFHELP;
$me is a simple static sitebuilder which uses the Template Toolkit to
process input templates and turn them into a web site.
ENDOFHELP
}
__PACKAGE__->meta->make_immutable;
1;
=head1 AUTHOR
Dave Cross <dave@perlhacks.com>
=head1 COPYRIGHT AND LICENCE
Copyright (c) 2017-2024, Magnum Solutions Ltd. All Rights Reserved.
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
( run in 2.693 seconds using v1.01-cache-2.11-cpan-13bb782fe5a )