line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Terse::View; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
887
|
use base 'Terse'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
266
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
1
|
|
|
1
|
1
|
16
|
my ($pkg, @args) = @_; |
7
|
1
|
|
|
|
|
5
|
my $self = $pkg->SUPER::new(@args); |
8
|
1
|
|
|
|
|
11
|
my ($namespace) = $pkg =~ m/([^:]+)$/; |
9
|
1
|
|
|
|
|
9
|
$self->namespace = lc( $namespace ); |
10
|
1
|
50
|
|
|
|
15
|
$self->build_view($self->app_config) if ($self->can('build_view')); |
11
|
1
|
|
|
|
|
9
|
return $self; |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub render { |
15
|
0
|
|
|
0
|
0
|
|
my ($self, $t, $data) = @_; |
16
|
0
|
|
|
|
|
|
return ('application/json', $data->pretty(1)->serialize()) |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Terse::View - views made simple. |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Version 0.18 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 SYNOPSIS |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
package My::App::View::Pretty; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
use base 'Terse::View'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
1; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
... If using Terse::App |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package My::App; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
use base 'Terse::App'; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub build_app { |
46
|
|
|
|
|
|
|
$_[0]->response_view = 'pretty'; # default all requests to use this view. |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub auth { |
50
|
|
|
|
|
|
|
shift; |
51
|
|
|
|
|
|
|
$_[0]->controller('admin/auth')->authenticate(@_); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
... else |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
package MyApp; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
use base 'Terse::Controller'; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
use MyAppView; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub build_controller { |
63
|
|
|
|
|
|
|
$_[0]->views->pretty = MyAppView->new(); |
64
|
|
|
|
|
|
|
$_[0]->response_view = 'pretty'; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub overview :get { |
68
|
|
|
|
|
|
|
$_[1]->response->data = $_[1]->model('data')->do_something(); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=cut |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 AUTHOR |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
LNATION, C<< >> |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
L. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|