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 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 9 ▶use File::ShareDir qw/module_dir/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 9 ▶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 9 extends 'CatalystX::AppBuilder';
24  
25 override _build_plugins => sub
26 9 ▶{
Subroutine __ANON__: called CC=1 SCAR=0.0
27 9 my $plugins = super();
28  
29 9 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 9 return $plugins;
46 9 };
47  
48 override _build_config => sub
49 9 ▶{
Subroutine __ANON__: called CC=2 SCAR=6.9
50 9 my $self = shift;
51 9 my $config = super(); # Get what CatalystX::AppBuilder gives you
52  
53 # .. get the path for this name space..
54 9 my $path = File::ShareDir::module_dir( 'OpusVL::AppKit' );
55  
56 9 $config->{'default_view'} = 'AppKitTT';
57  
58 9 $config->{'custom-error-message'} = { 'error-template' => 'error.tt' };
59  
60 # .. add static dir into the config for Static::Simple..
61 9 my $static_dirs = $config->{"Plugin::Static::Simple"}->{include_path};
62 9 push(@$static_dirs, $path . '/root' );
63 9 $config->{"Plugin::Static::Simple"}->{include_path} = $static_dirs;
64 9 $config->{"Plugin::Static::Simple"}->{ignore_extensions} = [qw/tt tt2 db yml/];
65 9 $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 9 my $pdf_path = $config->{'View::PDF::Reuse'}->{'INCLUDE_PATH'};
72 9 push(@$pdf_path, $path . '/root/templates' );
73 9 $config->{'View::PDF::Reuse'}->{'INCLUDE_PATH'} = $pdf_path;
74  
75 # .. add template dir into the config for View::AppKitTT...
76 9 my $inc_path = $config->{'View::AppKitTT'}->{'INCLUDE_PATH'};
77 9 push(@$inc_path, $path . '/root/templates' );
78  
79 # Configure View::AppKitTT...
80 9 my $tt_dirs = $config->{'View::AppKitTT'}->{'INCLUDE_PATH'};
81 # ...(add to include_path)..
82 9 push(@$tt_dirs, $self->inherited_path_to('root','templates') );
83 9 push(@$tt_dirs, $path . '/root/templates' );
84 9 $config->{'View::AppKitTT'}->{'INCLUDE_PATH'} = $tt_dirs;
85 9 $config->{'View::AppKitTT'}->{'TEMPLATE_EXTENSION'} = '.tt';
86 9 $config->{'View::AppKitTT'}->{'WRAPPER'} = 'wrapper.tt';
87 9 $config->{'View::AppKitTT'}->{'PRE_PROCESS'} = 'preprocess.tt';
88  
89 # This is the latest place this can be done and actually have an effect.
90 9 $config->{'View::AppKitTT'}->{RECURSION} = 1;
91  
92 9 $config->{'custom-error-message'}->{'view-name'} = 'AppKitTT';
93 # Configure session handling..
94 9 ▶ $config->{'Plugin::Session'} ||= {};
Condition50%1/2
$config->{"Plugin::Session"} ||= {}
l!l
09
MC/DC0%0/1
$config->{"Plugin::Session"} ||= {}
$config->{"Plugin::Session"}
Truth table50%1/2
A
A= $config->{"Plugin::Session"}
Aresult
11
00
95 9 $config->{'Plugin::Session'}->{flash_to_stash} = 1;
96  
97 9 $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 9 $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 9 $config->{'application_name'} = "OpusVL::AppKit";
133  
134 # we can turn off access controller... but ONLY FOR DEBUGGIN!
135 9 $config->{'appkit_can_access_everything'} = 0;
136  
137 # Configure AppKit Plugin access denied..
138 9 $config->{'appkit_access_denied'} = "access_notallowed";
139  
140 9 $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 9 class => 'Cache::FastMmap',
152 };
153  
154 # Password constraint config
155 9 $config->{'AppKit'}->{'password_min_characters'} = 8;
156 9 $config->{'AppKit'}->{'password_force_numerics'} = 0;
157 9 $config->{'AppKit'}->{'password_force_symbols'} = 0;
158
159 # unbuffer stdout and stderr to prevent logging
160 # getting clogged up.
161 9 select( ( select(\*STDERR), $|=1 )[0] );
162 9 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 9 $config->{'View::Excel'} = { etp_config => { INCLUDE_PATH => [] }};
174  
175 9 return $config;
176 9 };
177  
178 9 1;
179  
180 __END__
« blib/lib/HTML/FormFu/Validator/OpusVL/AppKit/CurrentPasswordValidator.pm ↑ Summary lib/OpusVL/AppKit/Controller/AppKit/User.pm »