Commit | Line | Data |
42772875 |
1 | #!/usr/bin/perl |
2 | # Root.pm |
3 | # Copyright (c) 2006 Jonathan Rockway <jrockway@cpan.org> |
4 | |
5 | package TestApp::Controller::Root; |
6 | use base qw(Catalyst::Controller); |
7 | __PACKAGE__->config->{namespace} = q{}; |
8 | my @words = qw(foo bar baz bat qux quux); |
9 | |
10 | sub index : Private { |
11 | my ($self, $c, @args) = @_; |
12 | my $words = $c->uri_for('/words'); |
13 | $c->response->body(<<"HERE"); |
14 | <html> |
15 | <head> |
16 | <title>TestApp</title> |
17 | </head> |
18 | <body> |
19 | <h1>TestApp</h1> |
20 | <p>This is the TestApp.</p> |
21 | <p><a href="$words">Click here</a> to <i>see</i> some words.</p> |
22 | </body> |
23 | </html> |
24 | HERE |
25 | } |
26 | |
27 | sub words : Local { |
28 | my ($self, $c, $times) = @_; |
29 | $times ||= 0; |
30 | my $html = <<"HEADER"; |
31 | <html> |
32 | <head> |
33 | <title>TestApp</title> |
34 | </head> |
35 | <body> |
36 | <h1>TestApp << Words</h1> |
37 | <p>Here you'll find all things "words" printed $times time(s)!</p> |
38 | <ul> |
39 | HEADER |
40 | local $" = q{ }; # single space |
41 | $html .= " <li>$_: @words</li>\n" for 1..$times; |
42 | $html .= <<"FOOTER"; |
43 | </ul> |
44 | </body> |
45 | </html> |
46 | FOOTER |
47 | $c->response->body($html); |
48 | } |
49 | |
50 | sub null : Path('/favicon.ico'){ |
51 | my ($self, $c) = @_; |
52 | $c->response->status(404); # doesn't exist |
53 | } |
54 | |
55 | 1; # true. |
56 | |