line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Action::RenderView; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
22934
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
49
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.16'; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use base 'Catalyst::Action'; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
597
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
832
|
use MRO::Compat; |
|
1
|
|
|
|
|
3179
|
|
|
1
|
|
|
|
|
28
|
|
11
|
1
|
|
|
1
|
|
458
|
use Data::Visitor::Callback; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my %ignore_classes = (); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub execute { |
16
|
|
|
|
|
|
|
my $self = shift; |
17
|
|
|
|
|
|
|
my ($controller, $c ) = @_; |
18
|
|
|
|
|
|
|
$self->next::method( @_ ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
$c->config->{'Action::RenderView'}->{ignore_classes} = |
21
|
|
|
|
|
|
|
( ref($c->config->{'debug'}) eq 'HASH' ? $c->config->{'debug'}->{ignore_classes} : undef ) |
22
|
|
|
|
|
|
|
|| [ qw/ |
23
|
|
|
|
|
|
|
DBIx::Class::ResultSource::Table |
24
|
|
|
|
|
|
|
DBIx::Class::ResultSourceHandle |
25
|
|
|
|
|
|
|
DateTime |
26
|
|
|
|
|
|
|
/ ] unless exists $c->config->{'Action::RenderView'}->{ignore_classes}; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
$c->config->{'Action::RenderView'}->{scrubber_func} = |
29
|
|
|
|
|
|
|
( ref($c->config->{'debug'}) eq 'HASH' ? $c->config->{'debug'}->{scrubber_func} : undef ) |
30
|
|
|
|
|
|
|
|| sub { $_='[stringified to: ' . $_ . ']' } |
31
|
|
|
|
|
|
|
unless exists $c->config->{'Action::RenderView'}->{scrubber_func}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ($c->debug && $c->req->params->{dump_info}) { |
34
|
|
|
|
|
|
|
unless ( keys %ignore_classes ) { |
35
|
|
|
|
|
|
|
foreach my $class (@{$c->config->{'Action::RenderView'}->{ignore_classes}}) { |
36
|
|
|
|
|
|
|
$ignore_classes{$class} = $c->config->{'Action::RenderView'}->{scrubber_func}; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
my $scrubber=Data::Visitor::Callback->new( |
40
|
|
|
|
|
|
|
"ignore_return_values" => 1, |
41
|
|
|
|
|
|
|
"object" => "visit_ref", |
42
|
|
|
|
|
|
|
%ignore_classes, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
$scrubber->visit( $c->stash ); |
45
|
|
|
|
|
|
|
die('Forced debug - Scrubbed output'); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
if(! $c->response->content_type ) { |
49
|
|
|
|
|
|
|
$c->response->content_type( 'text/html; charset=utf-8' ); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
return 1 if $c->req->method eq 'HEAD'; |
52
|
|
|
|
|
|
|
return 1 if defined $c->response->body; |
53
|
|
|
|
|
|
|
return 1 if scalar @{ $c->error } && !$c->stash->{template}; |
54
|
|
|
|
|
|
|
return 1 if $c->response->status =~ /^(?:204|3\d\d)$/; |
55
|
|
|
|
|
|
|
my $view = $c->view() |
56
|
|
|
|
|
|
|
|| die "Catalyst::Action::RenderView could not find a view to forward to.\n"; |
57
|
|
|
|
|
|
|
$c->forward( $view ); |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 NAME |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
Catalyst::Action::RenderView - Sensible default end action. |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head1 SYNOPSIS |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub end : ActionClass('RenderView') {} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This action implements a sensible default end action, which will forward |
73
|
|
|
|
|
|
|
to the first available view, unless C<< $c->res->status >> is a 3xx code |
74
|
|
|
|
|
|
|
(redirection, not modified, etc.), 204 (no content), or C<< $c->res->body >> has |
75
|
|
|
|
|
|
|
already been set. It also allows you to pass C<dump_info=1> to the url in |
76
|
|
|
|
|
|
|
order to force a debug screen, while in debug mode. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
If you have more than one view, you can specify which one to use with |
79
|
|
|
|
|
|
|
the C<default_view> config setting and the C<current_view> and |
80
|
|
|
|
|
|
|
C<current_view_instance> stash keys (see L<Catalyst>'s C<$c-E<gt>view($name)> |
81
|
|
|
|
|
|
|
method -- this module simply calls C<< $c->view >> with no argument). |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 METHODS |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 end |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
The default C<end> action. You can override this as required in your |
88
|
|
|
|
|
|
|
application class; normal inheritance applies. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 INTERNAL METHODS |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 execute |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Dispatches control to superclasses, then forwards to the default View. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
See L<Catalyst::Action/METHODS/action>. |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 SCRUBBING OUTPUT |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
When you force debug with dump_info=1, RenderView is capable of removing |
101
|
|
|
|
|
|
|
classes from the objects in your stash. By default it will replace any |
102
|
|
|
|
|
|
|
DBIx::Class resultsource objects with the class name, which cleans up the |
103
|
|
|
|
|
|
|
debug output considerably, but you can change what gets scrubbed by |
104
|
|
|
|
|
|
|
setting a list of classes in |
105
|
|
|
|
|
|
|
$c->config->{'Action::RenderView'}->{ignore_classes}. |
106
|
|
|
|
|
|
|
For instance: |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$c->config->{'Action::RenderView'}->{ignore_classes} = []; |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
To disable the functionality. You can also set |
111
|
|
|
|
|
|
|
config->{'Action::RenderView'}->{scrubber_func} to change what it does with the |
112
|
|
|
|
|
|
|
classes. For instance, this will undef it instead of putting in the |
113
|
|
|
|
|
|
|
class name: |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$c->config->{'Action::RenderView'}->{scrubber_func} = sub { undef $_ }; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 Deprecation notice |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
This plugin used to be configured by setting C<< $c->config->{debug} >>. |
120
|
|
|
|
|
|
|
That configuration key is still supported in this release, but is |
121
|
|
|
|
|
|
|
deprecated, please use the C< 'Action::RenderView' > namespace as shown |
122
|
|
|
|
|
|
|
above for configuration in new code. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head1 EXTENDING |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
To add something to an C<end> action that is called before rendering, |
127
|
|
|
|
|
|
|
simply place it in the C<end> method: |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub end : ActionClass('RenderView') { |
130
|
|
|
|
|
|
|
my ( $self, $c ) = @_; |
131
|
|
|
|
|
|
|
# do stuff here; the RenderView action is called afterwards |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
To add things to an C<end> action that are called I<after> rendering, |
135
|
|
|
|
|
|
|
you can set it up like this: |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub render : ActionClass('RenderView') { } |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub end : Private { |
140
|
|
|
|
|
|
|
my ( $self, $c ) = @_; |
141
|
|
|
|
|
|
|
$c->forward('render'); |
142
|
|
|
|
|
|
|
# do stuff here |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 AUTHORS |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Marcus Ramberg <marcus@thefeed.no> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Florian Ragwitz E<lt>rafl@debian.orgE<gt> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head1 COPYRIGHT |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Copyright (c) 2006 - 2009 |
154
|
|
|
|
|
|
|
the Catalyst::Action::RenderView L</AUTHOR> |
155
|
|
|
|
|
|
|
as listed above. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 LICENSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify it |
160
|
|
|
|
|
|
|
under the same terms as Perl itself. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=cut |
163
|
|
|
|
|
|
|
|