15 |
FillInForm |
FillInForm |
16 |
SubRequest |
SubRequest |
17 |
Static::Simple |
Static::Simple |
18 |
|
StackTrace |
19 |
/; |
/; |
20 |
# FormValidator |
# FormValidator |
21 |
|
|
22 |
our $VERSION = '0.22-dev'; |
our $VERSION = '0.32-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 |
|
$c->log->debug("trying site name: $site_name"); |
64 |
|
|
65 |
|
if (my $sites_root = $c->config->{sites_root}) { |
66 |
|
my $site_path = $c->path_to('root', $sites_root, $site_name); |
67 |
|
|
68 |
|
if (-e $site_path) { |
69 |
|
$c->stash->{site} = $site_name; |
70 |
|
if (my $action = join('/', @{ $c->req->args })) { |
71 |
|
$c->log->debug( "site: $site_name, action: $action" ); |
72 |
|
# TODO can I really change base like this? |
73 |
|
$c->stash->{base} = "/$site_name/" . $c->stash->{base} |
74 |
|
unless ($c->stash->{base} =~ m#^/\Q$site_name\E/#); |
75 |
|
$c->internal_redirect( $action, $c->stash, @{ $c->req->args } ); |
76 |
|
} else { |
77 |
|
$c->log->debug( "site: $site_name" ); |
78 |
|
} |
79 |
|
} else { |
80 |
|
$c->log->debug( "can't find site $site_name in $site_path"); |
81 |
|
} |
82 |
|
} else { |
83 |
|
$c->log->warn("sites_root not defined in config"); |
84 |
|
} |
85 |
} |
} |
86 |
|
|
87 |
=item end |
=item end |
96 |
if ($c->response->body) { |
if ($c->response->body) { |
97 |
$c->log->debug("at end body exists, we won't touch it!"); |
$c->log->debug("at end body exists, we won't touch it!"); |
98 |
} else { |
} else { |
99 |
$c->fillform( $c->req->params ); |
if (my $site_name = $c->stash->{site}) { |
100 |
|
my $template_path = $c->path_to('root', $c->config->{sites_root}, $site_name, $c->stash->{template}); |
101 |
|
if (-e $template_path) { |
102 |
|
$c->stash->{template} = $c->config->{sites_root} . "/$site_name/" . $c->stash->{template}; |
103 |
|
} else { |
104 |
|
$c->log->warn("can't find $template_path, fallback to default"); |
105 |
|
} |
106 |
|
$c->log->debug("using template ", $c->stash->{template}); |
107 |
|
} |
108 |
|
|
109 |
# Forward to View unless response body is already defined |
# Forward to View unless response body is already defined |
110 |
$c->forward('View::TT'); |
$c->forward('View::TT'); |
111 |
|
|
112 |
|
$c->fillform( $c->req->params ); |
113 |
|
|
114 |
$c->response->{body} =~ s#\Qnew Ajax.Autocompleter(\E#new WebPAC.Suggest(#gs; |
$c->response->{body} =~ s#\Qnew Ajax.Autocompleter(\E#new WebPAC.Suggest(#gs; |
115 |
$c->response->{body} =~ s#\Qnew Ajax.Updater(\E#new WebPAC.Updater(#gs; |
$c->response->{body} =~ s#\Qnew Ajax.Updater(\E#new WebPAC.Updater(#gs; |
116 |
|
|
119 |
|
|
120 |
} |
} |
121 |
|
|
122 |
|
=item internal_redirect |
123 |
|
|
124 |
|
$c->internal_redirect( $action, @args ); |
125 |
|
|
126 |
|
=cut |
127 |
|
|
128 |
|
sub internal_redirect { |
129 |
|
my ( $c, $action, @args ) = @_; |
130 |
|
|
131 |
|
unless ( defined $action ) { |
132 |
|
$action = $c->action->namespace; |
133 |
|
} else { |
134 |
|
$action = join '/', $c->action->namespace, $action unless $action =~ m!^/!; |
135 |
|
} |
136 |
|
$c->res->body( $c->subreq( $action, @args ) ); |
137 |
|
return; |
138 |
|
} |
139 |
|
|
140 |
|
|
141 |
=back |
=back |
142 |
|
|
143 |
=head1 AUTHOR |
=head1 AUTHOR |