line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::SiteTear::CSS; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
5
|
1
|
|
|
1
|
|
6
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
19
|
|
6
|
1
|
|
|
1
|
|
6
|
use File::Basename; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
86
|
|
7
|
1
|
|
|
1
|
|
7
|
use File::Path; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
601
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
require HTML::SiteTear::Item; |
10
|
|
|
|
|
|
|
our @ISA = qw(HTML::SiteTear::Item); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '1.43'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 NAME |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
HTML::SiteTear::CSS - treat cascading style sheet files. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SYMPOSIS |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use HTML::SiteTear::CSS; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
$item = HTML::SiteTear::CSS->new($parent,$source_path,$kind); |
23
|
|
|
|
|
|
|
$item->linkpath($path); # usually called from the mothod "change_path" |
24
|
|
|
|
|
|
|
# of the parent object. |
25
|
|
|
|
|
|
|
$item->copy_to_linkpath(); |
26
|
|
|
|
|
|
|
$item->copy_linked_files(); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 DESCRIPTION |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
This module is to treat cascading style sheet files liked from web pages. It's also a sub class of the L. Internal use only. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head2 new |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$css = HTML::SiteTear::CSS->new('parent' => $parent, |
37
|
|
|
|
|
|
|
'source_path' => $source_path); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Make an instance of this moduel. The parent object "$parent" must be an instance of HTML::SiteTear::Page. This method is called from $parent. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=cut |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new { |
44
|
0
|
|
|
0
|
1
|
|
my $class = shift @_; |
45
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(@_); |
46
|
0
|
0
|
|
|
|
|
unless ($self->kind ) { $self->kind('css') }; |
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
$self->{'linkedFiles'} = []; |
48
|
0
|
|
|
|
|
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 css_copy |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$css->css_copy($source_path, $target_path); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Copy a cascading style sheet file "$source_path" into $target_path dealing with internal links. This method is called form the method "copy_to_linkpath". |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub css_copy { |
60
|
0
|
|
|
0
|
1
|
|
my ($self, $target_path) = @_; |
61
|
0
|
|
|
|
|
|
my $source_path = $self->source_path; |
62
|
0
|
|
|
|
|
|
open(my $CSSIN, "< $source_path"); |
63
|
0
|
|
|
|
|
|
open(my $CSSOUT, "> $target_path"); |
64
|
0
|
|
|
|
|
|
while (my $a_line = <$CSSIN>) { |
65
|
0
|
0
|
|
|
|
|
if ($a_line =~ /url\(([^()]+)\)/) { |
66
|
0
|
|
|
|
|
|
my $new_link = $self->change_path($1, $self->resource_folder_name, 'css'); |
67
|
0
|
|
|
|
|
|
$a_line =~ s/url\([^()]+\)/url\($new_link\)/; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
print $CSSOUT $a_line; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
|
|
|
|
|
close($CSSIN); |
72
|
0
|
|
|
|
|
|
close($CSSOUT); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 copy_to_linkpath |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
$item->copy_to_linkpath; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Copy $source_path into new linked path from $parent. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=cut |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
sub copy_to_linkpath { |
84
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
85
|
0
|
|
|
|
|
|
my $source_path = $self->source_path; |
86
|
0
|
0
|
|
|
|
|
unless ($self->exists_in_copied_files($source_path)) { |
87
|
0
|
0
|
|
|
|
|
unless (-e $source_path) { |
88
|
0
|
|
|
|
|
|
die("The file \"$source_path\" does not exists.\n"); |
89
|
0
|
|
|
|
|
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
|
|
|
my $target_path; |
93
|
0
|
0
|
|
|
|
|
if (my $target_uri = $self->item_in_filemap($source_path)) { |
94
|
0
|
|
|
|
|
|
$target_path = $target_uri->file; |
95
|
|
|
|
|
|
|
} else { |
96
|
0
|
|
|
|
|
|
$target_path = $self->link_uri->file |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
print "Copying asset...\n"; |
100
|
0
|
|
|
|
|
|
print "from : $source_path\n"; |
101
|
0
|
|
|
|
|
|
print "to : $target_path\n\n"; |
102
|
0
|
0
|
|
|
|
|
($source_path eq $target_path) and die "source and target is same file.\n"; |
103
|
0
|
|
|
|
|
|
mkpath(dirname($target_path)); |
104
|
0
|
|
|
|
|
|
$self->target_path($target_path); #temporary set for css_copy |
105
|
0
|
|
|
|
|
|
$self->css_copy($target_path); |
106
|
|
|
|
|
|
|
#$self->target_path(Cwd::abs_path($target_path)); |
107
|
0
|
|
|
|
|
|
$self->add_to_copyied_files($source_path); |
108
|
0
|
|
|
|
|
|
$self->copy_linked_files; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SEE ALSO |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
L, L, L, L |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Tetsuro KURITA |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |