| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::Make::Page; |
|
2
|
2
|
|
|
2
|
|
150030
|
use warnings; |
|
|
2
|
|
|
|
|
14
|
|
|
|
2
|
|
|
|
|
74
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
67
|
|
|
4
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
132
|
|
|
5
|
2
|
|
|
2
|
|
11
|
use utf8; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
|
|
require Exporter; |
|
7
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw/make_page/; |
|
9
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
|
10
|
|
|
|
|
|
|
all => \@EXPORT_OK, |
|
11
|
|
|
|
|
|
|
); |
|
12
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
|
13
|
2
|
|
|
2
|
|
1333
|
use HTML::Make '0.15'; |
|
|
2
|
|
|
|
|
60450
|
|
|
|
2
|
|
|
|
|
1832
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub add_meta |
|
16
|
|
|
|
|
|
|
{ |
|
17
|
1
|
|
|
1
|
0
|
2
|
my ($head, $meta) = @_; |
|
18
|
1
|
50
|
|
|
|
6
|
if (ref $meta ne 'ARRAY') { |
|
19
|
0
|
|
|
|
|
0
|
carp "meta is not an array reference"; |
|
20
|
0
|
|
|
|
|
0
|
return; |
|
21
|
|
|
|
|
|
|
} |
|
22
|
1
|
|
|
|
|
3
|
my $i = -1; |
|
23
|
1
|
|
|
|
|
3
|
for my $m (@$meta) { |
|
24
|
1
|
|
|
|
|
2
|
$i++; |
|
25
|
1
|
50
|
|
|
|
4
|
if (ref $m ne 'HASH') { |
|
26
|
0
|
|
|
|
|
0
|
carp "meta element $i is not a hash reference"; |
|
27
|
0
|
|
|
|
|
0
|
next; |
|
28
|
|
|
|
|
|
|
} |
|
29
|
1
|
|
|
|
|
5
|
$head->push ('meta', attr => $m); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub add_link |
|
34
|
|
|
|
|
|
|
{ |
|
35
|
1
|
|
|
1
|
0
|
3
|
my ($head, $link, $quiet) = @_; |
|
36
|
1
|
50
|
|
|
|
5
|
if (ref $link ne 'ARRAY') { |
|
37
|
0
|
|
|
|
|
0
|
carp "link is not an array reference"; |
|
38
|
0
|
|
|
|
|
0
|
return; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
1
|
|
|
|
|
3
|
my $i = -1; |
|
41
|
1
|
|
|
|
|
3
|
for my $l (@$link) { |
|
42
|
1
|
|
|
|
|
2
|
$i++; |
|
43
|
1
|
50
|
|
|
|
4
|
if (ref $l ne 'HASH') { |
|
44
|
0
|
|
|
|
|
0
|
carp "link element $i is not a hash reference"; |
|
45
|
0
|
|
|
|
|
0
|
next; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
1
|
50
|
|
|
|
3
|
if (! $l->{rel}) { |
|
48
|
0
|
|
|
|
|
0
|
carp "link element $i has no value for 'rel', skipping"; |
|
49
|
0
|
|
|
|
|
0
|
next; |
|
50
|
|
|
|
|
|
|
} |
|
51
|
1
|
50
|
|
|
|
4
|
if (! $l->{href}) { |
|
52
|
0
|
0
|
|
|
|
0
|
if (! $quiet) { |
|
53
|
0
|
|
|
|
|
0
|
carp "link element $i ($l->{rel}) has no href"; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
1
|
|
|
|
|
4
|
$head->push ('link', attr => $l); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub make_page |
|
61
|
|
|
|
|
|
|
{ |
|
62
|
9
|
|
|
9
|
1
|
6934
|
my (%options) = @_; |
|
63
|
9
|
|
|
|
|
18
|
my $quiet; |
|
64
|
9
|
100
|
|
|
|
30
|
if ($options{quiet}) { |
|
65
|
2
|
|
|
|
|
5
|
$quiet = $options{quiet}; |
|
66
|
2
|
|
|
|
|
6
|
delete $options{quiet}; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
9
|
|
|
|
|
39
|
my $html = HTML::Make->new ('html'); |
|
69
|
9
|
100
|
|
|
|
257
|
if ($options{lang}) { |
|
70
|
2
|
|
|
|
|
12
|
$html->add_attr (lang => $options{lang}); |
|
71
|
2
|
|
|
|
|
693
|
delete $options{lang}; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
9
|
|
|
|
|
28
|
my $head = $html->push ('head'); |
|
74
|
9
|
|
|
|
|
476
|
$head->push ( |
|
75
|
|
|
|
|
|
|
'meta', |
|
76
|
|
|
|
|
|
|
attr => { |
|
77
|
|
|
|
|
|
|
charset => 'UTF-8' |
|
78
|
|
|
|
|
|
|
} |
|
79
|
|
|
|
|
|
|
); |
|
80
|
9
|
|
|
|
|
1486
|
$head->push ( |
|
81
|
|
|
|
|
|
|
'meta', |
|
82
|
|
|
|
|
|
|
attr => { |
|
83
|
|
|
|
|
|
|
name => 'viewport', |
|
84
|
|
|
|
|
|
|
content => |
|
85
|
|
|
|
|
|
|
'width=device-width, initial-scale=1.0' |
|
86
|
|
|
|
|
|
|
} |
|
87
|
|
|
|
|
|
|
); |
|
88
|
9
|
100
|
|
|
|
974
|
if ($options{css}) { |
|
89
|
1
|
|
|
|
|
2
|
for my $css (@{$options{css}}) { |
|
|
1
|
|
|
|
|
4
|
|
|
90
|
2
|
|
|
|
|
438
|
$head->push ( |
|
91
|
|
|
|
|
|
|
'link', |
|
92
|
|
|
|
|
|
|
attr => { |
|
93
|
|
|
|
|
|
|
rel => 'stylesheet', |
|
94
|
|
|
|
|
|
|
type => 'text/css', |
|
95
|
|
|
|
|
|
|
href => $css, |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
1
|
|
|
|
|
178
|
delete $options{css}; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
9
|
100
|
|
|
|
26
|
if ($options{js}) { |
|
102
|
1
|
|
|
|
|
5
|
add_js ($head, $options{js}, $quiet); |
|
103
|
1
|
|
|
|
|
2
|
delete $options{js}; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
9
|
100
|
|
|
|
24
|
if ($options{title}) { |
|
106
|
1
|
|
|
|
|
4
|
$head->push ('title', text => $options{title}); |
|
107
|
1
|
|
|
|
|
70
|
delete $options{title}; |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
else { |
|
110
|
8
|
100
|
|
|
|
19
|
if (! $quiet) { |
|
111
|
6
|
|
|
|
|
915
|
carp "No title"; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
9
|
100
|
|
|
|
169
|
if ($options{style}) { |
|
115
|
1
|
|
|
|
|
7
|
$head->push ('style', text => $options{style}); |
|
116
|
1
|
|
|
|
|
87
|
delete $options{style}; |
|
117
|
|
|
|
|
|
|
} |
|
118
|
9
|
100
|
|
|
|
25
|
if ($options{meta}) { |
|
119
|
1
|
|
|
|
|
5
|
add_meta ($head, $options{meta}); |
|
120
|
1
|
|
|
|
|
114
|
delete $options{meta}; |
|
121
|
|
|
|
|
|
|
} |
|
122
|
9
|
100
|
|
|
|
24
|
if ($options{link}) { |
|
123
|
1
|
|
|
|
|
6
|
add_link ($head, $options{link}, $quiet); |
|
124
|
1
|
|
|
|
|
154
|
delete $options{link}; |
|
125
|
|
|
|
|
|
|
} |
|
126
|
9
|
100
|
|
|
|
21
|
if (! $quiet) { |
|
127
|
7
|
|
|
|
|
14
|
for my $k (keys %options) { |
|
128
|
0
|
|
|
|
|
0
|
carp "Unknown option $k"; |
|
129
|
0
|
|
|
|
|
0
|
delete $options{$k}; |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
} |
|
132
|
9
|
|
|
|
|
36
|
my $body = $html->push ('body'); |
|
133
|
9
|
|
|
|
|
407
|
return ($html, $body); |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
sub add_js |
|
137
|
|
|
|
|
|
|
{ |
|
138
|
1
|
|
|
1
|
0
|
3
|
my ($head, $jss, $quiet) = @_; |
|
139
|
1
|
|
|
|
|
3
|
my $i = -1; |
|
140
|
1
|
|
|
|
|
3
|
for my $js (@$jss) { |
|
141
|
3
|
|
|
|
|
448
|
$i++; |
|
142
|
3
|
100
|
|
|
|
21
|
if (ref $js eq 'HASH') { |
|
143
|
1
|
50
|
|
|
|
4
|
if ($js->{src}) { |
|
144
|
1
|
|
|
|
|
3
|
$head->push ('script', attr => $js); |
|
145
|
1
|
|
|
|
|
103
|
next; |
|
146
|
|
|
|
|
|
|
} |
|
147
|
0
|
0
|
|
|
|
0
|
if ($js->{text}) { |
|
148
|
0
|
|
|
|
|
0
|
$head->push ('script', text => $js->{text}); |
|
149
|
0
|
|
|
|
|
0
|
next; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
0
|
0
|
|
|
|
0
|
if (! $quiet) { |
|
152
|
0
|
|
|
|
|
0
|
carp "No src or text specified for js element $i"; |
|
153
|
|
|
|
|
|
|
} |
|
154
|
0
|
|
|
|
|
0
|
next; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
$head->push ( |
|
157
|
2
|
|
|
|
|
10
|
'script', |
|
158
|
|
|
|
|
|
|
attr => { |
|
159
|
|
|
|
|
|
|
src => $js, |
|
160
|
|
|
|
|
|
|
}, |
|
161
|
|
|
|
|
|
|
); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |