Commit | Line | Data |
07571b2f |
1 | package TestApp; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Catalyst; # qw/-Debug/; |
e2bbd784 |
7 | use Path::Class; |
07571b2f |
8 | |
9 | our $VERSION = '0.01'; |
10 | |
11 | __PACKAGE__->config( |
12 | name => 'TestApp', |
13 | default_message => 'hi', |
14 | default_view => 'Pkgconfig', |
15 | 'View::TT::Appconfig' => { |
16 | PRE_CHOMP => 1, |
17 | POST_CHOMP => 1, |
18 | TEMPLATE_EXTENSION => '.tt', |
19 | }, |
20 | ); |
21 | |
22 | __PACKAGE__->setup; |
23 | |
24 | sub default : Private { |
25 | my ($self, $c) = @_; |
26 | |
27 | $c->response->redirect($c->uri_for('test')); |
28 | } |
29 | |
30 | sub test : Local { |
31 | my ($self, $c) = @_; |
32 | |
33 | $c->stash->{message} = ($c->request->param('message') || $c->config->{default_message}); |
34 | } |
35 | |
e2bbd784 |
36 | sub test_includepath : Local { |
37 | my ($self, $c) = @_; |
38 | $c->stash->{message} = ($c->request->param('message') || $c->config->{default_message}); |
39 | $c->stash->{template} = $c->request->param('template'); |
40 | if ( $c->request->param('additionalpath') ){ |
41 | my $additionalpath = Path::Class::dir($c->config->{root}, $c->request->param('additionalpath')); |
42 | $c->stash->{additional_template_paths} = ["$additionalpath"]; |
43 | } |
44 | } |
45 | |
07571b2f |
46 | sub end : Private { |
47 | my ($self, $c) = @_; |
48 | |
49 | return 1 if $c->response->status =~ /^3\d\d$/; |
50 | return 1 if $c->response->body; |
51 | |
52 | my $view = 'View::TT::' . ($c->request->param('view') || $c->config->{default_view}); |
53 | $c->forward($view); |
54 | } |
55 | |
56 | 1; |