line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package RapidApp::Template::Controller::Dispatch; |
2
|
4
|
|
|
4
|
|
3231
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
174
|
|
3
|
4
|
|
|
4
|
|
26
|
use warnings; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
157
|
|
4
|
|
|
|
|
|
|
|
5
|
4
|
|
|
4
|
|
27
|
use RapidApp::Util qw(:all); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
2383
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
40
|
use Moose; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
34
|
|
8
|
4
|
|
|
4
|
|
27644
|
use namespace::autoclean; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
44
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# This is the dispatch controller which maps public URL requests |
11
|
|
|
|
|
|
|
# to the actual Template Controller. It is mounted at the root |
12
|
|
|
|
|
|
|
# of the application if the root module isn't, otherwise, it is |
13
|
|
|
|
|
|
|
# called by the root module via shortcut method |
14
|
|
|
|
|
|
|
# $c->template_dispatcher->default($c,@path) where @path is a |
15
|
|
|
|
|
|
|
# *public* template path that is mapped into a real template path |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
404
|
BEGIN { extends 'Catalyst::Controller' } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
before 'COMPONENT' => sub { |
20
|
|
|
|
|
|
|
my $class = shift; |
21
|
|
|
|
|
|
|
my $app_class = ref $_[0] || $_[0]; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my $cnf = $app_class->config->{'Model::RapidApp'} || {}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$class->config( |
26
|
|
|
|
|
|
|
root_template => $cnf->{root_template} || 'rapidapp/default_root_template.html', |
27
|
|
|
|
|
|
|
root_template_prefix => $cnf->{root_template_prefix}, |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
unless ($app_class->application_has_root_controller) { |
31
|
|
|
|
|
|
|
$class->config( action => { |
32
|
|
|
|
|
|
|
default => { Path => '/' }, |
33
|
|
|
|
|
|
|
}); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub default { |
39
|
0
|
|
|
0
|
0
|
|
my ($self, $c, @args) = @_; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $cfg = $self->config; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# root '/' request: |
44
|
0
|
0
|
|
|
|
|
if(scalar @args == 0) { |
45
|
0
|
0
|
|
|
|
|
die "root_template not defined" unless ($cfg->{root_template}); |
46
|
0
|
|
|
|
|
|
@args = ($cfg->{root_template}); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
else { |
49
|
0
|
0
|
|
|
|
|
my $prefix = $cfg->{root_template_prefix} or die "No root_template_prefix defined"; |
50
|
0
|
0
|
|
|
|
|
@args = ($cfg->{root_template_prefix},@args) unless ($prefix eq '/'); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$c->stash->{editable} = 1; # <-- Enable template editing (if has perms) |
54
|
0
|
|
|
|
|
|
my $template = join('/',@args); |
55
|
0
|
|
|
|
|
|
$template =~ s/\/+/\//g; #<-- strip any double // |
56
|
0
|
|
|
|
|
|
return $c->template_controller->view($c, $template); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |