OurCal/View/HTML.pm

filter: Statementstmt 34.2% 13 / 38 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 57.1% 4 / 7 Podpod 100% 3 / 3 totaltotal 28.9% 20 / 69 CC 10 SCAR 42.4
CC
10
Cov
23%
handle
110.0
new
2.0
mime_type
2.0
CRAP 69.2
« OurCal/Handler/CGI.pm ↑ Summary OurCal/Provider/ICalendar.pm »
1 package OurCal::View::HTML;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use OurCal::Todo;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use OurCal::Event;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 =head1 NAME
9  
10 OurCal::View::HTML - an HTML view for OurCal
11  
12 =head1 METHODS
13  
14 =cut
15  
16 =head2 new
17  
18 =cut
19  
20 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod documented
21 0 my ($class, %what) = @_;
22 0 return bless \%what, $class;
23 }
24  
25  
26 =head2 mime_type
27  
28 Returns the mime_type for this view 'text/html'
29  
30 =cut
31  
32 0 ▶sub mime_type {
Subroutine mime_type: not called CC=1 SCAR=6.9
Pod documented
33 0 return "text/html";
34 }
35  
36 =head2 handle <opt[s]>
37  
38 Returns HTML representing the current mode.
39  
40 =cut
41  
42 0 ▶sub handle {
Subroutine handle: not called CC=10 SCAR=47.0
Pod documented
43 0 my $self = shift;
44 0 my %opts = @_;
45 0 my $handler = $self->{handler};
46 0 my $config = $self->{config};
47 0 my $cal = $self->{calendar};
48 0 my $mode = $handler->mode;
49  
50  
51 0 ▶ if ("save_todo" eq $mode) {
Branch: 4 branches
BranchTrueFalseTotal
if ('save_todo' eq $mode) { } 0 0 0
elsif ('del_todo' eq $mode) { } 0 0 0
elsif ('save_event' eq $mode) { } 0 0 0
elsif ('del_event' eq $mode) { } 0 0 0
52 0 my %what = ( description => $handler->param('description') );
53 0 ▶ $what{user} = $handler->user if defined $handler->user;
Branch: 1 branch
BranchTrueFalseTotal
if defined $handler->user 0 0 0
54 0 $cal->save_todo( OurCal::Todo->new(%what));
55 } elsif ("del_todo" eq $mode) {
56 0 $cal->del_todo( OurCal::Todo->new( id => $handler->param('id') ) );
57 } elsif ("save_event" eq $mode) {
58 0 ▶ die "Can't add an event to anything but a day\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $cal->span_name eq "day" 0 0 0
59 unless $cal->span_name eq 'day';
60 0 my %what = ( description => $handler->param('description'), date => $cal->date );
61 0 ▶ $what{user} = $handler->user if defined $handler->user;
Branch: 1 branch
BranchTrueFalseTotal
if defined $handler->user 0 0 0
62 0 $cal->save_event( OurCal::Event->new(%what) );
63 } elsif ("del_event" eq $mode) {
64 0 $cal->del_event( OurCal::Event->new( id => $handler->param('id') ) );
65 }
66  
67  
68 0 my $span = $cal->span_name;
69 my $vars = {
70 image_url => $config->{image_url},
71 0 handler => $handler,
72 calendar => $cal,
73 $span => $cal->span,
74 };
75 0 ▶ my $template = Template->new({ INCLUDE_PATH => $config->{template_path}, RELATIVE => 1}) || die "${Template::ERROR}\n";
Condition0%0/3
'Template'->new({'INCLUDE_PATH', $config->{'template_path'}, 'RELATIVE', 1}) || die("$Template::ERROR\n")
l!l&&r!l&&!r
000
MC/DC0%0/2
'Template'->new({'INCLUDE_PATH', $config->{'template_path'}, 'RELATIVE', 1}) || die("$Template::ERROR\n")
'Template'->new({'INCLUDE_PATH', $config->{'template_path'}, 'RELATIVE', 1}) die("$Template::ERROR\n")
Truth table0%0/3
A || B
A= 'Template'->new({'INCLUDE_PATH', $config->{'template_path'}, 'RELATIVE', 1})B= die("$Template::ERROR\n")
ABresult
1X1
011
000
76  
77  
78 0 my $return;
79 0 ▶ $template->process($span,$vars, \$return)
Branch: 1 branch
BranchTrueFalseTotal
$template->process($span, $vars, \$return) or die('Template process failed: ' . $template->error . "\n") 0 0 0
80 || die "Template process failed: ".$template->error()."\n";
81 0 return $return;
82  
83  
84 }
85  
86 =head1 DESIGN
87  
88 The default template design is ripped off http://www.chimpfactory.com/
89 with permission.
90  
91 Don't blame them for the horrible way it's implemented - that's all my
92 fault.
93  
94 =cut
95  
96  
97 2 1;
« OurCal/Handler/CGI.pm ↑ Summary OurCal/Provider/ICalendar.pm »