lib/MKDoc/Core.pm

filter: Statementstmt 28.0% 14 / 50 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 40.0% 4 / 10 Podpod 0.0% 0 / 6 totaltotal 21.9% 18 / 82 CC 8 SCAR 25.0
CC
8
Cov
23%
main
30.0
plugin_list
12.0
main_import
6.0
CRAP 12.2
« lib/MKDoc/Core/Language.pm ↑ Summary lib/MKDoc/Core/Init.pm »
1 =head1 NAME
2  
3 MKDoc::Core - Framework for MKDoc products.
4  
5  
6 =head1 SUMMARY
7  
8 MKDoc is a web content management system written in Perl which focuses on
9 standards compliance, accessiblity and usability issues, and multi-lingual
10 websites.
11  
12 At MKDoc Ltd we have decided to gradually break up our existing commercial
13 software into a collection of completely independent, well-documented,
14 well-tested open-source CPAN modules.
15  
16 Ultimately we want MKDoc code to be a coherent collection of module
17 distributions, yet each distribution should be usable and useful in itself.
18  
19 L<MKDoc::Core> is a mod_perl application framework. It doesn't do anything
20 useful on its own, however it is used by products such as L<MKDoc::Auth> and
21 L<MKDoc::Forum> which provide functionality.
22  
23 L<MKDoc::Core> is designed to let you setup multiple websites using apache
24 virtual hosting. It also provides L<MKDoc::Setup>, a base setup class which
25 lets you easily install products onto each site.
26  
27 For some more blurb about what L<MKDoc::Core> is and does, you can consult
28 L<MKDoc::Core::Article::Overview>.
29  
30  
31 =head1 INSTALLATION
32  
33 =head2 Install the L<MKDoc::Core> distribution.
34  
35 Install the module on your system. If you are using CPAN, this is done easily:
36  
37 perl -MCPAN -e 'install MKDoc::Forum'
38  
39 CPAN should pull out any dependencies.
40  
41 =head2 Set up the L<MKDoc::Core> master directory.
42  
43 The master directory is used to place resources which are common to all the
44 L<MKDoc::Core> sites which you will want to install on your system such as
45 templates, graphics, and some apache configuration.
46  
47 You need to set up the master directory I<only once>. Once this is done, you
48 will be able to add new L<MKDoc::Core> sites without having to re-do this step.
49 More importantly, once the master directory is set up you will not need to
50 touch your apache config files (or any config file for the matter) in order to
51 install new sites.
52  
53 Please read L<MKDoc::Setup::Core> to learn how to deploy the master directory.
54  
55 =head2 Set up at least an L<MKDoc::Core> site.
56  
57 Once you have set up the master directory, you need to install at least one
58 L<MKDoc::Core> site. This is done using L<MKDoc::Setup::Site>. Please refer to
59 L<MKDoc::Setup::Site> for more details on how to do this.
60  
61 =head2 Set up one or more products on your L<MKDoc::Core> site(s).
62  
63 Once you have a working, basic L<MKDoc::Core> site, you can add compliant
64 products in order to add functionality to the site. You could try out
65 L<MKDoc::Auth> or L<MKDoc::Forum>.
66  
67  
68 =head1 CUSTOMIZATION
69  
70 If you don't like the default templates, you can change the look and feel of by
71 customizing them as appropriate.
72  
73 In order to do so, you need to copy the default templates in your site
74 directory as follows:
75  
76 mkdir -p /var/www/example.com/resources
77 tar zxvf MKDoc-Core-xx.tgz
78 cp -a MKDoc-Core-xx/lib/MKDoc/resources/* /var/www/example.com/resources
79  
80 The templates which now live in /var/www/example.com/resources will be used for
81 the site example.com instead of the default ones.
82  
83 You might also want to customize the templates for all L<MKDoc::Core> sites
84 rather than one specific site. In this case, simply replace your site directory
85 by your L<MKDoc::Core> master directory.
86  
87 =cut
88 package MKDoc::Core;
89 1 ▶use MKDoc::Core::Init;
Subroutine BEGIN: called CC=1 SCAR=0.0
90 1 ▶use MKDoc::Core::Language;
Subroutine BEGIN: called CC=1 SCAR=0.0
91 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
92 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
93  
94  
95 1 our $VERSION = '0.91';
96  
97  
98 sub process
99 0 ▶{
Subroutine process: not called CC=1 SCAR=6.9
Pod undocumented
100 0 my $class = shift;
101 0 MKDoc::Core::Init::init();
102 0 $class->main();
103 0 MKDoc::Core::Init::clean();
104 }
105  
106  
107  
108 sub main
109 0 ▶{
Subroutine main: not called CC=5 SCAR=34.0
Pod undocumented
110 0 my $class = shift;
111 0 my @plugin = $class->plugin_list();
112  
113 0 local $::MKD_Current_Plugin;
114 0 for my $pkg (@plugin) { main_import ($pkg) }
115  
116 0 for my $pkg (@plugin)
117 {
118 0 $::MKD_Current_Plugin = $pkg;
119 0 my $ret = $pkg->main;
120 0 ▶ last if (defined $ret and $ret eq 'TERMINATE');
Branch: 1 branch
BranchTrueFalseTotal
if defined $ret and $ret eq "TERMINATE" 0 0 0
Condition0%0/3
defined $ret and $ret eq "TERMINATE"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ret and $ret eq "TERMINATE"
defined $ret $ret eq "TERMINATE"
Truth table0%0/3
A and B
A= defined $retB= $ret eq "TERMINATE"
ABresult
0X0
100
111
121 }
122 }
123  
124  
125  
126 sub plugin_list
127 0 ▶{
Subroutine plugin_list: not called CC=3 SCAR=24.8
Pod undocumented
128 0 my $class = shift;
129 0 ▶ $::MKD_Plugin_List ||= do {
Condition0%0/3
$main::MKD_Plugin_List ||= do { if (defined $ENV{"MKD__PLUGIN_LIST"}) { eval "use MKDoc::Config"; my(@plugin) = "MKDoc::Config"->config_lines("MKDoc::Config"->PLUGIN_LIST); \@plugin; } else { opendir DD, $ENV{"SITE_DIR"} . '/plugin'; my(@files) = sort(grep(/^\d\d\d\d\d_/, readdir DD)); closedir DD; [map({s/^\d\d\d\d\d_//; $_;} @files)]; } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$main::MKD_Plugin_List ||= do { if (defined $ENV{"MKD__PLUGIN_LIST"}) { eval "use MKDoc::Config"; my(@plugin) = "MKDoc::Config"->config_lines("MKDoc::Config"->PLUGIN_LIST); \@plugin; } else { opendir DD, $ENV{"SITE_DIR"} . '/plugin'; my(@files) = sort(grep(/^\d\d\d\d\d_/, readdir DD)); closedir DD; [map({s/^\d\d\d\d\d_//; $_;} @files)]; } }
$main::MKD_Plugin_List do { if (defined $ENV{"MKD__PLUGIN_LIST"}) { eval "use MKDoc::Config"; my(@plugin) = "MKDoc::Config"->config_lines("MKDoc::Config"->PLUGIN_LIST); \@plugin; } else { opendir DD, $ENV{"SITE_DIR"} . '/plugin'; my(@files) = sort(grep(/^\d\d\d\d\d_/, readdir DD)); closedir DD; [map({s/^\d\d\d\d\d_//; $_;} @files)]; } }
Truth table0%0/3
A ||= B
A= $main::MKD_Plugin_ListB= do { if (defined $ENV{"MKD__PLUGIN_LIST"}) { eval "use MKDoc::Config"; my(@plugin) = "MKDoc::Config"->config_lines("MKDoc::Config"->PLUGIN_LIST); \@plugin; } else { opendir DD, $ENV{"SITE_DIR"} . '/plugin'; my(@files) = sort(grep(/^\d\d\d\d\d_/, readdir DD)); closedir DD; [map({s/^\d\d\d\d\d_//; $_;} @files)]; } }
ABresult
1X1
011
000
130  
131 # this is for backwards compatibility with MKDoc 1.6
132 0 ▶ if (defined $ENV{MKD__PLUGIN_LIST})
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ENV{'MKD__PLUGIN_LIST'}) { } 0 0 0
133 {
134 0 eval "use MKDoc::Config";
135 0 my @plugin = MKDoc::Config->config_lines ( MKDoc::Config->PLUGIN_LIST );
136 0 \@plugin;
137 }
138 else
139 {
140 0 opendir DD, $ENV{SITE_DIR} . '/plugin';
141 0 my @files = sort grep /^\d\d\d\d\d_/, readdir (DD);
142 0 closedir DD;
143 0 [ map { s/^\d\d\d\d\d_//; $_ } @files ];
144 }
145 };
146  
147 0 return @{$::MKD_Plugin_List};
148 }
149  
150  
151  
152 sub main_import
153 0 ▶{
Subroutine main_import: not called CC=2 SCAR=17.9
Pod undocumented
154 0 my $pkg = shift;
155  
156 0 my $file = $pkg;
157 0 $file =~ s/::/\//g;
158 0 $file .= '.pm';
159  
160 0 ▶ $INC{$file} && return;
Branch: 1 branch
BranchTrueFalseTotal
$INC{$file} and return 0 0 0
161  
162 0 require $file;
163 0 import $pkg;
164 }
165  
166  
167 sub core_dir
168 0 ▶{
Subroutine core_dir: not called CC=1 SCAR=6.9
Pod undocumented
169 0 return $ENV{MKDOC_DIR};
170 }
171  
172  
173 sub site_dir
174 0 ▶{
Subroutine site_dir: not called CC=1 SCAR=6.9
Pod undocumented
175 0 return $ENV{SITE_DIR};
176 }
177  
178  
179 1 1;
180  
181  
182 =head1 AUTHOR
183  
184 Copyright 2003 - MKDoc Holdings Ltd.
185  
186 Author: Jean-Michel Hiver
187  
188 This module is free software and is distributed under the same license as Perl
189 itself. Use it at your own risk.
190  
191  
192 =head1 SEE ALSO
193  
194 L<Petal> TAL for perl
195 MKDoc: http://www.mkdoc.com/
196  
197 Help us open-source MKDoc. Join the mkdoc-modules mailing list:
198  
199 mkdoc-modules@lists.webarch.co.uk
200  
201 =cut
202  
203  
204 __END__
« lib/MKDoc/Core/Language.pm ↑ Summary lib/MKDoc/Core/Init.pm »