| 1 | package Mojolicious::Plugin::StaticShare::Controller; | ||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use Mojo::Base 'Mojolicious::Controller'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Mojo::File qw(path); | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use HTTP::AcceptLanguage; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Mojo::Path; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Mojo::Util qw ( decode encode url_unescape xml_escape);# | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Time::Piece;# module replaces the standard localtime and gmtime functions with implementations that return objects | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 8 | #~ use Mojo::Asset::File; | ||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | has plugin => sub { shift->stash('plugin') }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | has public_uploads => sub { shift->plugin->public_uploads }; | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | has is_admin => sub { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | $c->plugin->is_admin($c); | |||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: called CC=11 SCAR=37.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | $c->_stash(); | |||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||
| 22 | return $c->not_found | ||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 0 | ▶ | if !$c->is_admin && grep {/^\./} @{$c->stash('url_path')->parts}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $c->is_admin and grep {/^\./u;} @{$c->stash("url_path")->parts;}
MC/DC0%0/2
not $c->is_admin and grep {/^\./u;} @{$c->stash("url_path")->parts;}
not $c->is_admin
grep {/^\./u;} @{$c->stash("url_path")->parts;}
Truth table33%1/3
not(A) and B
A= not $c->is_adminB= grep {/^\./u;} @{$c->stash("url_path")->parts;}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | if ($c->plugin->access) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | ▶ | my $access = ref $c->plugin->access eq 'CODE' ? $c->plugin->access->($c) : $c->plugin->access; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | return $c->not_found | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 29 | unless $access; | ||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | return $c->render(%$access) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 32 | if ref $access eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | if ($c->is_admin && $c->param('admin')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$c->is_admin and $c->param("admin")
MC/DC0%0/2
$c->is_admin and $c->param("admin")
$c->is_admin
$c->param("admin")
Truth table33%1/3
A and B
A= $c->is_adminB= $c->param("admin")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 36 | # Temporary Redirect | ||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | $c->res->code(307); | |||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | return $c->redirect_to($c->req->url->to_abs->path); | |||||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 1 | my $file_path = $c->stash('file_path'); | |||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | return $c->dir($file_path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | if -d $file_path; | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | return $c->file($file_path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | if -f $file_path; | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 0 | $c->not_found; | |||||||||||||||||||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub post { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
post: not called CC=29 SCAR=67.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $c->_stash(); | |||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | my $file_path = $c->stash('file_path'); | |||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | my $url_path = $c->stash('url_path'); | |||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | $c->app->log->debug($file_path, $url_path->to_route, $c->dumper($c->req->params->to_hash)) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | if $c->plugin->debug; | ||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | if (my $dir = $c->param('dir')) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return $c->new_dir($file_path, $dir) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | if $c->is_admin; | ||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return $c->render(json=>{error=>$c->i18n('you cant create dir')}); | |||||||||||||||||||||||||||||||||||||||||||||
| 65 | } elsif (my $rename = $c->param('rename')) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | return $c->rename($file_path, $rename) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 67 | if $c->is_admin; | ||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return $c->render(json=>{error=>$c->i18n('you cant rename')}); | |||||||||||||||||||||||||||||||||||||||||||||
| 69 | ▶ | } elsif (my $delete = $c->param('delete[]') && $c->every_param('delete[]')) { | |||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$c->param('delete[]') && $c->every_param('delete[]')
MC/DC0%0/2
$c->param('delete[]') && $c->every_param('delete[]')
$c->param('delete[]')
$c->every_param('delete[]')
Truth table0%0/3
A && B
A= $c->param('delete[]')B= $c->every_param('delete[]')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | ▶ | return $c->delete($file_path, $delete) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 71 | if $c->is_admin; | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return $c->render(json=>{error=>$c->i18n('you cant delete')}); | |||||||||||||||||||||||||||||||||||||||||||||
| 73 | } elsif (defined (my $edit = $c->param('edit'))) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | return $c->_edit($file_path, $edit) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 75 | if $c->is_admin; | ||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | return $c->render(json=>{error=>$c->i18n('you cant edit')}); | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | return $c->render(json=>{error=>$c->i18n('target directory not found')}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | if !$c->is_admin && grep {/^\./} @{$c->stash('url_path')->parts}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $c->is_admin and grep {/^\./u;} @{$c->stash("url_path")->parts;}
MC/DC0%0/2
not $c->is_admin and grep {/^\./u;} @{$c->stash("url_path")->parts;}
not $c->is_admin
grep {/^\./u;} @{$c->stash("url_path")->parts;}
Truth table0%0/3
not(A) and B
A= not $c->is_adminB= grep {/^\./u;} @{$c->stash("url_path")->parts;}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('you cant upload')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->is_admin or $c->public_uploads
MC/DC0%0/2
$c->is_admin or $c->public_uploads
$c->is_admin
$c->public_uploads
Truth table0%0/3
A or B
A= $c->is_adminB= $c->public_uploads
| |||||||||||||||||||||||||||||||||||||||||||||||
| 83 | unless $c->is_admin || $c->public_uploads; | ||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | my $name = url_unescape($c->param('name') || '');#$file->filename | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$c->param('name') || ''
MC/DC0%0/1
$c->param('name') || ''
$c->param('name')
Truth table0%0/2
A
A= $c->param('name')
| |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | utf8::upgrade($name); | |||||||||||||||||||||||||||||||||||||||||||||
| 87 | #~ return $c->render(json=>{error=>$c->i18n('Provide the name of upload file')}) | ||||||||||||||||||||||||||||||||||||||||||||||
| 88 | #~ unless $name =~ /\S/i; | ||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('Cant open target directory')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $name or -w $file_path
MC/DC0%0/2
not $name or -w $file_path
not $name
-w $file_path
Truth table0%0/3
not(A) or B
A= not $nameB= -w $file_path
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | unless !$name || -w $file_path; | ||||||||||||||||||||||||||||||||||||||||||||||
| 92 | #~ $c->req->max_message_size(0); | ||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # Check file size | ||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('upload is too big')}, status=>417) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 95 | if $c->req->is_limit_exceeded; | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | ▶ | my $file = $c->req->upload('file') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 98 | or return $c->render(json=>{error=>$c->i18n('Where is your upload file?')}); | ||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | ▶ | my $to = $name ? $file_path->child($name) : $file_path; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('path is not a directory')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $name or -d $file_path
MC/DC0%0/2
not $name or -d $file_path
not $name
-d $file_path
Truth table0%0/3
not(A) or B
A= not $nameB= -d $file_path
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | unless !$name || -d $file_path; | ||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('path is a directory')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $name and -d $to
MC/DC0%0/2
not $name and -d $to
not $name
-d $to
Truth table0%0/3
not(A) and B
A= not $nameB= -d $to
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | if !$name && -d $to; | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('file already exists')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $c->param("replace") and -e $to
MC/DC0%0/2
not $c->param("replace") and -e $to
not $c->param("replace")
-e $to
Truth table0%0/3
not(A) and B
A= not $c->param("replace")B= -e $to
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | if !$c->param('replace') && -e $to; | ||||||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | eval { $file->asset->move_to($to) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | or return $c->render(json=>{error=>$@ =~ /(.+) at /}); | ||||||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $url_path->merge($name) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | if $name; | ||||||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $c->render(json=>{ok=> $url_path->trailing_slash(0)->to_route}); | |||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # TODO DELETE request | ||||||||||||||||||||||||||||||||||||||||||||||
| 121 | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||||
| 122 | my ($c) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||
| 123 | $c->_stash(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | my $file_path = $c->stash('file_path'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 126 | my $url_path = $c->stash('url_path'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $c->app->log->debug($file_path, $url_path->to_route, $c->dumper($c->req->params->to_hash)) | ||||||||||||||||||||||||||||||||||||||||||||||
| 129 | if $c->plugin->debug; | ||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | sub _stash { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stash: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 1 | my ($c) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 1 | ▶ | my $lang = HTTP::AcceptLanguage->new($c->req->headers->accept_language || 'en;q=0.5'); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$c->req->headers->accept_language || 'en;q=0.5'
MC/DC0%0/1
$c->req->headers->accept_language || 'en;q=0.5'
$c->req->headers->accept_language
Truth table50%1/2
A
A= $c->req->headers->accept_language
| |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | $c->stash('language' => $lang); | |||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 1 | my $pth = Mojo::Path->new($c->stash('pth'))->leading_slash(0)->trailing_slash(0); | |||||||||||||||||||||||||||||||||||||||||||||
| 140 | 1 | ▶ | $pth = $pth->trailing_slash(1)->merge('.'.$c->stash('format')) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 141 | if $c->stash('format'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | $c->stash('pth' => $pth); | |||||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | my $url_path = $c->plugin->root_url->clone->merge($pth)->trailing_slash(1); | |||||||||||||||||||||||||||||||||||||||||||||
| 144 | 1 | $c->stash('url_path' => $url_path); | |||||||||||||||||||||||||||||||||||||||||||||
| 145 | #~ $c->stash('file_path' => $c->plugin->root_dir->clone->merge($c->stash('pth'))); | ||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 1 | $c->stash('file_path' => path(decode('UTF-8', url_unescape($c->plugin->root_dir->clone->merge($pth))))); | |||||||||||||||||||||||||||||||||||||||||||||
| 147 | 1 | $c->stash('title' => $c->i18n('Share')." ".$url_path->to_route); | |||||||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | ▶ | sub dir { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dir: called CC=28 SCAR=41.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 1 | my ($c, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 1 | ▶ | return $c->not_found | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$c->plugin->render_dir // ""
MC/DC0%0/1
$c->plugin->render_dir // ""
$c->plugin->render_dir
Truth table50%1/2
A
A= $c->plugin->render_dir
| |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | if ($c->plugin->render_dir // '') eq 0; | ||||||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | my $ex = Mojo::Exception->new($c->i18n(qq{Cant open directory})); | |||||||||||||||||||||||||||||||||||||||||||||
| 158 | 1 | ▶ | opendir(my $dir, $path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex) || $c->reply->exception($ex)
MC/DC0%0/2
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex) || $c->reply->exception($ex)
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex)
$c->reply->exception($ex)
Truth table0%0/3
A || B
A= $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex)B= $c->reply->exception($ex)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 159 | or return $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', format=>'html', handler=>'ep', status=>500, exception=>$ex) | ||||||||||||||||||||||||||||||||||||||||||||||
| 160 | || $c->reply->exception($ex); | ||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 1 | my $files = $c->stash('files' => [])->stash('files'); | |||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | my $dirs = $c->stash('dirs' => [])->stash('dirs'); | |||||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 1 | ▶ | while (readdir $dir) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | next | ||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 16 | ▶ | if $_ eq '.' || $_ eq '..'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$_ eq "." or $_ eq ".."
MC/DC100%2/2
$_ eq "." or $_ eq ".."
$_ eq "."
$_ eq ".."
Truth table100%3/3
A or B
A= $_ eq "."B= $_ eq ".."
| |||||||||||||||||||||||||||||||||||||||||||||||
| 168 | next | ||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 14 | ▶ | if !$c->is_admin && /^\./; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $c->is_admin and /^\./u
MC/DC0%0/2
not $c->is_admin and /^\./u
not $c->is_admin
/^\./u
Truth table33%1/3
not(A) and B
A= not $c->is_adminB= /^\./u
| |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 14 | my $child = $path->child(decode('UTF-8', $_)); | |||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 14 | ▶ | push @$dirs, decode('UTF-8', $_) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition71%5/7
-d $child && -r _ && (push(@$dirs, decode('UTF-8', $_)) && (next))
-d $child and -r _
push @$dirs, decode("UTF-8", $_) and next
MC/DC0%0/3
-d $child && -r _ && (push(@$dirs, decode('UTF-8', $_)) && (next))
-d $child
-r _
push @$dirs, decode("UTF-8", $_)
Truth table25%1/4
A and B && C
A= -d $childB= -r _C= push @$dirs, decode("UTF-8", $_)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | and next | ||||||||||||||||||||||||||||||||||||||||||||||
| 175 | if -d $child && -r _; | ||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | next | ||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 10 | ▶ | unless -f _; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 10 | my @stat = stat $child; | |||||||||||||||||||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | ▶ | push @$files, { | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$stat[7] || 0
MC/DC100%1/1
$stat[7] || 0
$stat[7]
Truth table100%2/2
A
A= $stat[7]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 183 | name => decode('UTF-8', $_), | ||||||||||||||||||||||||||||||||||||||||||||||
| 184 | size => $stat[7] || 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| 185 | #~ type => $c->plugin->mime->type( (/\.([0-9a-zA-Z]+)$/)[0] || 'txt' ) || 'application/octet-stream', | ||||||||||||||||||||||||||||||||||||||||||||||
| 186 | mtime => decode('UTF-8', localtime( $stat[9] )->strftime), #->to_datetime, #to_string(), | ||||||||||||||||||||||||||||||||||||||||||||||
| 187 | #~ mode=> $stat[2] & 07777, #-r _, | ||||||||||||||||||||||||||||||||||||||||||||||
| 188 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 1 | closedir $dir; | |||||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 1 | ▶ | for my $index ($c->plugin->dir_index ? @{$c->plugin->dir_index} : ()) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | my $file = $path->child($index); | |||||||||||||||||||||||||||||||||||||||||||||
| 194 | next | ||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | ▶ | unless -f $file; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 1 | ▶ | $c->_stash_markdown($file) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition14%1/7
$index =~ $c->plugin->re_markdown && ($c->_stash_markdown($file) && $c->stash('index', $index) && (last))
$c->_stash_markdown($file) and $c->stash("index", $index) and last
$c->_stash_markdown($file) and $c->stash("index", $index)
MC/DC0%0/3
$index =~ $c->plugin->re_markdown && ($c->_stash_markdown($file) && $c->stash('index', $index) && (last))
$index =~ $c->plugin->re_markdown
$c->_stash_markdown($file)
$c->stash("index", $index)
Truth table0%0/4
A && B and C
A= $index =~ $c->plugin->re_markdownB= $c->_stash_markdown($file)C= $c->stash("index", $index)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 198 | and $c->stash(index=>$index) | ||||||||||||||||||||||||||||||||||||||||||||||
| 199 | and last | ||||||||||||||||||||||||||||||||||||||||||||||
| 200 | if $index =~ $c->plugin->re_markdown; | ||||||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 1 | ▶ | $c->_stash_pod($file) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition42%3/7
$index =~ $c->plugin->re_pod && ($c->_stash_pod($file) && $c->stash('index', $index) && (last))
$c->_stash_pod($file) and $c->stash("index", $index) and last
$c->_stash_pod($file) and $c->stash("index", $index)
MC/DC0%0/3
$index =~ $c->plugin->re_pod && ($c->_stash_pod($file) && $c->stash('index', $index) && (last))
$index =~ $c->plugin->re_pod
$c->_stash_pod($file)
$c->stash("index", $index)
Truth table0%0/4
A && B and C
A= $index =~ $c->plugin->re_podB= $c->_stash_pod($file)C= $c->stash("index", $index)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 203 | and $c->stash(index=>$index) | ||||||||||||||||||||||||||||||||||||||||||||||
| 204 | and last | ||||||||||||||||||||||||||||||||||||||||||||||
| 205 | if $index =~ $c->plugin->re_pod; | ||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | return $c->render(ref $c->plugin->render_dir ? %{$c->plugin->render_dir} : $c->plugin->render_dir,) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | if $c->plugin->render_dir; | ||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | $c->render_maybe("Mojolicious-Plugin-StaticShare/$_/dir", format=>'html', handler=>'ep',) | ||||||||||||||||||||||||||||||||||||||||||||||
| 213 | and return | ||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | ▶ | for $c->stash('language')->languages; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 1 | return $c->render('Mojolicious-Plugin-StaticShare/dir', format=>'html', handler=>'ep',); | |||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | #~ $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', format=>'html', handler=>'ep', status=>500,exception=>Mojo::Exception->new(qq{Template rendering for dir content not found})) | ||||||||||||||||||||||||||||||||||||||||||||||
| 220 | #~ or $c->reply->exception(); | ||||||||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub new_dir { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_dir: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | my ($c, $path, $dir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 0 | my $edir = url_unescape($dir); | |||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | utf8::upgrade($edir); | |||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('provide the name of new directory')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 230 | unless $edir =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my $to = $path->child($edir);# | |||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('dir or file exists')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | if -e $to; | ||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $to->make_path; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | $c->render(json=>{ok=> $c->stash('url_path')->clone->merge($dir)->trailing_slash(1)->to_route}); | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||
| 241 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | ▶ | sub rename { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rename: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my ($c, $path, $rename) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my $ename = url_unescape($rename); | |||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | utf8::upgrade($ename); | |||||||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('provide new name')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | unless $ename =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my $to = $path->sibling($ename); | |||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | return $c->render(json=>{error=>$c->i18n('dir or file exists')}) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | if -e $to; | ||||||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | ▶ | my $move = eval { $path->move_to($to) } | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | or return $c->render(json=>{error=>$@ =~ /(.+) at /}); | ||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $c->render(json=>{ok=> $c->stash('url_path')->trailing_slash(0)->to_dir->merge($rename)->to_route}); | |||||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | ▶ | sub delete { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my ($c, $path, $delete) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my @delete = (); | |||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | for (@$delete) { | |||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $del = url_unescape($_); | |||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | utf8::upgrade($del); | |||||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | push @delete, $c->i18n('provide the name of deleted dir') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$del =~ /\S/u || push(@delete, $c->i18n('provide the name of deleted dir')) && (next)
push @delete, $c->i18n("provide the name of deleted dir") and next
MC/DC0%0/2
$del =~ /\S/u || push(@delete, $c->i18n('provide the name of deleted dir')) && (next)
$del =~ /\S/u
push @delete, $c->i18n("provide the name of deleted dir")
Truth table0%0/3
A || B
A= $del =~ /\S/uB= push @delete, $c->i18n("provide the name of deleted dir")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 271 | and next | ||||||||||||||||||||||||||||||||||||||||||||||
| 272 | unless $del =~ /\S/; | ||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | my $d = $path->sibling($del); | |||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | push @delete, $c->i18n('dir or file does not exists') | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
-e $d || push(@delete, $c->i18n('dir or file does not exists')) && (next)
push @delete, $c->i18n("dir or file does not exists") and next
MC/DC0%0/2
-e $d || push(@delete, $c->i18n('dir or file does not exists')) && (next)
-e $d
push @delete, $c->i18n("dir or file does not exists")
Truth table0%0/3
A || B
A= -e $dB= push @delete, $c->i18n("dir or file does not exists")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | and next | ||||||||||||||||||||||||||||||||||||||||||||||
| 276 | unless -e $d; | ||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | push @delete, eval {$d->remove_tree()} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $c->render(json=>{ok=>\@delete}); | |||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | ▶ | sub file { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
file: not called CC=19 SCAR=59.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my ($c, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 0 | my $ex = Mojo::Exception->new($c->i18n(qq{Permission denied})); | |||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | return $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', format=>'html', handler=>'ep', status=>500,exception=>$ex) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex) || $c->reply->exception($ex)
MC/DC0%0/2
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex) || $c->reply->exception($ex)
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex)
$c->reply->exception($ex)
Truth table0%0/3
A || B
A= $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex)B= $c->reply->exception($ex)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 288 | || $c->reply->exception($ex) | ||||||||||||||||||||||||||||||||||||||||||||||
| 289 | unless -r $path; | ||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | return $c->_edit($path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->is_admin and $c->param("edit")
MC/DC0%0/2
$c->is_admin and $c->param("edit")
$c->is_admin
$c->param("edit")
Truth table0%0/3
A and B
A= $c->is_adminB= $c->param("edit")
| |||||||||||||||||||||||||||||||||||||||||||||||
| 292 | if $c->is_admin && $c->param('edit'); | ||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $filename = $path->basename; | |||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return $c->_markdown($path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
($c->plugin->render_markdown || "") eq 0 or $c->param("attachment") or not $filename =~ $c->plugin->re_markdown
($c->plugin->render_markdown || "") eq 0 or $c->param("attachment")
$c->plugin->render_markdown || ''
MC/DC0%0/3
($c->plugin->render_markdown || "") eq 0 or $c->param("attachment") or not $filename =~ $c->plugin->re_markdown
$c->plugin->render_markdown
$c->param("attachment")
not $filename =~ $c->plugin->re_markdown
Truth table0%0/4
A or B or not(C)
A= $c->plugin->render_markdownB= $c->param("attachment")C= not $filename =~ $c->plugin->re_markdown
| |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | unless ($c->plugin->render_markdown || '') eq 0 || $c->param('attachment') || $filename !~ $c->plugin->re_markdown; | ||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | return $c->_pod($path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/8
($c->plugin->render_pod || "") eq 0 or $c->param("attachment") or not $filename =~ $c->plugin->re_pod
($c->plugin->render_pod || "") eq 0 or $c->param("attachment")
$c->plugin->render_pod || ''
MC/DC0%0/3
($c->plugin->render_pod || "") eq 0 or $c->param("attachment") or not $filename =~ $c->plugin->re_pod
$c->plugin->render_pod
$c->param("attachment")
not $filename =~ $c->plugin->re_pod
Truth table0%0/4
A or B or not(C)
A= $c->plugin->render_podB= $c->param("attachment")C= not $filename =~ $c->plugin->re_pod
| |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | unless ($c->plugin->render_pod || '') eq 0 || $c->param('attachment') || $filename !~ $c->plugin->re_pod; | ||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | ▶ | my $asset = $c->_html($path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->param("attachment") or not $filename =~ $c->plugin->re_html
MC/DC0%0/2
$c->param("attachment") or not $filename =~ $c->plugin->re_html
$c->param("attachment")
not $filename =~ $c->plugin->re_html
Truth table0%0/3
A or not(B)
A= $c->param("attachment")B= not $filename =~ $c->plugin->re_html
| |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | unless $c->param('attachment') || $filename !~ $c->plugin->re_html; | ||||||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | $c->res->headers->content_disposition($c->param('attachment') ? "attachment; filename=$filename;" : "inline"); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | my $type =$c->plugin->mime->type( ( $path =~ /\.([0-9a-zA-Z]+)$/)[0] || 'txt' ) || $c->plugin->mime->type('txt');#'application/octet-stream'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$c->plugin->mime->type(($path =~ /\.([0-9a-zA-Z]+)$/u)[0] || 'txt') || $c->plugin->mime->type('txt')
($path =~ /\.([0-9a-zA-Z]+)$/u)[0] || 'txt'
MC/DC0%0/2
$c->plugin->mime->type(($path =~ /\.([0-9a-zA-Z]+)$/u)[0] || 'txt') || $c->plugin->mime->type('txt')
$c->plugin->mime->type(($path =~ /\.([0-9a-zA-Z]+)$/u)[0] || 'txt')
$c->plugin->mime->type('txt')
MC/DC0%0/1
($path =~ /\.([0-9a-zA-Z]+)$/u)[0] || 'txt'
($path =~ /\.([0-9a-zA-Z]+)$/u)[0]
Truth table0%0/3
A || B
A= $c->plugin->mime->type(($path =~ /\.([0-9a-zA-Z]+)$/u)[0] || 'txt')B= $c->plugin->mime->type('txt')
Truth table0%0/2
A
A= ($path =~ /\.([0-9a-zA-Z]+)$/u)[0]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $c->res->headers->content_type($type); | |||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | $c->reply->asset($asset || Mojo::Asset::File->new(path => $path)); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$asset || 'Mojo::Asset::File'->new('path', $path)
MC/DC0%0/2
$asset || 'Mojo::Asset::File'->new('path', $path)
$asset
'Mojo::Asset::File'->new('path', $path)
Truth table0%0/3
A || B
A= $assetB= 'Mojo::Asset::File'->new('path', $path)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | ▶ | sub _html {# disable scripts inside html | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_html: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | my ($c, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | my $file = Mojo::Asset::File->new(path => $path); | |||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my $content = $file->slurp; | |||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | my $dom = Mojo::DOM->new($content); | |||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | $dom->find('script')->each(\&_sanitize_script)->size | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | or return $file; | ||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | my $asset = Mojo::Asset::Memory->new; | |||||||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $asset->add_chunk($dom)->mtime($file->mtime); | |||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return $asset; | |||||||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | sub _markdown {# file | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_markdown: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my ($c, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | my $ex = Mojo::Exception->new($c->i18n(qq{Please install or verify markdown module (default to Text::Markdown::Hoedown) with markdown(\$str) sub or parse(\$str) method})); | |||||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | $c->_stash_markdown($path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex) || $c->reply->exception($ex)
MC/DC0%0/2
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex) || $c->reply->exception($ex)
$c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex)
$c->reply->exception($ex)
Truth table0%0/3
A || B
A= $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', 'format', 'html', 'handler', 'ep', 'status', 500, 'exception', $ex)B= $c->reply->exception($ex)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | or return $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', format=>'html', handler=>'ep', status=>500,exception=>$ex) | ||||||||||||||||||||||||||||||||||||||||||||||
| 331 | || $c->reply->exception($ex); | ||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | return $c->plugin->render_markdown | ||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | ? $c->render(ref $c->plugin->render_markdown ? %{$c->plugin->render_markdown} : $c->plugin->render_markdown,) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | : $c->render('Mojolicious-Plugin-StaticShare/markdown', format=>'html', handler=>'ep',); | ||||||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 1 | my $layout_re = qr|^(?:\s*%+\s*layouts/(.+)[;\s]+)|; | |||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | sub _stash_markdown { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stash_markdown: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | my ($c, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | my $md = $c->plugin->markdown | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 343 | or return; # not installed | ||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $content = decode('UTF-8', $path->slurp); | |||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $content =~ s|$layout_re|$c->_layout_index($1)|e;#) {# || $content =~ s/(?:%\s*layout\s+"([^"]+)";?)//m | |||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | my $dom = Mojo::DOM->new($md->parse($content)); | |||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $dom->find('script')->each(\&_sanitize_script); | |||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | $dom->find('*')->each(\&_dom_attrs); | |||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | ▶ | $c->stash(markdown => $dom->at('body') || $dom); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$dom->at('body') || $dom
MC/DC0%0/2
$dom->at('body') || $dom
$dom->at('body')
$dom
Truth table0%0/3
A || B
A= $dom->at('body')B= $dom
| |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | #~ my $filename = $path->basename; | ||||||||||||||||||||||||||||||||||||||||||||||
| 351 | #~ $c->stash('title'=>$filename); | ||||||||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | my $layout_ext_re = qr|\.([^/\.;\s]+)?\.?([^/\.;\s]+)?$|; # .html.ep | |||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | ▶ | sub _layout_index {# from regexp execute | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_layout_index: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | my ($c, @match) = @_;# | |||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | $match[0] =~ s|[;\s]+$||; | |||||||||||||||||||||||||||||||||||||||||||||
| 359 | #~ utf8::encode($match[0]); | ||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | push @match, $1, $2 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | if $match[0] =~ s|$layout_ext_re||; | ||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | my $found = $c->app->renderer->template_path({ | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$match[1] || 'html'
$match[2] || 'ep'
MC/DC0%0/1
$match[1] || 'html'
$match[1]
MC/DC0%0/1
$match[2] || 'ep'
$match[2]
Truth table0%0/2
A
A= $match[1]
Truth table0%0/2
A
A= $match[2]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 363 | template => "layouts/$match[0]", | ||||||||||||||||||||||||||||||||||||||||||||||
| 364 | format => $match[1] || 'html', | ||||||||||||||||||||||||||||||||||||||||||||||
| 365 | handler => $match[2] || 'ep', | ||||||||||||||||||||||||||||||||||||||||||||||
| 366 | }); | ||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | ▶ | $c->layout($match[0])#encode('UTF-8', $match[0])) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
$found && ($c->layout($match[0]) && (return ''))
$c->layout($match[0]) and return ""
MC/DC0%0/2
$found && ($c->layout($match[0]) && (return ''))
$found
$c->layout($match[0])
Truth table0%0/3
A && B
A= $foundB= $c->layout($match[0])
| |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | and return '' | ||||||||||||||||||||||||||||||||||||||||||||||
| 369 | if $found; | ||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $err = "layout [$match[0]].$match[1].$match[2] not found"; | |||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $c->app->log->error("$err", "\t app->renderer->paths: ", @{$c->app->renderer->paths}); | |||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | return "<div style='color:red;'>$err</div>"; | |||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | sub _sanitize_script {# for markdown | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_sanitize_script: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | my $el = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $text = xml_escape $el->text; | |||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | $el->replace("<code class=script>$text</code>"); | |||||||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 162 | ▶ | sub _dom_attrs {# for markdown | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dom_attrs: called CC=9 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 382 | # translate ^{...} to id, style, class attributes | ||||||||||||||||||||||||||||||||||||||||||||||
| 383 | # берем только первый child и он должен быть текстом | ||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 162 | my $el = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 385 | 162 | ▶ | my $text = $el->text | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | or return; | ||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 144 | my $child1 = $el->child_nodes->first; | |||||||||||||||||||||||||||||||||||||||||||||
| 388 | 144 | my $parent = $child1->parent; | |||||||||||||||||||||||||||||||||||||||||||||
| 389 | return | ||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 144 | ▶ | unless $parent && $parent->type eq 'tag' && $child1->type eq 'text'; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$parent and $parent->type eq "tag" and $child1->type eq "text"
$parent and $parent->type eq "tag"
MC/DC33%1/3
$parent and $parent->type eq "tag" and $child1->type eq "text"
$parent
$parent->type eq "tag"
$child1->type eq "text"
Truth table50%2/4
A and B and C
A= $parentB= $parent->type eq "tag"C= $child1->type eq "text"
| |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 141 | my $content = $child1->content; | |||||||||||||||||||||||||||||||||||||||||||||
| 392 | 141 | ▶ | if ($content =~ s|^(?:\s*\{([^\}]+)\}\s*)||) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | my $attrs = $1; | |||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | utf8::upgrade($attrs); | |||||||||||||||||||||||||||||||||||||||||||||
| 395 | # styles | ||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | ▶ | $parent->{style} .= " $1" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | while $attrs =~ s|(\S+\s*:\s*[^;]+;)||; | ||||||||||||||||||||||||||||||||||||||||||||||
| 398 | # id | ||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | ▶ | $parent->{id} = $1 | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | while $attrs =~ s|#(\S+)||; | ||||||||||||||||||||||||||||||||||||||||||||||
| 401 | # classes | ||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | $parent->{class} .= " $1" | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | while $attrs =~ s|\.?([^\.\s]+)||; | ||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $child1->content($content);# replace | |||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | sub _pod {# file | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_pod: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my ($c, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $c->_stash_pod($path) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | or return;# $c->render_maybe('Mojolicious-Plugin-StaticShare/exception', format=>'html', handler=>'ep', status=>500,exception=>$ex) | ||||||||||||||||||||||||||||||||||||||||||||||
| 413 | #~ || $c->reply->exception($ex); | ||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||
| 415 | return $c->plugin->render_pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | ? $c->render(ref $c->plugin->render_pod ? %{$c->plugin->render_pod} : $c->plugin->render_pod,) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | : $c->render('Mojolicious-Plugin-StaticShare/pod', format=>'html', handler=>'ep',); | ||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 1 | ▶ | sub _stash_pod { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stash_pod: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 1 | my ($c, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 423 | return | ||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 1 | ▶ | unless $c->app->renderer->helpers->{'pod_to_html'}; | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | my $content = decode('UTF-8', $path->slurp); | |||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $content =~ s|$layout_re|$c->_layout_index($1)|e;#) {# || $content =~ s/(?:%\s*layout\s+"([^"]+)";?)//m | |||||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | my $dom = Mojo::DOM->new($c->pod_to_html($content)); | |||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | $dom->find('script')->each(\&_sanitize_script); | |||||||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | $dom->find('*')->each(\&_dom_attrs); | |||||||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | ▶ | $c->stash(pod => $dom->at('body') || $dom); | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$dom->at('body') || $dom
MC/DC0%0/2
$dom->at('body') || $dom
$dom->at('body')
$dom
Truth table33%1/3
A || B
A= $dom->at('body')B= $dom
| |||||||||||||||||||||||||||||||||||||||||||||||
| 432 | #~ my $filename = $path->basename; | ||||||||||||||||||||||||||||||||||||||||||||||
| 433 | #~ $c->stash('title'=>$filename); | ||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | sub not_found { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
not_found: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | my $c = shift; | |||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | $c->render_maybe('Mojolicious-Plugin-StaticShare/not_found', format=>'html', handler=>'ep', status=>404,) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | or $c->reply->not_found; | ||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | }; | ||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | sub _edit { | ||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_edit: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my ($c, $path, $edit) = @_; | |||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | unless (defined $edit) {# get | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $c->stash('edit'=> decode('UTF-8', $path->slurp)); | |||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | $c->stash('title' => $c->i18n('Edit')." ".$c->stash('url_path')->to_route); | |||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | return $c->render('Mojolicious-Plugin-StaticShare/edit', format=>'html', handler=>'ep',); | |||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # save | ||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | $path->spurt(encode('UTF-8', $edit)); | |||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | $c->render(json=>{ok=>$path->to_string}); | |||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||
| 458 | =pod | ||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | =encoding utf8 | ||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | Доброго всем | ||||||||||||||||||||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | =head1 Mojolicious::Plugin::StaticShare::Controller | ||||||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||||||
| 466 | ¡ ¡ ¡ ALL GLORY TO GLORIA ! ! ! | ||||||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | Mojolicious::Plugin::StaticShare::Controller - is an internal controller for L<Mojolicious::Plugin::StaticShare>. | ||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||