line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::App::File::PYX; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
114408
|
use base qw(Plack::App::File); |
|
3
|
|
|
|
|
15
|
|
|
3
|
|
|
|
|
1354
|
|
4
|
3
|
|
|
3
|
|
53870
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
52
|
|
5
|
3
|
|
|
3
|
|
12
|
use warnings; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
67
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
1355
|
use Encode qw(encode); |
|
3
|
|
|
|
|
37816
|
|
|
3
|
|
|
|
|
210
|
|
8
|
3
|
|
|
3
|
|
1136
|
use English; |
|
3
|
|
|
|
|
6218
|
|
|
3
|
|
|
|
|
16
|
|
9
|
3
|
|
|
3
|
|
1891
|
use Error::Pure qw(err); |
|
3
|
|
|
|
|
12569
|
|
|
3
|
|
|
|
|
76
|
|
10
|
3
|
|
|
3
|
|
114
|
use HTTP::Date; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
150
|
|
11
|
3
|
|
|
3
|
|
18
|
use Plack::Util::Accessor qw(indent); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
24
|
|
12
|
3
|
|
|
3
|
|
1558
|
use PYX::SGML::Tags; |
|
3
|
|
|
|
|
74362
|
|
|
3
|
|
|
|
|
93
|
|
13
|
3
|
|
|
3
|
|
26
|
use Tags::Output::Raw; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
57
|
|
14
|
3
|
|
|
3
|
|
1177
|
use Unicode::UTF8 qw(encode_utf8); |
|
3
|
|
|
|
|
1261
|
|
|
3
|
|
|
|
|
1170
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
our $VERSION = 0.01; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub serve_path { |
19
|
7
|
|
|
7
|
1
|
35298
|
my ($self, $env, $file) = @_; |
20
|
|
|
|
|
|
|
|
21
|
7
|
|
50
|
|
|
22
|
my $encoding = $self->encoding || 'utf-8'; |
22
|
|
|
|
|
|
|
|
23
|
7
|
|
50
|
|
|
75
|
my $content_type = $self->content_type || 'text/html'; |
24
|
7
|
50
|
|
|
|
42
|
if (ref $content_type eq 'CODE') { |
25
|
0
|
|
|
|
|
0
|
$content_type = $content_type->($file); |
26
|
|
|
|
|
|
|
} |
27
|
7
|
50
|
|
|
|
27
|
if ($content_type =~ m/^text\//) { |
28
|
7
|
|
|
|
|
17
|
$content_type .= '; charset='.$encoding; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
7
|
|
|
|
|
15
|
my $tags = $self->_get_tags; |
32
|
4
|
|
|
|
|
23
|
my $pyx = PYX::SGML::Tags->new( |
33
|
|
|
|
|
|
|
'tags' => $tags, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
4
|
|
|
|
|
650
|
$pyx->parse_file($file); |
37
|
|
|
|
|
|
|
|
38
|
4
|
|
|
|
|
8399
|
my @stat = stat $file; |
39
|
|
|
|
|
|
|
|
40
|
4
|
|
|
|
|
10
|
my $out; |
41
|
4
|
50
|
|
|
|
11
|
if ($encoding eq 'utf-8') { |
42
|
4
|
|
|
|
|
12
|
$out = encode_utf8($tags->flush); |
43
|
|
|
|
|
|
|
} else { |
44
|
0
|
|
|
|
|
0
|
$out = encode($encoding, $tags->flush); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return [ |
48
|
4
|
|
|
|
|
78
|
200, |
49
|
|
|
|
|
|
|
[ |
50
|
|
|
|
|
|
|
'Content-Type' => $content_type, |
51
|
|
|
|
|
|
|
'Last-Modified' => HTTP::Date::time2str($stat[9]), |
52
|
|
|
|
|
|
|
], |
53
|
|
|
|
|
|
|
[$out], |
54
|
|
|
|
|
|
|
]; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _get_tags { |
58
|
7
|
|
|
7
|
|
11
|
my $self = shift; |
59
|
|
|
|
|
|
|
|
60
|
7
|
|
|
|
|
8
|
my $tags; |
61
|
7
|
100
|
|
|
|
17
|
if (! defined $self->indent) { |
62
|
2
|
|
|
|
|
23
|
$tags = Tags::Output::Raw->new; |
63
|
|
|
|
|
|
|
} else { |
64
|
5
|
|
|
|
|
27
|
my $class = $self->indent; |
65
|
5
|
|
|
|
|
236
|
eval "require $class;"; |
66
|
5
|
100
|
|
|
|
7796
|
if ($EVAL_ERROR) { |
67
|
1
|
|
|
|
|
7
|
err "Cannot load class '$class'.", |
68
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
69
|
|
|
|
|
|
|
} |
70
|
4
|
|
|
|
|
158
|
$tags = eval "$class->new"; |
71
|
4
|
100
|
|
|
|
432
|
if ($EVAL_ERROR) { |
72
|
1
|
|
|
|
|
6
|
err "Cannot create object for '$class' class.", |
73
|
|
|
|
|
|
|
'Error', $EVAL_ERROR; |
74
|
|
|
|
|
|
|
} |
75
|
3
|
100
|
|
|
|
22
|
if (! $tags->isa('Tags::Output')) { |
76
|
1
|
|
|
|
|
5
|
err "Bad 'Tags::Output' module to create PYX output."; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
4
|
|
|
|
|
226
|
return $tags; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__END__ |