| 1 | package Dancer::Renderer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 180 | our $AUTHORITY = 'cpan:SUKRIA'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Rendering class for Dancer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 180 | $Dancer::Renderer::VERSION = '1.3520'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 180 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 180 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 180 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 180 | ▶ | use HTTP::Headers; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 180 | ▶ | use HTTP::Date qw( str2time time2str ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 180 | ▶ | use Dancer::Route; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 180 | ▶ | use Dancer::HTTP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 180 | ▶ | use Dancer::Cookie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 180 | ▶ | use Dancer::Factory::Hook; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 180 | ▶ | use Dancer::Cookies; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 180 | ▶ | use Dancer::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 180 | ▶ | use Dancer::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 180 | ▶ | use Dancer::Serializer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 180 | ▶ | use Dancer::Config 'setting'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 180 | ▶ | use Dancer::FileUtils qw(path path_or_empty dirname read_file_content open_file); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 180 | ▶ | use Dancer::SharedData; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 180 | ▶ | use Dancer::Logger; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 180 | ▶ | use Dancer::MIME; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 180 | ▶ | use Dancer::Exception qw(:all); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 180 | Dancer::Factory::Hook->instance->install_hooks( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | qw/before after before_serializer after_serializer before_file_render after_file_render/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 519 | ▶ | sub render_file { get_file_response() } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | sub render_action { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 514 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_action: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 514 | my $resp = $class->get_action_response(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 469 | ▶ | return (defined $resp) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ? response_with_headers() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | sub render_error { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 32 | ▶ | my ($class, $error_code) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_error: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 32 | my $app = Dancer::App->current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 32 | my $static_file = path($app->setting('public'), "$error_code.html"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 32 | my $response = Dancer::Renderer->get_file_response_for_path( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | $static_file => $error_code); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 32 | ▶ | return $response if $response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 30 | return Dancer::Response->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | status => $error_code, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | headers => ['Content-Type' => 'text/html'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | content => Dancer::Renderer->html_page( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | "Error $error_code" => "<h2>Unable to process your query</h2>" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | . "The page you requested is not available" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | # Takes a response object and add default headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | sub response_with_headers { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 450 | ▶ | my $response = Dancer::SharedData->response(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
response_with_headers: called CC=4 SCAR=14.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 450 | ▶ | if (Dancer::Config::setting('server_tokens')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 450 | ▶ | $response->{headers} ||= HTTP::Headers->new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$response->{"headers"} ||= "HTTP::Headers"->new
MC/DC0%0/2
$response->{"headers"} ||= "HTTP::Headers"->new
$response->{"headers"}
"HTTP::Headers"->new
Truth table33%1/3
A ||= B
A= $response->{"headers"}B= "HTTP::Headers"->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 450 | ▶ | my $powered_by = "Perl Dancer " . ( Dancer->VERSION || '' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
'Dancer'->VERSION || ''
MC/DC0%0/1
'Dancer'->VERSION || ''
'Dancer'->VERSION
Truth table50%1/2
A
A= 'Dancer'->VERSION
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 450 | $response->header('X-Powered-By' => $powered_by); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 450 | $response->header('Server' => $powered_by); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 450 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | sub html_page { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 39 | ▶ | my ($class, $title, $content, $style) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
html_page: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 39 | ▶ | $style ||= 'style'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$style ||= "style"
MC/DC100%1/1
$style ||= "style"
$style
Truth table100%2/2
A
A= $style
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 39 | my $template = $class->templates->{'default'}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 39 | my $ts = Dancer::Template::Simple->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 39 | return $ts->render( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | \$template, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | { title => $title, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | style => $style, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | version => $Dancer::VERSION, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | content => $content | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | sub get_action_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 538 | ▶ | my $class = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_action_response: called CC=14 SCAR=26.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 538 | ▶ | my $depth = shift || 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 1
MC/DC100%1/1
shift() || 1
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | # save the request before the filters are ran | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 538 | my $request = Dancer::SharedData->request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 538 | my ($method, $path) = ($request->method, $request->path_info); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | # look for a matching route handler, for the given request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 538 | my $handler = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | Dancer::App->find_route_through_apps(Dancer::SharedData->request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 538 | ▶ | my $app = ($handler && $handler->app) ? $handler->app : Dancer::App->current(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$handler and $handler->app
MC/DC50%1/2
$handler and $handler->app
$handler
$handler->app
Truth table66%2/3
A and B
A= $handlerB= $handler->app
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | # run the before filters, before "running" the route handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 538 | Dancer::Factory::Hook->instance->execute_hooks('before', $handler); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | # recurse if something has changed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 532 | my $MAX_RECURSIVE_LOOP = 10; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 532 | ▶ | if ( ($path ne Dancer::SharedData->request->path_info) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$path ne "Dancer::SharedData"->request->path_info or $method ne "Dancer::SharedData"->request->method
MC/DC50%1/2
$path ne "Dancer::SharedData"->request->path_info or $method ne "Dancer::SharedData"->request->method
$path ne "Dancer::SharedData"->request->path_info
$method ne "Dancer::SharedData"->request->method
Truth table66%2/3
A or B
A= $path ne "Dancer::SharedData"->request->path_infoB= $method ne "Dancer::SharedData"->request->method
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | || ($method ne Dancer::SharedData->request->method)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 26 | ▶ | if ($depth > $MAX_RECURSIVE_LOOP) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 2 | raise core_renderer => "infinite loop detected, " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | . "check your route/filters for " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | . $method . ' ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | . $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 24 | return $class->get_action_response($depth + 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # redirect immediately - skip route execution | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 506 | my $response = Dancer::SharedData->response(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 506 | ▶ | if (defined $response && (my $status = $response->status)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $response and my $status = $response->status
MC/DC0%0/2
defined $response and my $status = $response->status
defined $response
my $status = $response->status
Truth table33%1/3
A and B
A= defined $responseB= my $status = $response->status
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 506 | ▶ | if ($status == 302 || $status == 301) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$status == 302 or $status == 301
MC/DC50%1/2
$status == 302 or $status == 301
$status == 302
$status == 301
Truth table66%2/3
A or B
A= $status == 302B= $status == 301
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 6 | $class->serialize_response_if_needed(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 6 | Dancer::Factory::Hook->instance->execute_hooks('after', $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 6 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | # execute the action | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 500 | ▶ | if ($handler) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | # a response may exist, produced by a before filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 481 | ▶ | return $class->serialize_response_if_needed() if defined $response && $response->exists; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $response and $response->exists
MC/DC0%0/2
defined $response and $response->exists
defined $response
$response->exists
Truth table33%1/3
A and B
A= defined $responseB= $response->exists
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | # else, get the route handler's response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 481 | Dancer::App->current($handler->{app}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 481 | ▶ | $handler->run($request); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 444 | $class->serialize_response_if_needed(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } continuation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 9 | ▶ | my ($continuation) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | # If we have a Route continuation, run the after hook, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | # propagate the continuation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 9 | my $resp = Dancer::SharedData->response(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 9 | Dancer::Factory::Hook->instance->execute_hooks('after', $resp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 9 | $continuation->rethrow(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 481 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 444 | my $resp = Dancer::SharedData->response(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 444 | Dancer::Factory::Hook->instance->execute_hooks('after', $resp); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 444 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 19 | return undef; # 404 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | sub render_autopage { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 19 | ▶ | return unless Dancer::setting('auto_page'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
render_autopage: called CC=8 SCAR=20.8
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 8 | my $request = Dancer::SharedData->request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 8 | my $path = $request->path_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | # See if we find a matching view for this request, if so, render it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 8 | my $viewpath = $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 8 | $viewpath =~ s{^/}{}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 8 | ▶ | my $view = Dancer::engine('template')->view($viewpath) || ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
Dancer::engine('template')->view($viewpath) || ''
MC/DC100%1/1
Dancer::engine('template')->view($viewpath) || ''
Dancer::engine('template')->view($viewpath)
Truth table100%2/2
A
A= Dancer::engine('template')->view($viewpath)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 8 | ▶ | if ($view && -f $view) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$view and -f $view
MC/DC50%1/2
$view and -f $view
$view
-f $view
Truth table66%2/3
A and B
A= $viewB= -f $view
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | # A view exists for the path requested, go ahead and render it: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | return _autopage_response($viewpath); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | # Try appending "index" and looking again | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 3 | ▶ | $view = Dancer::engine('template')->view( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
Dancer::engine('template')->view(Dancer::FileUtils::path($viewpath, 'index')) || ''
MC/DC100%1/1
Dancer::engine('template')->view(Dancer::FileUtils::path($viewpath, 'index')) || ''
Dancer::engine('template')->view(Dancer::FileUtils::path($viewpath, 'index'))
Truth table100%2/2
A
A= Dancer::engine('template')->view(Dancer::FileUtils::path($viewpath, 'index'))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | Dancer::FileUtils::path($viewpath, 'index') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | )|| ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 3 | Dancer::error("Looking for $viewpath/index - got $view"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 3 | ▶ | if ($view && -f $view) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$view and -f $view
MC/DC50%1/2
$view and -f $view
$view
-f $view
Truth table66%2/3
A and B
A= $viewB= -f $view
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | return _autopage_response( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | Dancer::FileUtils::path($viewpath, 'index') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | sub _autopage_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | ▶ | my $viewpath = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_autopage_response: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 7 | my $response = Dancer::Response->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 7 | $response->status(200); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 7 | $response->content( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | Dancer::template($viewpath) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 7 | $response->header( 'Content-Type' => 'text/html' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 7 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | sub serialize_response_if_needed { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 450 | ▶ | my $response = Dancer::SharedData->response(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
serialize_response_if_needed: called CC=3 SCAR=11.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 450 | ▶ | if (Dancer::App->current->setting('serializer') && $response->content()){ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
"Dancer::App"->current->setting("serializer") and $response->content
MC/DC50%1/2
"Dancer::App"->current->setting("serializer") and $response->content
"Dancer::App"->current->setting("serializer")
$response->content
Truth table66%2/3
A and B
A= "Dancer::App"->current->setting("serializer")B= $response->content
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 30 | Dancer::Factory::Hook->execute_hooks('before_serializer', $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 30 | ▶ | Dancer::Serializer->process_response($response); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } continuation { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | my ($continuation) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | # If we have a Route continuation, run the after hook, then | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | # propagate the continuation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | Dancer::Factory::Hook->execute_hooks('after_serializer', $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $continuation->rethrow(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 30 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 30 | Dancer::Factory::Hook->execute_hooks('after_serializer', $response); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 450 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | sub get_file_response { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 532 | ▶ | my $request = Dancer::SharedData->request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_file_response: called CC=6 SCAR=18.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 532 | my $path_info = $request->path_info; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | # requests that have \0 in path are forbidden | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 532 | ▶ | if ( $path_info =~ /\0/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | _bad_request(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 531 | my $app = Dancer::App->current; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | # TODO: this should be later removed with a check whether the file exists | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # and then returning a 404 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 531 | ▶ | my $public = defined $app->setting('public') ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | $app->setting('public') : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 531 | my $static_file = path( $public, $path_info ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 531 | ▶ | return if ( !$static_file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition60%3/5
not $static_file or index($static_file, path($public) || "") != 0
path($public) || ''
MC/DC50%1/2
not $static_file or index($static_file, path($public) || "") != 0
not $static_file
index($static_file, path($public) || "") != 0
MC/DC0%0/1
path($public) || ''
path($public)
Truth table66%2/3
not(A) or B
A= not $static_fileB= index($static_file, path($public) || "") != 0
Truth table50%1/2
A
A= path($public)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | || index( $static_file, ( path($public) || '' ) ) != 0 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 529 | return Dancer::Renderer->get_file_response_for_path( $static_file, undef, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | $request->content_type ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | sub get_file_response_for_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 563 | ▶ | my ($class, $static_file, $status, $mime) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_file_response_for_path: called CC=9 SCAR=23.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 563 | ▶ | if ( -f $static_file ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 16 | Dancer::Factory::Hook->execute_hooks( 'before_file_render', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | $static_file ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 16 | ▶ | my $response = Dancer::SharedData->response() || Dancer::Response->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
'Dancer::SharedData'->response || 'Dancer::Response'->new
MC/DC0%0/2
'Dancer::SharedData'->response || 'Dancer::Response'->new
'Dancer::SharedData'->response
'Dancer::Response'->new
Truth table33%1/3
A || B
A= 'Dancer::SharedData'->responseB= 'Dancer::Response'->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | # handle If-Modified-Since | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 16 | my $last_modified = (stat $static_file)[9]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 16 | my $since = str2time(Dancer::SharedData->request->env->{HTTP_IF_MODIFIED_SINCE}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 16 | ▶ | if( defined $since && $since >= $last_modified ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $since and $since >= $last_modified
MC/DC0%0/2
defined $since and $since >= $last_modified
defined $since
$since >= $last_modified
Truth table33%1/3
A and B
A= defined $sinceB= $since >= $last_modified
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $response->status( 304 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $response->content( '' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 16 | my $fh = open_file( '<', $static_file ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 16 | binmode $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 16 | ▶ | $response->status($status) if ($status); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 16 | $response->header( 'Last-Modified' => time2str( $last_modified ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 16 | ▶ | $response->header('Content-Type' => (($mime && _get_full_mime_type($mime)) || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition77%7/9
$mime && _get_full_mime_type($mime) || 'Dancer::SharedData'->request->content_type || _get_mime_type($static_file)
$mime and _get_full_mime_type($mime) or "Dancer::SharedData"->request->content_type
$mime and _get_full_mime_type($mime)
MC/DC0%0/4
$mime && _get_full_mime_type($mime) || 'Dancer::SharedData'->request->content_type || _get_mime_type($static_file)
$mime
_get_full_mime_type($mime)
"Dancer::SharedData"->request->content_type
_get_mime_type($static_file)
Truth table42%3/7
A and B or C || D
A= $mimeB= _get_full_mime_type($mime)C= "Dancer::SharedData"->request->content_typeD= _get_mime_type($static_file)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | Dancer::SharedData->request->content_type || | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | _get_mime_type($static_file))); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 16 | $response->content($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 16 | Dancer::Factory::Hook->execute_hooks( 'after_file_render', $response ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 16 | return $response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 547 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | # private | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | sub _get_full_mime_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 1 | ▶ | my $mime = Dancer::MIME->instance(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_full_mime_type: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 1 | return $mime->name_or_type(shift @_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | sub _get_mime_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 14 | ▶ | my $file = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_mime_type: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 14 | my $mime = Dancer::MIME->instance(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 14 | return $mime->for_file($file); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | sub _bad_request{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 1 | ▶ | my $response = Dancer::SharedData->response() || Dancer::Response->new(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bad_request: called CC=2 SCAR=7.6
Condition33%1/3
'Dancer::SharedData'->response || 'Dancer::Response'->new
MC/DC0%0/2
'Dancer::SharedData'->response || 'Dancer::Response'->new
'Dancer::SharedData'->response
'Dancer::Response'->new
Truth table33%1/3
A || B
A= 'Dancer::SharedData'->responseB= 'Dancer::Response'->new
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 1 | $response->status(400); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 1 | $response->content('Bad Request'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | # set of builtin templates needed by Dancer when rendering HTML pages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | sub templates { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 39 | ▶ | my $charset = setting('charset') || 'UTF-8'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
templates: called CC=2 SCAR=7.2
Pod
undocumented
Condition50%1/2
setting('charset') || 'UTF-8'
MC/DC0%0/1
setting('charset') || 'UTF-8'
setting('charset')
Truth table50%1/2
A
A= setting('charset')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 39 | { default => | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | <html> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | <head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | <title><% title %></title> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | <link rel="stylesheet" href="/css/<% style %>.css" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | <meta http-equiv="Content-type" content="text/html; charset=' . $charset | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | . '" /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | </head> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | <body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | <h1><% title %></h1> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | <div id="content"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | <% content %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | <div id="footer"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | Powered by <a href="http://perldancer.org/">Dancer</a> <% version %> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | </body> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | </html>', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 180 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||