OpenInteract2/Brick/Apache2.pm

filter: Statementstmt 95.0% 19 / 20 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 5 totaltotal 80.0% 28 / 35 CC 2 SCAR 2.2
CC
2
Cov
91%
load
2.1
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« OpenInteract2/Brick/Messages.pm ↑ Summary OpenInteract2/Brick/CGI.pm »
1 package OpenInteract2::Brick::Apache2;
2  
3 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 87 ▶use base qw( OpenInteract2::Brick );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 87 ▶use OpenInteract2::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 87 my %INLINED_SUBS = (
8 'startup_mp2.pl' => 'STARTUP_MP2PL',
9 'httpd_mp2_solo.conf' => 'HTTPD_MP2_SOLOCONF',
10 );
11  
12 87 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
Pod undocumented
13 87 return 'apache2';
14 }
15  
16 3 ▶sub get_resources {
Subroutine get_resources: called CC=1 SCAR=0.0
Pod undocumented
17 return (
18 3 'startup_mp2.pl' => [ 'conf startup_mp2.pl', 'yes' ],
19 'httpd_mp2_solo.conf' => [ 'conf httpd_mp2_solo.conf', 'yes' ],
20 );
21 }
22  
23 2 ▶sub load {
Subroutine load: called CC=2 SCAR=7.4
Pod undocumented
24 2 my ( $self, $resource_name ) = @_;
25 2 my $inline_sub_name = $INLINED_SUBS{ $resource_name };
26 2 ▶ unless ( $inline_sub_name ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($inline_sub_name) 0 2 2
27 0 OpenInteract2::Exception->throw(
28 "Resource name '$resource_name' not found ",
29 "in ", ref( $self ), "; cannot load content." );
30 }
31 2 return $self->$inline_sub_name();
32 }
33  
34 87 OpenInteract2::Brick->register_factory_type( get_name() => __PACKAGE__ );
35  
36 =pod
37  
38 =head1 NAME
39  
40 OpenInteract2::Brick::Apache2 - All resources used for creating Apache 2.x configurations in a new website
41  
42 =head1 SYNOPSIS
43  
44 oi2_manage create_website --website_dir=/path/to/site
45  
46 =head1 DESCRIPTION
47  
48 This class just holds all the static resources used for creating Apache 2.x configuration files when creating a website.
49  
50 These resources are associated with OpenInteract2 version 1.99_06.
51  
52 =head2 Resources
53  
54 You can grab resources individually using the names below and
55 C<load_resource()> and C<copy_resources_to()>, or you can copy all the
56 resources at once using C<copy_all_resources_to()> -- see
57 L<OpenInteract2::Brick> for details.
58  
59 =over 4
60  
61  
62 =item B<startup_mp2.pl>
63  
64 =item B<httpd_mp2_solo.conf>
65  
66  
67 =back
68  
69 =head1 COPYRIGHT
70  
71 Copyright (c) 2005 Chris Winters. All rights reserved.
72  
73 This library is free software; you can redistribute it and/or modify
74 it under the same terms as Perl itself.
75  
76 =head1 AUTHORS
77  
78  
79 Chris Winters E<lt>chris@cwinters.comE<gt>
80  
81  
82 =cut
83  
84  
85 1 ▶sub STARTUP_MP2PL {
Subroutine STARTUP_MP2PL: called CC=1 SCAR=0.0
Pod undocumented
86 1 return <<'SOMELONGSTRING';
87 #!/usr/bin/perl
88  
89 use strict;
90 use Apache2 ();
91 use Apache2::OpenInteract2;
92 use CGI;
93 use Log::Log4perl;
94 use OpenInteract2::Config::Bootstrap;
95 use OpenInteract2::Constants qw( :log );
96 use OpenInteract2::Context;
97  
98 CGI->compile( ':all' );
99  
100 my $BOOTSTRAP_CONFIG_FILE = '[% website_dir %]/conf/bootstrap.ini';
101  
102 {
103 Log::Log4perl::init( '[% website_dir %]/conf/log4perl.conf' );
104 my $bootstrap = OpenInteract2::Config::Bootstrap->new({
105 filename => $BOOTSTRAP_CONFIG_FILE
106 });
107 my $ctx = OpenInteract2::Context->create(
108 $bootstrap, { temp_lib_create => 'create' } );
109 $ctx->assign_request_type( 'apache2' );
110 $ctx->assign_response_type( 'apache2' );
111 }
112  
113 1;
114  
115 SOMELONGSTRING
116 }
117  
118 1 ▶sub HTTPD_MP2_SOLOCONF {
Subroutine HTTPD_MP2_SOLOCONF: called CC=1 SCAR=0.0
Pod undocumented
119 1 return <<'SOMELONGSTRING';
120 # Change manually:
121 # -- Change '127.0.0.1' to your IP address
122 # -- Change 'webmaster@mycompany.com' to your contact e-mail address
123 # -- Change 'www.mycompany.com' to your website hostname
124 # -- If you wish to run the mod_perl server on a port other than 80,
125 # change it in the 'Listen' and 'VirtualHost' directives
126  
127 # If you're using Named virtual hosts, just remove the 'Listen' line
128  
129 Listen 127.0.0.1:80
130 <VirtualHost 127.0.0.1:80>
131 ServerAdmin webmaster@mycompany.com
132 ServerName www.mycompany.com
133 DocumentRoot [% website_dir %]/html
134  
135 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
136 CustomLog [% website_dir %]/logs/access_log_mp2 combined
137 ErrorLog [% website_dir %]/logs/error_log_mp2
138  
139 # This reads in all your SPOPS objects, sets up aliases, database
140 # handles, template processing objects, etc.
141  
142 PerlRequire [% website_dir %]/conf/startup_mp2.pl
143  
144 # This sends all incoming requests to the OpenInteract Apache 2.x
145 # content handler (Apache2::OpenInteract2)
146  
147 # NOTE: If you're not running under the root context, just
148 # change the path specified in 'Location' to the server
149 # configuration key 'context_info.deployed_under'
150  
151 <Location />
152 SetHandler perl-script
153 PerlResponseHandler Apache2::OpenInteract2
154 </Location>
155  
156 <Location /images>
157 SetHandler default-handler
158 </Location>
159  
160 ScriptAlias /cgi-bin [% website_dir %]/cgi-bin
161 <Location /cgi-bin>
162 SetHandler cgi-script
163 AllowOverride None
164 Options None
165 Order allow,deny
166 Allow from all
167 </Location>
168  
169 </VirtualHost>
170  
171 SOMELONGSTRING
172 }
173  
« OpenInteract2/Brick/Messages.pm ↑ Summary OpenInteract2/Brick/CGI.pm »