| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Plack::App::DirectoryIndex; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
202107
|
use parent qw[Plack::App::Directory]; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
142462
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
29
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
84
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
9
|
use Plack::Util::Accessor qw[dir_index icons pretty]; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
14
|
|
|
9
|
1
|
|
|
1
|
|
886
|
use WebServer::DirIndex; |
|
|
1
|
|
|
|
|
104100
|
|
|
|
1
|
|
|
|
|
450
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.2.3'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# NOTE: Copied from Plack::App::Directory as that module makes it |
|
14
|
|
|
|
|
|
|
# impossible to override the HTML. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub serve_path { |
|
17
|
5
|
|
|
5
|
0
|
278642
|
my $self = shift; |
|
18
|
5
|
|
|
|
|
14
|
my ($env, $dir) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
5
|
|
100
|
|
|
20
|
my $dir_index = $self->dir_index // 'index.html'; |
|
21
|
|
|
|
|
|
|
|
|
22
|
5
|
100
|
66
|
|
|
172
|
if (-d $dir and $dir_index and -f "$dir$dir_index") { |
|
|
|
|
66
|
|
|
|
|
|
23
|
3
|
|
|
|
|
12
|
$dir .= $dir_index; |
|
24
|
|
|
|
|
|
|
} |
|
25
|
|
|
|
|
|
|
|
|
26
|
5
|
100
|
|
|
|
58
|
if (-f $dir) { |
|
27
|
3
|
|
|
|
|
23
|
return $self->SUPER::serve_path($env, $dir); |
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
2
|
|
|
|
|
8
|
my $dir_url = $env->{SCRIPT_NAME} . $env->{PATH_INFO}; |
|
31
|
|
|
|
|
|
|
|
|
32
|
2
|
50
|
|
|
|
21
|
if ($dir_url !~ m{/$}) { |
|
33
|
0
|
|
|
|
|
0
|
return $self->return_dir_redirect($env); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
2
|
|
|
|
|
14
|
my %dir_index_args = ( |
|
37
|
|
|
|
|
|
|
dir => $dir, |
|
38
|
|
|
|
|
|
|
dir_url => $dir_url, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
|
|
41
|
2
|
50
|
|
|
|
9
|
$dir_index_args{pretty} = $self->pretty if defined $self->pretty; |
|
42
|
2
|
100
|
|
|
|
19
|
$dir_index_args{icons} = $self->icons if defined $self->icons; |
|
43
|
|
|
|
|
|
|
|
|
44
|
2
|
|
|
|
|
76
|
my $di = WebServer::DirIndex->new(%dir_index_args); |
|
45
|
2
|
|
|
|
|
1455
|
my $page = $di->to_html($env->{PATH_INFO}); |
|
46
|
|
|
|
|
|
|
|
|
47
|
2
|
|
|
|
|
250
|
return [ 200, ['Content-Type' => 'text/html; charset=utf-8'], [ $page ] ]; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
1; |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__END__ |