| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Toader::Render::CSS; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
23138
|
use warnings; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
125
|
|
|
4
|
4
|
|
|
4
|
|
20
|
use strict; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
125
|
|
|
5
|
4
|
|
|
4
|
|
503
|
use Toader::Templates; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
95
|
|
|
6
|
4
|
|
|
4
|
|
23
|
use base 'Error::Helper'; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
3089
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Toader::Render::CSS - This renders the CSS file for Toader. |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Version 0.1.0 |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our $VERSION = '0.1.0'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
use Toader::Render::CSS; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $foo = Toader::Render::CSS->new($toader); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#renders it to a string |
|
27
|
|
|
|
|
|
|
my $css=$foo->renderCSS; |
|
28
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
29
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
#this renders it to a file... this unlike renderCSS |
|
33
|
|
|
|
|
|
|
#requires a output directory set |
|
34
|
|
|
|
|
|
|
$toader->setOutputDir('/foo/bar'); |
|
35
|
|
|
|
|
|
|
if ( $toader->error ){ |
|
36
|
|
|
|
|
|
|
#do something |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
$foo->render; |
|
39
|
|
|
|
|
|
|
if ( $foo->error ){ |
|
40
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 METHODS |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head2 new |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
This initiates the object. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
One argument is taken. That is the a L object. |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $foo=Toader::Render::CSS->new($toader); |
|
52
|
|
|
|
|
|
|
if($foo->error){ |
|
53
|
|
|
|
|
|
|
warn('error: '.$foo->error.":".$foo->errorString); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub new{ |
|
59
|
0
|
|
|
0
|
1
|
|
my $toader=$_[1]; |
|
60
|
|
|
|
|
|
|
|
|
61
|
0
|
|
|
|
|
|
my $self={ |
|
62
|
|
|
|
|
|
|
error=>undef, |
|
63
|
|
|
|
|
|
|
errorString=>'', |
|
64
|
|
|
|
|
|
|
perror=>undef, |
|
65
|
|
|
|
|
|
|
errorExtra=>{ |
|
66
|
|
|
|
|
|
|
flags=>{ |
|
67
|
|
|
|
|
|
|
1=>'noObj', |
|
68
|
|
|
|
|
|
|
2=>'noToaderObj', |
|
69
|
|
|
|
|
|
|
3=>'toaderObjPerror', |
|
70
|
|
|
|
|
|
|
4=>'noOutputDirSet', |
|
71
|
|
|
|
|
|
|
5=>'templateFillFailed', |
|
72
|
|
|
|
|
|
|
6=>'outputDirDoesNotExist', |
|
73
|
|
|
|
|
|
|
7=>'outputWriteFailed', |
|
74
|
|
|
|
|
|
|
}, |
|
75
|
|
|
|
|
|
|
}, |
|
76
|
|
|
|
|
|
|
}; |
|
77
|
0
|
|
|
|
|
|
bless $self; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#make sure a Toader object is given |
|
80
|
0
|
0
|
|
|
|
|
if ( ! defined( $toader ) ){ |
|
81
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
82
|
0
|
|
|
|
|
|
$self->{error}=1; |
|
83
|
0
|
|
|
|
|
|
$self->{errorString}='Nothing defined for the Toader object'; |
|
84
|
0
|
|
|
|
|
|
$self->warn; |
|
85
|
0
|
|
|
|
|
|
return $self; |
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
0
|
|
|
|
|
if ( ref( $toader ) ne 'Toader' ){ |
|
88
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
89
|
0
|
|
|
|
|
|
$self->{error}=2; |
|
90
|
0
|
|
|
|
|
|
$self->{errorString}='The specified object is not a Toader object, but a "'. |
|
91
|
|
|
|
|
|
|
ref( $toader ).'"'; |
|
92
|
0
|
|
|
|
|
|
$self->warn; |
|
93
|
0
|
|
|
|
|
|
return $self; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
0
|
|
|
|
|
|
$self->{toader}=$toader; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
#make sure the object does not have a permanent error set |
|
98
|
0
|
0
|
|
|
|
|
if( ! $self->{toader}->errorblank ){ |
|
99
|
0
|
|
|
|
|
|
$self->{perror}=1; |
|
100
|
0
|
|
|
|
|
|
$self->{error}=3; |
|
101
|
0
|
|
|
|
|
|
$self->{errorString}='The Toader object has a permanent error set'; |
|
102
|
0
|
|
|
|
|
|
$self->warn; |
|
103
|
0
|
|
|
|
|
|
return $self; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
$self->{templates}=Toader::Templates->new( { |
|
107
|
|
|
|
|
|
|
dir=>$self->{toader}->getRootDir, |
|
108
|
|
|
|
|
|
|
toader=>$toader, |
|
109
|
|
|
|
|
|
|
} ); |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
return $self; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head2 renderCSS |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This processes the CSS template. |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
No arguments are accepted. |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
my $css=$foo->renderCSS; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub renderCSS{ |
|
125
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
126
|
|
|
|
|
|
|
|
|
127
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
128
|
0
|
|
|
|
|
|
return undef; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
0
|
|
|
|
|
|
my $config=$self->{toader}->getConfig; |
|
132
|
0
|
|
|
|
|
|
my $css=$self->{templates}->fill_in( 'css', |
|
133
|
|
|
|
|
|
|
{ |
|
134
|
|
|
|
|
|
|
c=>\$config, |
|
135
|
|
|
|
|
|
|
toader=>\$self->{toader}, |
|
136
|
|
|
|
|
|
|
}); |
|
137
|
|
|
|
|
|
|
|
|
138
|
0
|
0
|
|
|
|
|
if ( $self->{templates}->error ){ |
|
139
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
140
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to render the template. error="'. |
|
141
|
|
|
|
|
|
|
$self->{templates}->error.'" errorString="'. |
|
142
|
|
|
|
|
|
|
$self->{templates}->errorString.'"'; |
|
143
|
0
|
|
|
|
|
|
$self->warn; |
|
144
|
0
|
|
|
|
|
|
return undef; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my $cssInclude=$self->{templates}->fill_in( 'cssInclude', |
|
148
|
|
|
|
|
|
|
{ |
|
149
|
|
|
|
|
|
|
c=>\$config, |
|
150
|
|
|
|
|
|
|
toader=>\$self->{toader}, |
|
151
|
|
|
|
|
|
|
}); |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
|
if ( $self->{templates}->error ){ |
|
154
|
0
|
|
|
|
|
|
$self->{error}=5; |
|
155
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to render the template. error="'. |
|
156
|
|
|
|
|
|
|
$self->{templates}->error.'" errorString="'. |
|
157
|
|
|
|
|
|
|
$self->{templates}->errorString.'"'; |
|
158
|
0
|
|
|
|
|
|
$self->warn; |
|
159
|
0
|
|
|
|
|
|
return undef; |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
return $css.$cssInclude; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head2 render |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
This renders it to the output directory. |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
No arguments are taken. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
$foo->render; |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=cut |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
sub render{ |
|
177
|
0
|
|
|
0
|
1
|
|
my $self=$_[0]; |
|
178
|
|
|
|
|
|
|
|
|
179
|
0
|
0
|
|
|
|
|
if ( ! $self->errorblank ){ |
|
180
|
0
|
|
|
|
|
|
return undef; |
|
181
|
|
|
|
|
|
|
} |
|
182
|
|
|
|
|
|
|
|
|
183
|
0
|
|
|
|
|
|
my $dir=$self->{toader}->getOutputDir; |
|
184
|
0
|
0
|
|
|
|
|
if ( ! defined( $dir ) ){ |
|
185
|
0
|
|
|
|
|
|
$self->{error}=4; |
|
186
|
0
|
|
|
|
|
|
$self->{errorString}='The Toader object does not have a output directory set'; |
|
187
|
0
|
|
|
|
|
|
$self->warn; |
|
188
|
0
|
|
|
|
|
|
return undef; |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
my $css=$self->renderCSS; |
|
192
|
0
|
0
|
|
|
|
|
if ( $self->error ){ |
|
193
|
0
|
|
|
|
|
|
$self->warnString( 'renderCSS errored' ); |
|
194
|
0
|
|
|
|
|
|
return undef; |
|
195
|
|
|
|
|
|
|
} |
|
196
|
|
|
|
|
|
|
|
|
197
|
0
|
0
|
|
|
|
|
if ( ! -d $dir ){ |
|
198
|
0
|
0
|
|
|
|
|
if ( ! mkdir( $dir )){ |
|
199
|
0
|
|
|
|
|
|
$self->{error}=6; |
|
200
|
0
|
|
|
|
|
|
$self->{errorString}='The output directory,"'.$dir |
|
201
|
|
|
|
|
|
|
.'", does not exist and it could be created'; |
|
202
|
0
|
|
|
|
|
|
$self->warn; |
|
203
|
0
|
|
|
|
|
|
return undef; |
|
204
|
|
|
|
|
|
|
} |
|
205
|
|
|
|
|
|
|
} |
|
206
|
|
|
|
|
|
|
|
|
207
|
0
|
|
|
|
|
|
my $file=$dir.'/toader.css'; |
|
208
|
0
|
|
|
|
|
|
my $fh; |
|
209
|
0
|
0
|
|
|
|
|
if ( ! open( $fh, '>', $file ) ){ |
|
210
|
0
|
|
|
|
|
|
$self->{error}=7; |
|
211
|
0
|
|
|
|
|
|
$self->{errorString}='Failed to open "'.$file.'" for writing'; |
|
212
|
0
|
|
|
|
|
|
$self->warn; |
|
213
|
0
|
|
|
|
|
|
return undef; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
0
|
|
|
|
|
|
print $fh $css; |
|
216
|
0
|
|
|
|
|
|
close( $fh ); |
|
217
|
|
|
|
|
|
|
|
|
218
|
0
|
|
|
|
|
|
return 1; |
|
219
|
|
|
|
|
|
|
} |
|
220
|
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 ERROR CODES |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head2 1, noObj |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
Nothing defined for the L object. |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=head2 2, noToaderObj |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
The specified object is not a L object. |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=head2 3, toaderObjPerror |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
The L object has a permanent error set. |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=head2 4, noOutputDirSet |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
The L object does not have a output directory set. |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=head2 5, templateFillFailed |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
Failed to fill in the CSS template. |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 6, outputDirDoesNotExist |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
The output directory did not exist and could not be created. |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 7, outputWriteFailed |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Failed to write the file out to the output directory. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 AUTHOR |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Zane C. Bowers-Hadley, C<< >> |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 BUGS |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
|
258
|
|
|
|
|
|
|
the web interface at L. I will |
|
259
|
|
|
|
|
|
|
be notified, and then you'll automatically be notified of progress on your bug as I |
|
260
|
|
|
|
|
|
|
make changes. |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=head1 SUPPORT |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
|
265
|
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
perldoc Toader::Render:CSS |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
You can also look for information at: |
|
269
|
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
=over 4 |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
L |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
L |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=item * CPAN Ratings |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
L |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=item * Search CPAN |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
L |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=back |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
|
291
|
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
Copyright 2011. Zane C. Bowers-Hadley. |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
|
297
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
|
298
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
|
299
|
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
|
301
|
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=cut |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
1; # End of Toader::Render::CSS |