| 1 | package Plack::App::DirectoryIndex; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use parent qw[Plack::App::Directory]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Plack::Util::Accessor qw[dir_index icons pretty]; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use WebServer::DirIndex; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | our $VERSION = '0.2.4'; | |||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | # NOTE: Copied from Plack::App::Directory as that module makes it | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # impossible to override the HTML. | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 5 | ▶ | sub serve_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serve_path: called CC=9 SCAR=22.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 18 | 5 | my ($env, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | 5 | ▶ | my $dir_index = $self->dir_index // 'index.html'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->dir_index // "index.html"
MC/DC100%1/1
$self->dir_index // "index.html"
$self->dir_index
Truth table100%2/2
A
A= $self->dir_index
| |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 5 | ▶ | if (-d $dir and $dir_index and -f "$dir$dir_index") { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
-d $dir and $dir_index and -f "$dir$dir_index"
-d $dir and $dir_index
MC/DC33%1/3
-d $dir and $dir_index and -f "$dir$dir_index"
-d $dir
$dir_index
-f "$dir$dir_index"
Truth table50%2/4
A and B and C
A= -d $dirB= $dir_indexC= -f "$dir$dir_index"
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | 3 | $dir .= $dir_index; | |||||||||||||||||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 5 | ▶ | if (-f $dir) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | return $self->SUPER::serve_path($env, $dir); | |||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | my $dir_url = $env->{SCRIPT_NAME} . $env->{PATH_INFO}; | |||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | if ($dir_url !~ m{/$}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | return $self->return_dir_redirect($env); | |||||||||||||||||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 2 | my %dir_index_args = ( | |||||||||||||||||||||||||||||||||||||||||
| 37 | dir => $dir, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | dir_url => $dir_url, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ▶ | $dir_index_args{pretty} = $self->pretty if defined $self->pretty; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 2 | ▶ | $dir_index_args{icons} = $self->icons if defined $self->icons; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 2 | my $di = WebServer::DirIndex->new(%dir_index_args); | |||||||||||||||||||||||||||||||||||||||||
| 45 | 2 | my $page = $di->to_html($env->{PATH_INFO}); | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 2 | return [ 200, ['Content-Type' => 'text/html; charset=utf-8'], [ $page ] ]; | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | __END__ | ||||||||||||||||||||||||||||||||||||||||||