line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::AutoCRUD::View::TT; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
479
|
use 5.010; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
3
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
5
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
4
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
8
|
|
|
|
|
|
|
extends 'App::AutoCRUD::View'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
10383
|
use Template; |
|
1
|
|
|
|
|
33083
|
|
|
1
|
|
|
|
|
26
|
|
11
|
1
|
|
|
1
|
|
12437
|
use Template::Filters (); |
|
1
|
|
|
|
|
4551
|
|
|
1
|
|
|
|
|
38
|
|
12
|
1
|
|
|
1
|
|
13
|
use Encode qw/encode_utf8/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
95
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use namespace::clean -except => 'meta'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
11
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'tt_args' => ( is => 'bare', isa => 'HashRef', default => sub {{}} ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub render { |
20
|
8
|
|
|
8
|
0
|
11
|
my ($self, $data, $context) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# where to find templates |
23
|
8
|
|
|
|
|
185
|
my @dirs = map {"$_/templates"} $context->app->share_paths; |
|
8
|
|
|
|
|
30
|
|
24
|
8
|
|
|
|
|
42
|
unshift @dirs, $context->dir . "/templates"; |
25
|
|
|
|
|
|
|
|
26
|
8
|
|
|
|
|
66
|
my %tt_args = ( |
27
|
|
|
|
|
|
|
INCLUDE_PATH => \@dirs, |
28
|
|
|
|
|
|
|
PRE_PROCESS => 'lib/config', |
29
|
|
|
|
|
|
|
WRAPPER => 'lib/site/wrapper', |
30
|
|
|
|
|
|
|
ERROR => 'src/error.tt', |
31
|
|
|
|
|
|
|
ENCODING => 'utf8', |
32
|
|
|
|
|
|
|
FILTERS => { utf8_url => \&utf8_url }, |
33
|
8
|
|
|
|
|
40
|
%{$self->{tt_args}}, |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
8
|
|
|
|
|
74
|
my $renderer = Template->new(%tt_args); |
37
|
8
|
50
|
|
|
|
31260
|
my $template = $context->template |
38
|
|
|
|
|
|
|
or die "no template for TT view"; |
39
|
8
|
50
|
|
|
|
51
|
$renderer->process("src/$template", |
40
|
|
|
|
|
|
|
{data => $data, c => $context}, |
41
|
|
|
|
|
|
|
\my $output) |
42
|
|
|
|
|
|
|
or die $renderer->error; |
43
|
|
|
|
|
|
|
|
44
|
8
|
|
|
|
|
728
|
return [200, ['Content-type' => 'text/html; charset=utf-8', |
45
|
|
|
|
|
|
|
'X-UA-Compatible' => "IE=edge", # enforce latest MSIE rendering |
46
|
|
|
|
|
|
|
], |
47
|
|
|
|
|
|
|
[encode_utf8($output)] ]; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub default_dashed_args { |
52
|
2
|
|
|
2
|
0
|
4
|
my ($self, $context) = @_; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
50
|
|
|
49
|
return (-page_index => 1, |
55
|
|
|
|
|
|
|
-page_size => ($context->app->default('page_size') || 50)); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub utf8_url { |
60
|
48
|
|
|
48
|
0
|
61
|
my $data = shift; |
61
|
48
|
|
|
|
|
112
|
return Template::Filters::url_filter(encode_utf8($data)); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
1; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
__END__ |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# code partially borrowed from Catalyst::Helper::View::TTSite |