line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::AutoCRUD::View::TT; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
522
|
use 5.010; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
8
|
|
|
|
|
|
|
extends 'App::AutoCRUD::View'; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
7164
|
use Template; |
|
1
|
|
|
|
|
19834
|
|
|
1
|
|
|
|
|
33
|
|
11
|
1
|
|
|
1
|
|
562
|
use Template::Filters (); |
|
1
|
|
|
|
|
5345
|
|
|
1
|
|
|
|
|
28
|
|
12
|
1
|
|
|
1
|
|
8
|
use Encode qw/encode_utf8/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
58
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
7
|
use namespace::clean -except => 'meta'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has 'tt_args' => ( is => 'bare', isa => 'HashRef', default => sub {{}} ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub render { |
20
|
7
|
|
|
7
|
0
|
23
|
my ($self, $data, $context) = @_; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
# where to find templates |
23
|
7
|
|
|
|
|
197
|
my @dirs = map {"$_/templates"} $context->app->share_paths; |
|
7
|
|
|
|
|
38
|
|
24
|
7
|
|
|
|
|
46
|
unshift @dirs, $context->dir . "/templates"; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
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
|
7
|
|
|
|
|
36
|
%{$self->{tt_args}}, |
|
7
|
|
|
|
|
64
|
|
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
7
|
|
|
|
|
83
|
my $renderer = Template->new(%tt_args); |
37
|
7
|
50
|
|
|
|
23109
|
my $template = $context->template |
38
|
|
|
|
|
|
|
or die "no template for TT view"; |
39
|
7
|
50
|
|
|
|
65
|
$renderer->process("src/$template", |
40
|
|
|
|
|
|
|
{data => $data, c => $context}, |
41
|
|
|
|
|
|
|
\my $output) |
42
|
|
|
|
|
|
|
or die $renderer->error; |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
1149
|
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
|
7
|
my ($self, $context) = @_; |
53
|
|
|
|
|
|
|
|
54
|
2
|
|
50
|
|
|
58
|
return (-page_index => 1, |
55
|
|
|
|
|
|
|
-page_size => ($context->app->default('page_size') || 50)); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub utf8_url { |
60
|
45
|
|
|
45
|
0
|
96
|
my $data = shift; |
61
|
45
|
|
|
|
|
185
|
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 |