line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::DispatchType::Index; |
2
|
|
|
|
|
|
|
|
3
|
155
|
|
|
155
|
|
3187
|
use Moose; |
|
155
|
|
|
|
|
572
|
|
|
155
|
|
|
|
|
1305
|
|
4
|
|
|
|
|
|
|
extends 'Catalyst::DispatchType'; |
5
|
155
|
|
|
155
|
|
1046292
|
use namespace::clean -except => 'meta'; |
|
155
|
|
|
|
|
575
|
|
|
155
|
|
|
|
|
2036
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Catalyst::DispatchType::Index - Index DispatchType |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 SYNOPSIS |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
See L<Catalyst::DispatchType>. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Dispatch type managing behaviour for index pages. For more information on |
18
|
|
|
|
|
|
|
dispatch types, see: |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=over 4 |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=item * L<Catalyst::Manual::Intro> for how they affect application authors |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item * L<Catalyst::DispatchType> for implementation information. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=back |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=cut |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has _actions => ( |
31
|
|
|
|
|
|
|
is => 'rw', isa => 'HashRef', default => sub { +{} } |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 METHODS |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head2 $self->match( $c, $path ) |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Check if there's an index action for a given path, and set it up to use it |
39
|
|
|
|
|
|
|
if there is; only matches a full URI - if $c->req->args is already set |
40
|
|
|
|
|
|
|
this DispatchType is guaranteed not to match. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub match { |
45
|
1404
|
|
|
1404
|
1
|
4010
|
my ( $self, $c, $path ) = @_; |
46
|
1404
|
100
|
|
|
|
2653
|
return if @{ $c->req->args }; |
|
1404
|
|
|
|
|
4971
|
|
47
|
927
|
|
|
|
|
5238
|
my $result = $c->get_action( 'index', $path ); |
48
|
|
|
|
|
|
|
|
49
|
927
|
100
|
100
|
|
|
6228
|
return 0 unless $result && exists $self->_actions->{ $result->reverse }; |
50
|
|
|
|
|
|
|
|
51
|
27
|
50
|
33
|
|
|
124
|
if ($result && $result->match($c)) { |
52
|
27
|
|
|
|
|
810
|
$c->action($result); |
53
|
27
|
|
|
|
|
779
|
$c->namespace( $result->namespace ); |
54
|
27
|
|
|
|
|
132
|
$c->req->action('index'); |
55
|
27
|
|
|
|
|
118
|
$c->req->match( $c->req->path ); |
56
|
27
|
|
|
|
|
186
|
return 1; |
57
|
|
|
|
|
|
|
} |
58
|
0
|
|
|
|
|
0
|
return 0; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 $self->register( $c, $action ) |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Register an action with this DispatchType. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub register { |
68
|
44594
|
|
|
44594
|
1
|
92699
|
my ( $self, $c, $action ) = @_; |
69
|
|
|
|
|
|
|
|
70
|
44594
|
100
|
|
|
|
1164221
|
$self->_actions->{ $action->reverse } = $action if $action->name eq 'index'; |
71
|
|
|
|
|
|
|
|
72
|
44594
|
|
|
|
|
123231
|
return 1; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 $self->uri_for_action( $action, $captures ) |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
get a URI part for an action; always returns undef is $captures is set |
78
|
|
|
|
|
|
|
since index actions don't have captures |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub uri_for_action { |
83
|
78
|
|
|
78
|
1
|
222
|
my ( $self, $action, $captures ) = @_; |
84
|
|
|
|
|
|
|
|
85
|
78
|
100
|
|
|
|
279
|
return undef if @$captures; |
86
|
|
|
|
|
|
|
|
87
|
29
|
100
|
|
|
|
983
|
return undef unless exists $self->_actions->{ $action->reverse }; |
88
|
|
|
|
|
|
|
|
89
|
1
|
|
|
|
|
28
|
return "/".$action->namespace; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
74089
|
|
|
74089
|
|
176415
|
sub _is_low_precedence { 1 } |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 AUTHORS |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
Catalyst Contributors, see Catalyst.pm |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head1 COPYRIGHT |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This library is free software. You can redistribute it and/or modify it under |
101
|
|
|
|
|
|
|
the same terms as Perl itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=cut |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |