/[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 358 by dpavlin, Sun Jan 8 13:58:19 2006 UTC revision 405 by dpavlin, Sun Feb 19 22:40:40 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.31-dev';  our $VERSION = '0.33-dev';
24    
25  #  #
26  # Configure the application  # Configure the application
# Line 60  sub default : Private { Line 61  sub default : Private {
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");
65    
66          if (my $sites_root = $c->config->{sites_root}) {          if (my $sites_root = $c->config->{sites_root}) {
67                  my $site_path = $c->path_to('root', $sites_root, $site_name);                  my $site_path = $c->path_to('root', $sites_root, $site_name);
68    
69                  if (-e $site_path) {                  if (-e $site_path) {
70                          $c->stash->{site} = $site_name;                          $c->stash->{site} = $site_name;
71                          if (my $action = shift @{ $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                                  $c->internal_redirect( $action, $c->stash );                                  # do a subrequest
74                                    $c->res->body( $c->subreq( $action, $c->stash, @{ $c->req->args } ) );
75                          } else {                          } else {
76                                  $c->log->debug( "site: $site_name" );                                  $c->log->debug( "site: $site_name" );
77                          }                          }
# Line 91  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 100  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 114  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.358  
changed lines
  Added in v.405

  ViewVC Help
Powered by ViewVC 1.1.26