15 |
FillInForm |
FillInForm |
16 |
SubRequest |
SubRequest |
17 |
Static::Simple |
Static::Simple |
18 |
|
StackTrace |
19 |
/; |
/; |
20 |
# FormValidator |
# FormValidator |
21 |
|
|
22 |
our $VERSION = '0.23-dev'; |
our $VERSION = '0.31-dev'; |
23 |
|
|
24 |
# |
# |
25 |
# Configure the application |
# Configure the application |
57 |
sub default : Private { |
sub default : Private { |
58 |
my ( $self, $c ) = @_; |
my ( $self, $c ) = @_; |
59 |
$c->stash->{template} = 'index.tt'; |
$c->stash->{template} = 'index.tt'; |
60 |
|
|
61 |
|
my $site_name = shift @{ $c->req->args }; |
62 |
|
|
63 |
|
if (my $sites_root = $c->config->{sites_root}) { |
64 |
|
my $site_path = $c->path_to('root', $sites_root, $site_name); |
65 |
|
|
66 |
|
if (-e $site_path) { |
67 |
|
$c->stash->{site} = $site_name; |
68 |
|
if (my $action = shift @{ $c->req->args }) { |
69 |
|
$c->log->debug( "site: $site_name, action: $action" ); |
70 |
|
$c->internal_redirect( $action, $c->stash ); |
71 |
|
} else { |
72 |
|
$c->log->debug( "site: $site_name" ); |
73 |
|
} |
74 |
|
} else { |
75 |
|
$c->log->debug( "can't find site $site_name in $site_path"); |
76 |
|
} |
77 |
|
} else { |
78 |
|
$c->log->warn("sites_root not defined in config"); |
79 |
|
} |
80 |
} |
} |
81 |
|
|
82 |
=item end |
=item end |
93 |
} else { |
} else { |
94 |
$c->fillform( $c->req->params ); |
$c->fillform( $c->req->params ); |
95 |
|
|
96 |
|
if (my $site_name = $c->stash->{site}) { |
97 |
|
my $template_path = $c->path_to('root', $c->config->{sites_root}, $site_name, $c->stash->{template}); |
98 |
|
if (-e $template_path) { |
99 |
|
$c->stash->{template} = $c->config->{sites_root} . "/$site_name/" . $c->stash->{template}; |
100 |
|
} else { |
101 |
|
$c->log->warn("can't find $template_path, fallback to default"); |
102 |
|
} |
103 |
|
$c->log->debug("using template ", $c->stash->{template}); |
104 |
|
} |
105 |
|
|
106 |
# Forward to View unless response body is already defined |
# Forward to View unless response body is already defined |
107 |
$c->forward('View::TT'); |
$c->forward('View::TT'); |
108 |
|
|
114 |
|
|
115 |
} |
} |
116 |
|
|
117 |
|
=item internal_redirect |
118 |
|
|
119 |
|
$c->internal_redirect( $action, @args ); |
120 |
|
|
121 |
|
=cut |
122 |
|
|
123 |
|
sub internal_redirect { |
124 |
|
my ( $c, $action, @args ) = @_; |
125 |
|
|
126 |
|
unless ( defined $action ) { |
127 |
|
$action = $c->action->namespace; |
128 |
|
} else { |
129 |
|
$action = join '/', $c->action->namespace, $action unless $action =~ m!^/!; |
130 |
|
} |
131 |
|
$c->res->body( $c->subreq( $action, @args ) ); |
132 |
|
return; |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
=back |
=back |
137 |
|
|
138 |
=head1 AUTHOR |
=head1 AUTHOR |