blib/lib/OpusVL/AppKit/Controller/Root.pm untested

filter: Statementstmt 0.0% 0 / 43 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 10 Podpod 0.0% 0 / 7 totaltotal 0.0% 0 / 75 CC 7 SCAR 21.8
CC
7
Cov
0%
end
20.0
access_denied
12.0
default
6.0
CRAP 8.9
1 package OpusVL::AppKit::Controller::Root;
2  
3  
4 ############################################################################################################
5 use Moose;
6 use namespace::autoclean;
7  
8 BEGIN { extends 'Catalyst::Controller'; }
9 with 'OpusVL::AppKit::RolesFor::Controller::GUI';
10  
11 use File::ShareDir ':ALL';
12  
13 __PACKAGE__->config->{namespace} = '';
14
15 sub auto
16 : Action
17 : AppKitAllAccess
18 {
19 my ( $self, $c ) = @_;
20 return 1;
21 }
22  
23  
24 sub index
25 :Path
26 :Args(0)
27 : AppKitFeature('Home Page')
28 {
29 my ( $self, $c ) = @_;
30  
31 $c->_appkit_stash_portlets;
32  
33 $c->stash->{template} = 'index.tt';
34 $c->stash->{homepage} = 1;
35 }
36  
37  
38 sub default :Path
39 {
40 my ( $self, $c ) = @_;
41 delete $c->stash->{current_view} if defined $c->stash->{current_view}; # ensure default view.
42 $c->stash->{template} = '404.tt';
43 $c->response->status(404);
44 $c->stash->{homepage} = 1;
45 $c->detach;
46 }
47  
48 sub not_found :Private
49 {
50 my ($self, $c) = @_;
51 $c->forward('/default');
52 }
53  
54 sub access_denied : Private
55 {
56 my ( $self, $c ) = @_;
57 $c->REST_403 if($c->in_REST_action);
58 $c->stash->{template} = '403.tt';
59 delete $c->stash->{current_view} if defined $c->stash->{current_view}; # ensure default view.
60 $c->response->status(403);
61 $c->stash->{homepage} = 1;
62 $c->detach('View::AppKitTT');
63 }
64  
65  
66 sub end : ActionClass('RenderView')
67 {
68 my ( $self, $c ) = @_;
69 unless($c->config->{no_clickjack_protection} || $c->stash->{no_clickjack_protection})
70 {
71 if($c->config->{clickjack_same_origin})
72 {
73 $c->response->headers->header( 'X-FRAME-OPTIONS' => 'SAMEORIGIN' );
74 }
75 else
76 {
77 $c->response->headers->header( 'X-FRAME-OPTIONS' => 'DENY' );
78 }
79 }
80 $c->response->headers->header('X-XSS-Protection' => '1; mode=block');
81 if($c->config->{ssl_only})
82 {
83 $c->response->headers->header('Strict-Transport-Security' => 'max-age=31536000; includeSubDomains');
84 }
85 $c->response->headers->header('X-Content-Type-Options' => 'nosniff');
86 }
87  
88 1;
89  
90 __END__
91  
92 =pod
93  
94 =encoding UTF-8
95  
96 =head1 NAME
97  
98 OpusVL::AppKit::Controller::Root
99  
100 =head1 VERSION
101  
102 version 2.22
103  
104 =head1 DESCRIPTION
105  
106 The OpusVL::AppKit is intended to be inherited by another Catalyst App using AppBuilder.
107  
108 The current intention is that Apps that use AppKit do not need to have their own Root Controller,
109 but use this one.
110 If you app requires its own Root.pm Controller, you should inherite this one
111  
112 This should provide all the base funcationallity required for delivery of standard sites
113 developed by the OpusVL team.
114  
115 =head1 NAME
116  
117 OpusVL::AppKit::Controller::Root - Root Controller for OpusVL::AppKit
118  
119 =head1 METHODS
120  
121 =head2 auto
122  
123 =head2 index
124 This is intended to be seen as the AppKit home page.
125  
126 =head2 access_notallowed
127 This called by the ACL method when an access control rule is broken. (including not being logged in!)
128 Configured in myapp.conf :
129 <OpusVL::AppKit::Plugin::AppKit>
130 access_denied "access_notallowed"
131 </OpusVL::AppKit::Plugin::AppKit>
132  
133 =head2 end
134 Attempt to render a view, if needed.
135  
136 =head1 AUTHOR
137  
138 OpusVL - www.opusvl.com
139  
140 =head1 COPYRIGHT AND LICENSE
141  
142 This software is copyright (c) 2010 by OpusVL - www.opusvl.com.
143  
144 This is free software; you can redistribute it and/or modify it under
145 the same terms as the Perl 5 programming language system itself.
146  
147 =cut