blib/lib/OpusVL/AppKit/Builder.pm

filter: Statementstmt 100% 54 / 54 Branchbran n/a Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 96.7% 60 / 62 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 12 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 12 ▶use File::ShareDir qw/module_dir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 12 ▶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 12 extends 'CatalystX::AppBuilder';
24  
25 override _build_plugins => sub
26 {
27 11 ▶ my $plugins = super();
Subroutine __ANON__: called CC=1 SCAR=0.0
28  
29 11 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 11 return $plugins;
46 12 };
47  
48 override _build_config => sub
49 {
50 11 ▶ my $self = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
51 11 my $config = super(); # Get what CatalystX::AppBuilder gives you
52  
53 # .. get the path for this name space..
54 11 my $path = File::ShareDir::module_dir( 'OpusVL::AppKit' );
55  
56 11 $config->{'default_view'} = 'AppKitTT';
57  
58 11 $config->{'custom-error-message'} = { 'error-template' => 'error.tt' };
59  
60 # .. add static dir into the config for Static::Simple..
61 11 my $static_dirs = $config->{"Plugin::Static::Simple"}->{include_path};
62 11 push(@$static_dirs, $path . '/root' );
63 11 $config->{"Plugin::Static::Simple"}->{include_path} = $static_dirs;
64 11 $config->{"Plugin::Static::Simple"}->{ignore_extensions} = [qw/tt tt2 db yml/];
65 11 $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 11 my $pdf_path = $config->{'View::PDF::Reuse'}->{'INCLUDE_PATH'};
72 11 push(@$pdf_path, $path . '/root/templates' );
73 11 $config->{'View::PDF::Reuse'}->{'INCLUDE_PATH'} = $pdf_path;
74  
75 # .. add template dir into the config for View::AppKitTT...
76 11 my $inc_path = $config->{'View::AppKitTT'}->{'INCLUDE_PATH'};
77 11 push(@$inc_path, $path . '/root/templates' );
78  
79 # Configure View::AppKitTT...
80 11 my $tt_dirs = $config->{'View::AppKitTT'}->{'INCLUDE_PATH'};
81 # ...(add to include_path)..
82 11 push(@$tt_dirs, $self->inherited_path_to('root','templates') );
83 11 push(@$tt_dirs, $path . '/root/templates' );
84 11 $config->{'View::AppKitTT'}->{'INCLUDE_PATH'} = $tt_dirs;
85 11 $config->{'View::AppKitTT'}->{'TEMPLATE_EXTENSION'} = '.tt';
86 11 $config->{'View::AppKitTT'}->{'WRAPPER'} = 'wrapper.tt';
87 11 $config->{'View::AppKitTT'}->{'PRE_PROCESS'} = 'preprocess.tt';
88  
89 # This is the latest place this can be done and actually have an effect.
90 11 $config->{'View::AppKitTT'}->{RECURSION} = 1;
91  
92 11 $config->{'custom-error-message'}->{'view-name'} = 'AppKitTT';
93 # Configure session handling..
94 11 ▶ $config->{'Plugin::Session'} ||= {};
Condition50%1/2
$config->{"Plugin::Session"} ||= {}
l!l
011
MC/DC0%0/1
$config->{"Plugin::Session"} ||= {}
$config->{"Plugin::Session"}
Truth table50%1/2
A
A= $config->{"Plugin::Session"}
Aresult
11
00
95 11 $config->{'Plugin::Session'}->{flash_to_stash} = 1;
96  
97 11 $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 11 $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 11 $config->{'application_name'} = "OpusVL::AppKit";
133  
134 # we can turn off access controller... but ONLY FOR DEBUGGIN!
135 11 $config->{'appkit_can_access_everything'} = 0;
136  
137 # Configure AppKit Plugin access denied..
138 11 $config->{'appkit_access_denied'} = "access_notallowed";
139  
140 11 $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 11 class => 'Cache::FastMmap',
152 };
153  
154 # Password constraint config
155 11 $config->{'AppKit'}->{'password_min_characters'} = 8;
156 11 $config->{'AppKit'}->{'password_force_numerics'} = 0;
157 11 $config->{'AppKit'}->{'password_force_symbols'} = 0;
158
159 # NOTE: if you want to use Memcahced in your app add this to your builder,
160 #
161 # $config->{'Plugin::Cache'}{backend} = {
162 # class => "Cache::Memcached::libmemcached",
163 # servers => ['127.0.0.1:11211'],
164 # debug => 2,
165 # };
166  
167 # set this up empty for now.
168 11 $config->{'View::Excel'} = { etp_config => { INCLUDE_PATH => [] }};
169  
170 11 return $config;
171 12 };
172  
173 12 1;
174  
175 __END__
176  
177 =pod
178  
179 =encoding UTF-8
180  
181 =head1 NAME
182  
183 OpusVL::AppKit::Builder
184  
185 =head1 VERSION
186  
187 version 2.22
188  
189 =head1 SYNOPSIS
190  
191 See: OpusVL::AppKit
192  
193 Inheriting this app using AppBuilder will give your application the following:
194  
195 Catalyst::Plugin::Static::Simple
196 Catalyst::Plugin::CustomErrorMessage
197 Catalyst::Plugin::Authentication
198 Catalyst::Plugin::Authorization::Roles
199 Catalyst::Plugin::Session
200 Catalyst::Plugin::Session::Store::FastMmap
201 Catalyst::Plugin::Session::State::Cookie
202 CatalystX::SimpleLogin
203 CatalystX::VirtualComponents
204 OpusVL::AppKit::Plugin::AppKit
205  
206 Controller::Root
207  
208 View::AppKitTT
209 View::Email
210 View::Download
211 View::JSON
212 View::Excel
213  
214 Plugins
215 All the standard ones we use as per their documentation.
216 We have created our own AppKit Plugin, which is used to drive the AppKit specific code . At the moment it is used
217 for ACL rules, Portlets and Navigation... I guess in time it will evolve, but now works ok.
218  
219 Controllers
220
221 The Root controller is used to drive the GUI, it is pretty simple so could be over written if required (i think?).
222 The Root controller (and any you want to work with the GUI) are based on the L<OpusVL::AppKit::Base::Controller>, this
223 turns a controller into an "AppKit aware" controller and it can tell the AppKit what its name is, what Porlets it has, etc.
224 See L<OpusVL::AppKit::Base::Controller> for more information.
225  
226 Views
227  
228 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).
229 The other views are available to be utilised in furture development.
230  
231 =head1 DESCRIPTION
232  
233 This extends CatalystX::AppBuilder so the OpusVL::AppKit can be inherited.
234  
235 Here we set the configuration required for the AppKit to run (inside another app)
236
237 The supporting files like templates etc. are stored in the modules 'auto' directory
238 see. L<File::ShareDir>
239  
240 This creates a catalyst app with the following Plugins loaded:
241 L<Catalyst::Plugin::Static::Simple>
242 L<Catalyst::Plugin::Unicode>
243 L<Catalyst::Plugin::CustomErrorMessage>
244 L<Catalyst::Plugin::Authentication>
245 L<Catalyst::Plugin::Authorization::Roles>
246 L<Catalyst::Plugin::Session>
247 L<Catalyst::Plugin::Session::Store::FastMmap>
248 L<Catalyst::Plugin::Session::State::Cookie>
249 L<CatalystX::SimpleLogin>
250 L<CatalystX::VirtualComponents>
251 L<OpusVL::AppKit::Plugin::AppKit>
252  
253 This also configures the application in the following way:
254  
255 default_view - Set to 'AppKitTT'
256 custom-error-message - enable customer error msg.
257 static - set static to auto dir
258 OpusVL::AppKit::Plugin::AppKit - used to config ACL rules.
259 View::AppKitTT - set include paths, wrapper, etc.
260 Plugin::Authentication - used to authenicate users.
261 View::Email - use to send any emails
262  
263 =head1 NAME
264  
265 OpusVL::AppKit::Builder - Builder class for OpusVL::AppKit
266  
267 =head1 SEE ALSO
268  
269 L<File::ShareDir>,
270 L<CatalystX::AppBuilder>,
271 L<OpusVL::AppKit>,
272 L<Catalyst>
273  
274 =head1 AUTHOR
275  
276 OpusVL - www.opusvl.com
277  
278 =head1 COPYRIGHT AND LICENSE
279  
280 This software is copyright (c) 2010 by OpusVL - www.opusvl.com.
281  
282 This is free software; you can redistribute it and/or modify it under
283 the same terms as the Perl 5 programming language system itself.
284  
285 =cut
« blib/lib/HTML/FormFu/Validator/OpusVL/AppKit/CurrentPasswordValidator.pm ↑ Summary lib/OpusVL/AppKit/Controller/AppKit/User.pm »