10 |
# Static::Simple: will serve static files from the applications root directory |
# Static::Simple: will serve static files from the applications root directory |
11 |
# |
# |
12 |
use Catalyst qw/-Debug |
use Catalyst qw/-Debug |
|
Static::Simple |
|
13 |
Prototype |
Prototype |
14 |
Config::YAML |
Config::YAML |
15 |
FillInForm |
FillInForm |
16 |
|
SubRequest |
17 |
|
Static::Simple |
18 |
|
StackTrace |
19 |
|
Dumper |
20 |
/; |
/; |
21 |
# FormValidator |
# FormValidator |
22 |
|
|
23 |
our $VERSION = '0.11-dev'; |
our $VERSION = '0.33-dev'; |
24 |
|
|
25 |
# |
# |
26 |
# Configure the application |
# Configure the application |
58 |
sub default : Private { |
sub default : Private { |
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 }; |
63 |
|
|
64 |
|
$c->log->debug("trying site name: $site_name"); |
65 |
|
|
66 |
|
if (my $sites_root = $c->config->{sites_root}) { |
67 |
|
my $site_path = $c->path_to('root', $sites_root, $site_name); |
68 |
|
|
69 |
|
if (-e $site_path) { |
70 |
|
$c->stash->{site} = $site_name; |
71 |
|
if (my $action = join('/', @{ $c->req->args })) { |
72 |
|
$c->log->debug( "site: $site_name, action: $action" ); |
73 |
|
# do a subrequest |
74 |
|
$c->res->body( $c->subreq( $action, $c->stash, @{ $c->req->args } ) ); |
75 |
|
} else { |
76 |
|
$c->log->debug( "site: $site_name" ); |
77 |
|
} |
78 |
|
} else { |
79 |
|
$c->log->debug( "can't find site $site_name in $site_path"); |
80 |
|
} |
81 |
|
} else { |
82 |
|
$c->log->warn("sites_root not defined in config"); |
83 |
|
} |
84 |
} |
} |
85 |
|
|
86 |
=item end |
=item end |
92 |
|
|
93 |
$c->stash->{webpacus_version} = $VERSION; |
$c->stash->{webpacus_version} = $VERSION; |
94 |
|
|
95 |
# Forward to View unless response body is already defined |
if ($c->response->body) { |
96 |
$c->forward('View::TT') unless $c->response->body; |
$c->log->debug("at end body exists, we won't touch it!"); |
97 |
|
} else { |
98 |
|
if (my $site_name = $c->stash->{site}) { |
99 |
|
my $template_path = $c->path_to('root', $c->config->{sites_root}, $site_name, $c->stash->{template}); |
100 |
|
if (-e $template_path) { |
101 |
|
$c->stash->{template} = $c->config->{sites_root} . "/$site_name/" . $c->stash->{template}; |
102 |
|
} else { |
103 |
|
$c->log->warn("can't find $template_path, fallback to default"); |
104 |
|
} |
105 |
|
$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 |
114 |
|
$c->forward('View::TT'); |
115 |
|
|
116 |
|
$c->fillform( $c->req->params ); |
117 |
|
|
118 |
$c->fillform; # defaults to $c->req->parameters |
$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; |
120 |
|
|
121 |
# $c->log->debug( $c->response->body ); |
# $c->log->debug( $c->response->body ); |
122 |
|
} |
123 |
|
|
124 |
} |
} |
125 |
|
|
127 |
|
|
128 |
=head1 AUTHOR |
=head1 AUTHOR |
129 |
|
|
130 |
Dobrica Pavlinusic,,, |
Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >> |
131 |
|
|
132 |
=head1 LICENSE |
=head1 LICENSE |
133 |
|
|