wire layout_args, which was somehow never connected to the mix
[catagits/Reaction.git] / lib / ComponentUI / Controller / Root.pm
1 package ComponentUI::Controller::Root;
2
3 use strict;
4 use warnings;
5 use base 'Reaction::UI::Controller::Root';
6 use Reaction::Class;
7
8 use aliased 'Reaction::UI::ViewPort';
9 use aliased 'Reaction::UI::ViewPort::SiteLayout';
10
11 #
12 # Sets the actions in this controller to be registered with no prefix
13 # so they function identically to actions created in MyApp.pm
14 #
15 __PACKAGE__->config(
16   view_name => 'Site',
17   window_title => 'Reaction Test App',
18   namespace => ''
19 );
20
21 sub base :Chained('/') :PathPart('') :CaptureArgs(0) {
22   my ($self, $c) = @_;
23   $self->push_viewport(SiteLayout,
24     title => 'ComponentUI test title',
25     static_base_uri => "${\$c->uri_for('/static')}",
26     meta_info => {
27       http_header => {
28         'Content-Type' => 'text/html;charset=utf-8',
29       },
30     },
31   );
32 }
33
34 sub root :Chained('base') :PathPart('') :Args(0) {
35   my ($self, $c) = @_;
36   $self->push_viewport(
37     ViewPort, (
38       layout => 'index',
39       layout_args => {
40         user_agent => $c->request->user_agent,
41         message_to_layout => 'I hate programming.',
42       },
43     ),
44   );
45   $c->log->debug('remote', $c->request->remote_user );
46 }
47
48 sub bye :Chained('base') :PathPart('bye') :Args(0) {
49   exit;
50 }
51
52 sub static :Chained('base') :PathPart('static') :Args {
53   my ($self, $c, @args) = @_;
54   return if $c->stash->{window}->view->serve_static_file($c, \@args);
55   $c->forward('error_404');
56 }
57
58 sub error_404 :Private {
59   my ($self, $c) = @_;
60   $c->res->body("Error 404");
61   $c->res->status(404);
62 }
63
64 1;