source: server/trunk/web/lib/Sophie/Controller/Root.pm @ 13

Last change on this file since 13 was 4, checked in by nanardon, 14 years ago
  • add admin tools
File size: 1.5 KB
Line 
1package Sophie::Controller::Root;
2use Moose;
3use namespace::autoclean;
4
5BEGIN { extends 'Catalyst::Controller' }
6
7#
8# Sets the actions in this controller to be registered with no prefix
9# so they function identically to actions created in MyApp.pm
10#
11__PACKAGE__->config(namespace => '');
12
13=head1 NAME
14
15Sophie::Controller::Root - Root Controller for Sophie
16
17=head1 DESCRIPTION
18
19[enter your description here]
20
21=head1 METHODS
22
23=cut
24
25sub begin : Private {
26    my ( $self, $c ) = @_;
27
28    if ($c->req->param('json')) {
29        $c->stash->{current_view} = 'Json';
30    }
31
32    if ($c->action =~ m/^admin\//) {
33        if (!$c->user_exists) {
34            $c->res->redirect($c->uri_for('/login'));
35        }
36    }
37}
38
39=head2 index
40
41The root page (/)
42
43=cut
44
45sub index :Path :Args(0) {
46    my ( $self, $c ) = @_;
47
48    # Hello World
49}
50
51=head2 default
52
53Standard 404 error page
54
55=cut
56
57sub default :Path {
58    my ( $self, $c ) = @_;
59    $c->response->body( 'Page not found' );
60    $c->response->status(404);
61}
62
63=head2 end
64
65Attempt to render a view, if needed.
66
67=cut
68
69sub _end : ActionClass('RenderView') {}
70
71sub  end : Private {
72    my ( $self, $c ) = @_;
73    if (!$c->req->xmlrpc->method) {
74        $c->forward('_end');
75    } elsif (!$c->stash->{current_view}) {
76    }
77    $c->model('Base')->storage->dbh->rollback;
78}
79
80=head1 AUTHOR
81
82Olivier Thauvin
83
84=head1 LICENSE
85
86This library is free software. You can redistribute it and/or modify
87it under the same terms as Perl itself.
88
89=cut
90
91__PACKAGE__->meta->make_immutable;
92
931;
Note: See TracBrowser for help on using the repository browser.