blib/lib/OpusVL/AppKit/Builder.pm

filter: Statementstmt 100% 56 / 56 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 96.8% 62 / 64 CC 2 SCAR 2.9
CC
2
Cov
98%
__ANON__
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.3
« blib/lib/HTML/FormFu/Validator/OpusVL/AppKit/CurrentPasswordValidator.pm ↑ Summary lib/OpusVL/AppKit/Controller/AppKit/User.pm »
1 package OpusVL::AppKit::Builder;
2  
3 ##################################################################################################################################
4 # use lines.
5 ##################################################################################################################################
6 11 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 11 ▶use File::ShareDir qw/module_dir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 11 ▶use OpusVL::AppKit::Form::Login;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 ##################################################################################################################################
11 # moose calls.
12 ##################################################################################################################################
13 #
14 # The following Moose calls are used to interact with the CatalystX::AppBuilder. You can see it overrides the building of 2
15 # AppBuilder variables forcing the AppBuilder to create our Builder object with our own Plugins and Config.
16 #
17 # FYI: the 2 varables are
18 # plugins - ArrayRef of Plugin names to load.
19 # config - HashRef of configuration for the application.
20 #
21 #################################################################################################################################
22  
23 11 extends 'CatalystX::AppBuilder';
24  
25 override _build_plugins => sub
26 {
27 10 ▶ my $plugins = super();
Subroutine __ANON__: called CC=1 SCAR=0.0
28  
29 10 push @$plugins, qw(
30 ConfigLoader::Environment
31 Static::Simple
32 CustomErrorMessage
33 Authentication
34 Authorization::Roles
35 Session
36 Session::Store::FastMmap
37 Session::State::Cookie
38 Cache
39 +CatalystX::SimpleLogin
40 +CatalystX::VirtualComponents
41 +OpusVL::AppKit::Plugin::AppKit
42 +OpusVL::AppKit::Plugin::AppKitControllerSorter
43 );
44  
45 10 return $plugins;
46 11 };
47  
48 override _build_config => sub
49 {
50 10 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
51 10 my $config = super(); # Get what CatalystX::AppBuilder gives you
52  
53 # .. get the path for this name space..
54 10 my $path = File::ShareDir::module_dir( 'OpusVL::AppKit' );
55  
56 10 $config->{'default_view'} = 'AppKitTT';
57  
58 10 $config->{'custom-error-message'} = { 'error-template' => 'error.tt' };
59  
60 # .. add static dir into the config for Static::Simple..
61 10 my $static_dirs = $config->{"Plugin::Static::Simple"}->{include_path};
62 10 push(@$static_dirs, $path . '/root' );
63 10 $config->{"Plugin::Static::Simple"}->{include_path} = $static_dirs;
64 10 $config->{"Plugin::Static::Simple"}->{ignore_extensions} = [qw/tt tt2 db yml/];
65 10 $config->{encoding} = 'UTF-8';
66  
67 # FIXME: this line appears to cause a problem
68 #$config->{'Controller::HTML::FormFu'}->{constructor}->{config_file_path} = [ $path . '/root/forms' ];
69  
70 # .. add template dir into the config for View::PDF::Reuse...
71 10 my $pdf_path = $config->{'View::PDF::Reuse'}->{'INCLUDE_PATH'};
72 10 push(@$pdf_path, $path . '/root/templates' );
73 10 $config->{'View::PDF::Reuse'}->{'INCLUDE_PATH'} = $pdf_path;
74  
75 # .. add template dir into the config for View::AppKitTT...
76 10 my $inc_path = $config->{'View::AppKitTT'}->{'INCLUDE_PATH'};
77 10 push(@$inc_path, $path . '/root/templates' );
78  
79 # Configure View::AppKitTT...
80 10 my $tt_dirs = $config->{'View::AppKitTT'}->{'INCLUDE_PATH'};
81 # ...(add to include_path)..
82 10 push(@$tt_dirs, $self->inherited_path_to('root','templates') );
83 10 push(@$tt_dirs, $path . '/root/templates' );
84 10 $config->{'View::AppKitTT'}->{'INCLUDE_PATH'} = $tt_dirs;
85 10 $config->{'View::AppKitTT'}->{'TEMPLATE_EXTENSION'} = '.tt';
86 10 $config->{'View::AppKitTT'}->{'WRAPPER'} = 'wrapper.tt';
87 10 $config->{'View::AppKitTT'}->{'PRE_PROCESS'} = 'preprocess.tt';
88  
89 # This is the latest place this can be done and actually have an effect.
90 10 $config->{'View::AppKitTT'}->{RECURSION} = 1;
91  
92 10 $config->{'custom-error-message'}->{'view-name'} = 'AppKitTT';
93 # Configure session handling..
94 10 ▶ $config->{'Plugin::Session'} ||= {};
Condition50%1/2
$config->{"Plugin::Session"} ||= {}
l!l
010
MC/DC0%0/1
$config->{"Plugin::Session"} ||= {}
$config->{"Plugin::Session"}
Truth table50%1/2
A
A= $config->{"Plugin::Session"}
Aresult
11
00
95 10 $config->{'Plugin::Session'}->{flash_to_stash} = 1;
96  
97 10 $config->{'Plugin::Authentication'} =
98 {
99 default_realm => 'appkit',
100 appkit =>
101 {
102 credential =>
103 {
104 class => 'Password',
105 password_type => 'self_check',
106 },
107 store =>
108 {
109 class => 'DBIx::Class',
110 user_model => 'AppKitAuthDB::User',
111 role_relation => 'roles',
112 role_field => 'role',
113 }
114 },
115 };
116  
117 10 $config->{'View::Email'} =
118 {
119 stash_key => 'email',
120 default =>
121 {
122 content_type => 'text/plain',
123 charset => 'utf-8'
124 },
125 sender =>
126 {
127 mailer => 'SMTP',
128 }
129 };
130  
131 # set the appkit_friendly_name..
132 10 $config->{'application_name'} = "OpusVL::AppKit";
133  
134 # we can turn off access controller... but ONLY FOR DEBUGGIN!
135 10 $config->{'appkit_can_access_everything'} = 0;
136  
137 # Configure AppKit Plugin access denied..
138 10 $config->{'appkit_access_denied'} = "access_notallowed";
139  
140 10 $config->{'Controller::Login'} =
141 {
142 traits => [
143 '+OpusVL::AppKit::TraitFor::Controller::Login::SetHomePageFlag',
144 '+OpusVL::AppKit::TraitFor::Controller::Login::NewSessionIdOnLogin',
145 '-Login::WithRedirect'
146 ],
147 login_form_class => 'OpusVL::AppKit::Form::Login',
148 };
149  
150 $config->{'Plugin::Cache'}{backend} = {
151 10 class => 'Cache::FastMmap',
152 };
153  
154 # Password constraint config
155 10 $config->{'AppKit'}->{'password_min_characters'} = 8;
156 10 $config->{'AppKit'}->{'password_force_numerics'} = 0;
157 10 $config->{'AppKit'}->{'password_force_symbols'} = 0;
158
159 # unbuffer stdout and stderr to prevent logging
160 # getting clogged up.
161 10 select( ( select(\*STDERR), $|=1 )[0] );
162 10 select( ( select(\*STDOUT), $|=1 )[0] );
163  
164 # NOTE: if you want to use Memcahced in your app add this to your builder,
165 #
166 # $config->{'Plugin::Cache'}{backend} = {
167 # class => "Cache::Memcached::libmemcached",
168 # servers => ['127.0.0.1:11211'],
169 # debug => 2,
170 # };
171  
172 # set this up empty for now.
173 10 $config->{'View::Excel'} = { etp_config => { INCLUDE_PATH => [] }};
174  
175 10 return $config;
176 11 };
177  
178 11 1;
179  
180 __END__
181  
182 =pod
183  
184 =encoding UTF-8
185  
186 =head1 NAME
187  
188 OpusVL::AppKit::Builder
189  
190 =head1 VERSION
191  
192 version 2.24
193  
194 =head1 SYNOPSIS
195  
196 See: OpusVL::AppKit
197  
198 Inheriting this app using AppBuilder will give your application the following:
199  
200 Catalyst::Plugin::Static::Simple
201 Catalyst::Plugin::CustomErrorMessage
202 Catalyst::Plugin::Authentication
203 Catalyst::Plugin::Authorization::Roles
204 Catalyst::Plugin::Session
205 Catalyst::Plugin::Session::Store::FastMmap
206 Catalyst::Plugin::Session::State::Cookie
207 CatalystX::SimpleLogin
208 CatalystX::VirtualComponents
209 OpusVL::AppKit::Plugin::AppKit
210  
211 Controller::Root
212  
213 View::AppKitTT
214 View::Email
215 View::Download
216 View::JSON
217 View::Excel
218  
219 Plugins
220 All the standard ones we use as per their documentation.
221 We have created our own AppKit Plugin, which is used to drive the AppKit specific code . At the moment it is used
222 for ACL rules, Portlets and Navigation... I guess in time it will evolve, but now works ok.
223  
224 Controllers
225
226 The Root controller is used to drive the GUI, it is pretty simple so could be over written if required (i think?).
227 The Root controller (and any you want to work with the GUI) are based on the L<OpusVL::AppKit::Base::Controller>, this
228 turns a controller into an "AppKit aware" controller and it can tell the AppKit what its name is, what Porlets it has, etc.
229 See L<OpusVL::AppKit::Base::Controller> for more information.
230  
231 Views
232  
233 Currently only the AppKitTT view is used and this is to create the GUI... the view is configured for the GUI, but it could be reused (i think).
234 The other views are available to be utilised in furture development.
235  
236 =head1 DESCRIPTION
237  
238 This extends CatalystX::AppBuilder so the OpusVL::AppKit can be inherited.
239  
240 Here we set the configuration required for the AppKit to run (inside another app)
241
242 The supporting files like templates etc. are stored in the modules 'auto' directory
243 see. L<File::ShareDir>
244  
245 This creates a catalyst app with the following Plugins loaded:
246 L<Catalyst::Plugin::Static::Simple>
247 L<Catalyst::Plugin::Unicode>
248 L<Catalyst::Plugin::CustomErrorMessage>
249 L<Catalyst::Plugin::Authentication>
250 L<Catalyst::Plugin::Authorization::Roles>
251 L<Catalyst::Plugin::Session>
252 L<Catalyst::Plugin::Session::Store::FastMmap>
253 L<Catalyst::Plugin::Session::State::Cookie>
254 L<CatalystX::SimpleLogin>
255 L<CatalystX::VirtualComponents>
256 L<OpusVL::AppKit::Plugin::AppKit>
257  
258 This also configures the application in the following way:
259  
260 default_view - Set to 'AppKitTT'
261 custom-error-message - enable customer error msg.
262 static - set static to auto dir
263 OpusVL::AppKit::Plugin::AppKit - used to config ACL rules.
264 View::AppKitTT - set include paths, wrapper, etc.
265 Plugin::Authentication - used to authenicate users.
266 View::Email - use to send any emails
267  
268 =head1 NAME
269  
270 OpusVL::AppKit::Builder - Builder class for OpusVL::AppKit
271  
272 =head1 SEE ALSO
273  
274 L<File::ShareDir>,
275 L<CatalystX::AppBuilder>,
276 L<OpusVL::AppKit>,
277 L<Catalyst>
278  
279 =head1 AUTHOR
280  
281 OpusVL - www.opusvl.com
282  
283 =head1 COPYRIGHT AND LICENSE
284  
285 This software is copyright (c) 2010 by OpusVL - www.opusvl.com.
286  
287 This is free software; you can redistribute it and/or modify it under
288 the same terms as the Perl 5 programming language system itself.
289  
290 =cut
« blib/lib/HTML/FormFu/Validator/OpusVL/AppKit/CurrentPasswordValidator.pm ↑ Summary lib/OpusVL/AppKit/Controller/AppKit/User.pm »