Line | |
---|
1 | package Sophie::Controller::Root; |
---|
2 | use Moose; |
---|
3 | use namespace::autoclean; |
---|
4 | |
---|
5 | BEGIN { 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 | |
---|
15 | Sophie::Controller::Root - Root Controller for Sophie |
---|
16 | |
---|
17 | =head1 DESCRIPTION |
---|
18 | |
---|
19 | [enter your description here] |
---|
20 | |
---|
21 | =head1 METHODS |
---|
22 | |
---|
23 | =cut |
---|
24 | |
---|
25 | sub 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 | |
---|
41 | The root page (/) |
---|
42 | |
---|
43 | =cut |
---|
44 | |
---|
45 | sub index :Path :Args(0) { |
---|
46 | my ( $self, $c ) = @_; |
---|
47 | |
---|
48 | # Hello World |
---|
49 | } |
---|
50 | |
---|
51 | =head2 default |
---|
52 | |
---|
53 | Standard 404 error page |
---|
54 | |
---|
55 | =cut |
---|
56 | |
---|
57 | sub default :Path { |
---|
58 | my ( $self, $c ) = @_; |
---|
59 | $c->response->body( 'Page not found' ); |
---|
60 | $c->response->status(404); |
---|
61 | } |
---|
62 | |
---|
63 | =head2 end |
---|
64 | |
---|
65 | Attempt to render a view, if needed. |
---|
66 | |
---|
67 | =cut |
---|
68 | |
---|
69 | sub _end : ActionClass('RenderView') {} |
---|
70 | |
---|
71 | sub 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 | |
---|
82 | Olivier Thauvin |
---|
83 | |
---|
84 | =head1 LICENSE |
---|
85 | |
---|
86 | This library is free software. You can redistribute it and/or modify |
---|
87 | it under the same terms as Perl itself. |
---|
88 | |
---|
89 | =cut |
---|
90 | |
---|
91 | __PACKAGE__->meta->make_immutable; |
---|
92 | |
---|
93 | 1; |
---|
Note: See
TracBrowser
for help on using the repository browser.