change dist name to Reaction
[catagits/Reaction.git] / lib / Reaction / UI / Controller / Root.pm
index 302aa78..51b0655 100644 (file)
@@ -15,18 +15,32 @@ has 'window_title' => (isa => 'Str', is => 'rw');
 
 sub begin :Private {
   my ($self, $ctx) = @_;
-  my $window :Stashed = Reaction::UI::Window->new(
-                          ctx => $ctx,
-                          view_name => $self->view_name,
-                          content_type => $self->content_type,
-                          title => $self->window_title,
-                        );
-  my $focus_stack :Stashed = $window->focus_stack;
+  $ctx->stash(
+    window => Reaction::UI::Window->new(
+                ctx => $ctx,
+                view_name => $self->view_name,
+                content_type => $self->content_type,
+                title => $self->window_title,
+              )
+  );
+  $ctx->stash(focus_stack => $ctx->stash->{window}->focus_stack);
 }
 
 sub end :Private {
-  my $window :Stashed;
-  $window->flush;
+  my ($self, $ctx) = @_;
+  $ctx->stash->{window}->flush;
+}
+
+sub error_404 :Private {
+  my ($self, $c) = @_;
+  $c->res->body("Error 404: File not Found");
+  $c->res->status(404);
+}
+
+sub error_403 :Private {
+  my ($self, $c) = @_;
+  $c->res->body("Error 403: Forbidden");
+  $c->res->status(403);
 }
 
 1;
@@ -60,6 +74,11 @@ object containing an empty L<Reaction::UI::FocusStack> for your UI
 elements. The stack is also resolved and rendered for you in the
 C<end> action.
 
+At the C<begin> of each request, a L<Reaction::UI::Window> object is
+created using the configured L</view_name>, L</content_type> and
+L</window_title>. These thus should be directly changed on the stashed
+window object at runtime, if needed.
+
 =head1 METHODS
 
 =head2 view_name