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