16 |
SubRequest |
SubRequest |
17 |
Static::Simple |
Static::Simple |
18 |
StackTrace |
StackTrace |
19 |
|
Dumper |
20 |
/; |
/; |
21 |
# FormValidator |
# FormValidator |
22 |
|
|
23 |
our $VERSION = '0.32-dev'; |
our $VERSION = '0.34-dev'; |
24 |
|
|
25 |
# |
# |
26 |
# Configure the application |
# Configure the application |
59 |
my ( $self, $c ) = @_; |
my ( $self, $c ) = @_; |
60 |
$c->stash->{template} = 'index.tt'; |
$c->stash->{template} = 'index.tt'; |
61 |
|
|
62 |
my $site_name = shift @{ $c->req->args }; |
my $site_name = shift @{ $c->req->args } || ''; |
63 |
|
|
64 |
$c->log->debug("trying site name: $site_name"); |
$c->log->debug("trying site name: $site_name"); |
65 |
|
|
70 |
$c->stash->{site} = $site_name; |
$c->stash->{site} = $site_name; |
71 |
if (my $action = join('/', @{ $c->req->args })) { |
if (my $action = join('/', @{ $c->req->args })) { |
72 |
$c->log->debug( "site: $site_name, action: $action" ); |
$c->log->debug( "site: $site_name, action: $action" ); |
73 |
# TODO can I really change base like this? |
# do a subrequest |
74 |
$c->stash->{base} = "/$site_name/" . $c->stash->{base} |
$c->res->body( $c->subreq( $action, $c->stash, @{ $c->req->args } ) ); |
|
unless ($c->stash->{base} =~ m#^/\Q$site_name\E/#); |
|
|
$c->internal_redirect( $action, $c->stash, @{ $c->req->args } ); |
|
75 |
} else { |
} else { |
76 |
$c->log->debug( "site: $site_name" ); |
$c->log->debug( "site: $site_name" ); |
77 |
} |
} |
95 |
if ($c->response->body) { |
if ($c->response->body) { |
96 |
$c->log->debug("at end body exists, we won't touch it!"); |
$c->log->debug("at end body exists, we won't touch it!"); |
97 |
} else { |
} else { |
|
$c->fillform( $c->req->params ); |
|
|
|
|
98 |
if (my $site_name = $c->stash->{site}) { |
if (my $site_name = $c->stash->{site}) { |
99 |
my $template_path = $c->path_to('root', $c->config->{sites_root}, $site_name, $c->stash->{template}); |
my $template_path = $c->path_to('root', $c->config->{sites_root}, $site_name, $c->stash->{template}); |
100 |
if (-e $template_path) { |
if (-e $template_path) { |
102 |
} else { |
} else { |
103 |
$c->log->warn("can't find $template_path, fallback to default"); |
$c->log->warn("can't find $template_path, fallback to default"); |
104 |
} |
} |
105 |
$c->log->debug("using template ", $c->stash->{template}); |
$c->log->debug("using template " . $c->stash->{template}); |
106 |
|
|
107 |
|
$c->stash->{site_url} = "/$site_name/"; |
108 |
|
|
109 |
|
#$c->log->dumper( $c->stash, 'stash' ); |
110 |
|
|
111 |
} |
} |
112 |
|
|
113 |
# Forward to View unless response body is already defined |
# Forward to View unless response body is already defined |
114 |
$c->forward('View::TT'); |
$c->forward('View::TT'); |
115 |
|
|
116 |
|
$c->fillform( $c->req->params ); |
117 |
|
|
118 |
$c->response->{body} =~ s#\Qnew Ajax.Autocompleter(\E#new WebPAC.Suggest(#gs; |
$c->response->{body} =~ s#\Qnew Ajax.Autocompleter(\E#new WebPAC.Suggest(#gs; |
119 |
$c->response->{body} =~ s#\Qnew Ajax.Updater(\E#new WebPAC.Updater(#gs; |
$c->response->{body} =~ s#\Qnew Ajax.Updater(\E#new WebPAC.Updater(#gs; |
120 |
|
|
123 |
|
|
124 |
} |
} |
125 |
|
|
|
=item internal_redirect |
|
|
|
|
|
$c->internal_redirect( $action, @args ); |
|
|
|
|
|
=cut |
|
|
|
|
|
sub internal_redirect { |
|
|
my ( $c, $action, @args ) = @_; |
|
|
|
|
|
unless ( defined $action ) { |
|
|
$action = $c->action->namespace; |
|
|
} else { |
|
|
$action = join '/', $c->action->namespace, $action unless $action =~ m!^/!; |
|
|
} |
|
|
$c->res->body( $c->subreq( $action, @args ) ); |
|
|
return; |
|
|
} |
|
|
|
|
|
|
|
126 |
=back |
=back |
127 |
|
|
128 |
=head1 AUTHOR |
=head1 AUTHOR |