line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojolicious::Command::export; |
2
|
|
|
|
|
|
|
our $VERSION = '0.007'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Export a Mojolicious website to static files |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
6
|
|
|
|
|
|
|
#pod |
7
|
|
|
|
|
|
|
#pod Usage: APPLICATION export [OPTIONS] [PAGES] |
8
|
|
|
|
|
|
|
#pod |
9
|
|
|
|
|
|
|
#pod ./myapp.pl export |
10
|
|
|
|
|
|
|
#pod ./myapp.pl export /perldoc --to /var/www/html |
11
|
|
|
|
|
|
|
#pod ./myapp.pl export /perldoc --base /url |
12
|
|
|
|
|
|
|
#pod |
13
|
|
|
|
|
|
|
#pod Options: |
14
|
|
|
|
|
|
|
#pod -h, --help Show this summary of available options |
15
|
|
|
|
|
|
|
#pod --to Path to store the static pages. Defaults to '.'. |
16
|
|
|
|
|
|
|
#pod --base Rewrite internal absolute links to prepend base |
17
|
|
|
|
|
|
|
#pod -q, --quiet Silence report of dirs/files modified |
18
|
|
|
|
|
|
|
#pod |
19
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
20
|
|
|
|
|
|
|
#pod |
21
|
|
|
|
|
|
|
#pod Export a Mojolicious webapp to static files. |
22
|
|
|
|
|
|
|
#pod |
23
|
|
|
|
|
|
|
#pod =head2 Configuration |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod Default values for the command's options can be specified in the |
26
|
|
|
|
|
|
|
#pod configuration using one of Mojolicious's configuration plugins. |
27
|
|
|
|
|
|
|
#pod |
28
|
|
|
|
|
|
|
#pod # myapp.conf |
29
|
|
|
|
|
|
|
#pod { |
30
|
|
|
|
|
|
|
#pod export => { |
31
|
|
|
|
|
|
|
#pod # Configure the default pages to export |
32
|
|
|
|
|
|
|
#pod pages => [ '/', '/hidden' ], |
33
|
|
|
|
|
|
|
#pod # The directory to export to |
34
|
|
|
|
|
|
|
#pod to => '/var/www/html', |
35
|
|
|
|
|
|
|
#pod # Rewrite URLs to include base directory |
36
|
|
|
|
|
|
|
#pod base => '/', |
37
|
|
|
|
|
|
|
#pod } |
38
|
|
|
|
|
|
|
#pod } |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
41
|
|
|
|
|
|
|
#pod |
42
|
|
|
|
|
|
|
#pod L, L |
43
|
|
|
|
|
|
|
#pod |
44
|
|
|
|
|
|
|
#pod =cut |
45
|
|
|
|
|
|
|
|
46
|
2
|
|
|
2
|
|
593645
|
use Mojo::Base 'Mojolicious::Command'; |
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
13
|
|
47
|
2
|
|
|
2
|
|
41166
|
use Mojo::Util qw( getopt ); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
503
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
has description => 'Export site to static files'; |
50
|
|
|
|
|
|
|
has usage => sub { shift->extract_usage }; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub run { |
53
|
7
|
|
|
7
|
1
|
66590
|
my ( $self, @args ) = @_; |
54
|
7
|
|
|
|
|
34
|
my $app = $self->app; |
55
|
7
|
50
|
|
|
|
75
|
if ( !$app->can( 'export' ) ) { |
56
|
7
|
|
|
|
|
184
|
$app->plugin( 'Export' ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
7
|
|
|
|
|
41
|
getopt( \@args, \my %opt, |
60
|
|
|
|
|
|
|
'to=s', |
61
|
|
|
|
|
|
|
'base=s', |
62
|
|
|
|
|
|
|
'quiet|q', |
63
|
|
|
|
|
|
|
); |
64
|
7
|
|
50
|
|
|
3509
|
$opt{quiet} //= 0; |
65
|
7
|
50
|
|
|
|
24
|
if ( $opt{quiet} ) { |
66
|
0
|
|
|
|
|
0
|
$self->quiet( 1 ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
7
|
100
|
|
|
|
22
|
if ( @args ) { |
70
|
4
|
|
|
|
|
9
|
$opt{pages} = \@args; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
|
|
35
|
$app->export->export( \%opt ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |