/[webpac2]/Webpacus/lib/Webpacus.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /Webpacus/lib/Webpacus.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 378 by dpavlin, Sat Jan 21 23:27:16 2006 UTC revision 399 by dpavlin, Sun Feb 19 12:37:27 2006 UTC
# Line 16  use Catalyst qw/-Debug Line 16  use Catalyst qw/-Debug
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.33-dev';
24    
25  #  #
26  # Configure the application  # Configure the application
# Line 69  sub default : Private { Line 70  sub default : Private {
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                          }                          }
# Line 96  sub end : Private { Line 95  sub end : Private {
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) {
# Line 105  sub end : Private { Line 102  sub end : Private {
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    
# Line 119  sub end : Private { Line 123  sub end : Private {
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

Legend:
Removed from v.378  
changed lines
  Added in v.399

  ViewVC Help
Powered by ViewVC 1.1.26