| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package HTML::SiteTear::Item; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
45
|
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
38
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
7
|
use File::Spec; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
7
|
1
|
|
|
1
|
|
5
|
use File::Basename; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
89
|
|
|
8
|
1
|
|
|
1
|
|
1075
|
use File::Copy; |
|
|
1
|
|
|
|
|
2777
|
|
|
|
1
|
|
|
|
|
78
|
|
|
9
|
1
|
|
|
1
|
|
9
|
use File::Path; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
59
|
|
|
10
|
|
|
|
|
|
|
#use Cwd; |
|
11
|
1
|
|
|
1
|
|
7
|
use URI::file; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
26
|
|
|
12
|
1
|
|
|
1
|
|
1265
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
11951
|
|
|
|
1
|
|
|
|
|
95
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
13
|
use base qw(Class::Accessor); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
1852
|
|
|
15
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors(qw(linkpath |
|
16
|
|
|
|
|
|
|
link_uri |
|
17
|
|
|
|
|
|
|
source_path |
|
18
|
|
|
|
|
|
|
source_uri |
|
19
|
|
|
|
|
|
|
base_uri |
|
20
|
|
|
|
|
|
|
target_path |
|
21
|
|
|
|
|
|
|
target_uri |
|
22
|
|
|
|
|
|
|
kind |
|
23
|
|
|
|
|
|
|
parent |
|
24
|
|
|
|
|
|
|
source_root)); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
require HTML::SiteTear::Page; |
|
27
|
|
|
|
|
|
|
require HTML::SiteTear::CSS; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
our $VERSION = '1.43'; |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 NAME |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
HTML::SiteTear::Item - treat javascript files, image files and so on. |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 SYMPOSIS |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use HTML::SiteTear::Item; |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$item = HTML::SiteTear::Item->new($parent, $source_path, $kind); |
|
41
|
|
|
|
|
|
|
$item->linkpath($path); # usually called from the mothod "change_path" |
|
42
|
|
|
|
|
|
|
# of the parent object. |
|
43
|
|
|
|
|
|
|
$item->copy_to_linkpath; |
|
44
|
|
|
|
|
|
|
$item->copy_liked_files; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This module is to treat general files liked from web pages. It's also a super class of L, L. Internal use only. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 METHODS |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head2 new |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$item = HTML::SiteTear::Item->new('parent' => $parent, |
|
55
|
|
|
|
|
|
|
'source_path' => $source_path, |
|
56
|
|
|
|
|
|
|
'kind' => $kind); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Make an instance of this moduel. $parent must be an instance of HTML::SiteTear::Root or HTML::SiteTear::Page. This method is called from $parent. |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=cut |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub new { |
|
63
|
0
|
|
|
0
|
1
|
|
my $class = shift @_; |
|
64
|
0
|
|
|
|
|
|
my %args = @_; |
|
65
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(\%args); |
|
66
|
0
|
|
|
|
|
|
$self->source_root($self->parent->source_root); |
|
67
|
0
|
0
|
|
|
|
|
if (exists $args{'source_path'}) { |
|
68
|
0
|
|
|
|
|
|
$self->source_path($self->source_path); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
|
|
|
|
|
return $self; |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 copy_to_linkpath |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
$item->copy_to_linkpath; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Copy $source_path into new linked path from $parent. |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=cut |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub copy_to_linkpath { |
|
83
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
84
|
0
|
|
|
|
|
|
my $source_path = $self->source_path; |
|
85
|
0
|
0
|
|
|
|
|
unless ($self->exists_in_copied_files($source_path)) { |
|
86
|
0
|
0
|
|
|
|
|
unless (-e $source_path) { |
|
87
|
0
|
|
|
|
|
|
die("The file \"$source_path\" does not exists.\n"); |
|
88
|
0
|
|
|
|
|
|
return; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $target_path; |
|
92
|
0
|
0
|
|
|
|
|
if (my $target_uri = $self->item_in_filemap($source_path)) { |
|
93
|
0
|
|
|
|
|
|
$target_path = $target_uri->file; |
|
94
|
|
|
|
|
|
|
} else { |
|
95
|
0
|
|
|
|
|
|
$target_path = $self->link_uri->file; |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
|
print "\nCopying asset...\n"; |
|
99
|
0
|
|
|
|
|
|
print "from : $source_path\n"; |
|
100
|
0
|
|
|
|
|
|
print "to : $target_path\n"; |
|
101
|
0
|
0
|
|
|
|
|
($source_path eq $target_path) and die "source and target is same file.\n"; |
|
102
|
0
|
|
|
|
|
|
mkpath(dirname($target_path)); |
|
103
|
0
|
|
|
|
|
|
copy($source_path, $target_path); |
|
104
|
0
|
|
|
|
|
|
$self->add_to_copyied_files($source_path); |
|
105
|
|
|
|
|
|
|
#$self->target_path(Cwd::abs_path($target_path)); |
|
106
|
0
|
|
|
|
|
|
$self->target_path($target_path); |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head2 add_to_linked_files |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$item->add_to_linked_files($linked_obj) |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Add $linked_obj into the internal list. in $linked_obj is an instance of HTML::SiteTear::Item or subclass of HTML::SiteTear::Item for linked files from $source_path. |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=cut |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub add_to_linked_files { |
|
119
|
0
|
|
|
0
|
1
|
|
my ($self, $linked_obj) = @_; |
|
120
|
0
|
|
|
|
|
|
push (@{$self->{'linkedFiles'}}, $linked_obj); |
|
|
0
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
} |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head2 change_path |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
$new_linkpath = $item->change_path($linkpath, $folder_name, $kind) |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
make a new link path from a link path($linkpath) in $source_path. $folder_name is folder name to store, if $linkpath is not under $source_path. |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub change_path { |
|
132
|
|
|
|
|
|
|
#print STDERR "start change_path\n"; |
|
133
|
0
|
|
|
0
|
1
|
|
my ($self, $linkpath, $folder_name, $kind) = @_; |
|
134
|
0
|
|
|
|
|
|
my $result_path; |
|
135
|
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $uri = URI->new($linkpath); |
|
137
|
0
|
0
|
0
|
|
|
|
if (($uri->scheme) and ($uri->scheme ne 'file')) { |
|
138
|
0
|
|
|
|
|
|
return $linkpath; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
|
|
141
|
0
|
0
|
|
|
|
|
unless (defined($kind)){ |
|
142
|
0
|
|
|
|
|
|
$kind = $folder_name; |
|
143
|
|
|
|
|
|
|
} |
|
144
|
0
|
|
|
|
|
|
my $fragment = $uri->fragment; |
|
145
|
0
|
|
|
|
|
|
$uri = $uri->abs($self->base_uri); |
|
146
|
0
|
|
|
|
|
|
my $abs_path = $uri->file; |
|
147
|
0
|
0
|
|
|
|
|
unless (-e $abs_path) { |
|
148
|
0
|
|
|
|
|
|
warn("\n$abs_path is not found.\nThe link to this path is not changed.\n"); |
|
149
|
0
|
|
|
|
|
|
return $linkpath; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#$abs_path = Cwd::abs_path($abs_path); |
|
153
|
|
|
|
|
|
|
#print "abs_path in change_path:".$abs_path."\n"; |
|
154
|
0
|
0
|
|
|
|
|
if ($self->exists_in_filemap($abs_path) ) { |
|
155
|
0
|
|
|
|
|
|
$result_path |
|
156
|
|
|
|
|
|
|
= $self->rel_for_mappedfile($abs_path, $self->target_uri); |
|
157
|
0
|
|
|
|
|
|
$result_path->fragment($fragment); |
|
158
|
|
|
|
|
|
|
} else { |
|
159
|
|
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
my $new_linked_obj; |
|
161
|
0
|
|
|
|
|
|
my %args = ('parent' => $self, |
|
162
|
|
|
|
|
|
|
'source_path' => $abs_path, |
|
163
|
|
|
|
|
|
|
'kind' => $kind); |
|
164
|
0
|
0
|
|
|
|
|
if ($kind eq 'page') { |
|
|
|
0
|
|
|
|
|
|
|
165
|
0
|
|
|
|
|
|
$new_linked_obj = HTML::SiteTear::Page->new(%args); |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
} elsif ($kind eq 'css') { |
|
168
|
0
|
|
|
|
|
|
$new_linked_obj = HTML::SiteTear::CSS->new(%args); |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
} else { |
|
171
|
0
|
|
|
|
|
|
$new_linked_obj = HTML::SiteTear::Item->new(%args); |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
## obtain relative path from source_root |
|
175
|
|
|
|
|
|
|
## to judge whether $abs_path is under sourceRoot or not. |
|
176
|
0
|
|
|
|
|
|
my $rel_from_root = File::Spec->abs2rel($abs_path, dirname($self->source_root_path)); |
|
177
|
0
|
|
|
|
|
|
my $updir_str = File::Spec->updir(); |
|
178
|
|
|
|
|
|
|
|
|
179
|
0
|
|
|
|
|
|
my $new_link_uri; |
|
180
|
0
|
|
|
|
|
|
my $should_copy = 1; |
|
181
|
0
|
0
|
|
|
|
|
if ($rel_from_root =~ /^\Q$updir_str\E/) { |
|
182
|
|
|
|
|
|
|
## not under sourceRoot |
|
183
|
0
|
0
|
|
|
|
|
if ($self->source_root->only_subitems) { |
|
184
|
0
|
|
|
|
|
|
$new_link_uri = $uri->rel($self->target_uri); |
|
185
|
0
|
|
|
|
|
|
$should_copy = 0; |
|
186
|
|
|
|
|
|
|
} else { |
|
187
|
0
|
|
|
|
|
|
my $file_name = basename($abs_path); |
|
188
|
0
|
|
|
|
|
|
$new_link_uri = URI->new("$folder_name/$file_name"); |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
} else { # when under sourceRoot, linpath is not changed. |
|
192
|
0
|
|
|
|
|
|
$new_link_uri = URI->new($linkpath); |
|
193
|
|
|
|
|
|
|
} |
|
194
|
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
$new_linked_obj->linkpath($result_path); |
|
196
|
0
|
|
|
|
|
|
my $target_uri = $new_link_uri->abs($self->target_uri); |
|
197
|
0
|
|
|
|
|
|
$new_linked_obj->link_uri($target_uri); |
|
198
|
|
|
|
|
|
|
|
|
199
|
0
|
0
|
|
|
|
|
$self->add_to_linked_files($new_linked_obj) if $should_copy; |
|
200
|
0
|
|
|
|
|
|
$self->add_to_filemap($abs_path, $target_uri); |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
0
|
|
|
|
|
if ($fragment) { |
|
203
|
0
|
|
|
|
|
|
$new_link_uri->fragment($fragment); |
|
204
|
|
|
|
|
|
|
} |
|
205
|
0
|
|
|
|
|
|
$result_path = $new_link_uri->as_string; |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
#print "end of change_path\n"; |
|
209
|
0
|
|
|
|
|
|
return $result_path |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head2 copy_linked_files |
|
213
|
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
$item->copy_linked_files(); |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
Call method "copy_to_linkpath()" of every object added by "addToLikedFiles($linked_obj)". |
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=cut |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
sub copy_linked_files { |
|
221
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
222
|
0
|
|
|
|
|
|
my @page_list = (); |
|
223
|
|
|
|
|
|
|
|
|
224
|
0
|
|
|
|
|
|
foreach my $linked_file (@{$self->{'linkedFiles'}}) { |
|
|
0
|
|
|
|
|
|
|
|
225
|
0
|
0
|
|
|
|
|
if ($linked_file->kind eq 'page') { |
|
226
|
0
|
|
|
|
|
|
push @page_list, $linked_file; |
|
227
|
|
|
|
|
|
|
} |
|
228
|
|
|
|
|
|
|
else { |
|
229
|
0
|
|
|
|
|
|
$linked_file->copy_to_linkpath(); |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
} |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
#HTML file must be copied after other assets. |
|
234
|
0
|
0
|
|
|
|
|
unless (@page_list) {return}; |
|
|
0
|
|
|
|
|
|
|
|
235
|
0
|
|
|
|
|
|
foreach my $linked_file (@page_list) { |
|
236
|
0
|
|
|
|
|
|
$linked_file->copy_to_linkpath(); |
|
237
|
|
|
|
|
|
|
} |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
##== methods to access root object |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head2 add_to_copyied_files |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
$item->add_to_copyied_files($source_path); |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Add a file path already copied to the copiedFiles table of the root object of the parent chain. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
sub add_to_copyied_files { |
|
252
|
0
|
|
|
0
|
1
|
|
my ($self, $path) = @_; |
|
253
|
0
|
|
|
|
|
|
$self->parent->add_to_copyied_files($path); |
|
254
|
|
|
|
|
|
|
} |
|
255
|
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=head2 exists_in_copied_files |
|
257
|
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
$item->exists_in_copied_files($source_path); |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
Check existance of $source_path in the copiedFiles entry. |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=cut |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
sub exists_in_copied_files { |
|
265
|
0
|
|
|
0
|
1
|
|
my ($self, $path) = @_; |
|
266
|
0
|
|
|
|
|
|
return $self->parent->exists_in_copied_files($path); |
|
267
|
|
|
|
|
|
|
} |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head2 add_to_filemap |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
$item->add_to_filemap($source_path, $target_path); |
|
272
|
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
Add a relation between $source_path and $target_path to the internal table of the root object of the parent chain. |
|
274
|
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
=cut |
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
sub add_to_filemap { |
|
278
|
0
|
|
|
0
|
1
|
|
my ($self, $source_path, $target_path) = @_; |
|
279
|
0
|
|
|
|
|
|
$self->parent->add_to_filemap($source_path, $target_path); |
|
280
|
|
|
|
|
|
|
} |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
=head2 exists_in_filemap |
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
$bool = $item->exists_in_filemap($source_path); |
|
285
|
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
Check existance of $source_path in the internal table the root object of parent chain. |
|
287
|
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=cut |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub exists_in_filemap{ |
|
291
|
0
|
|
|
0
|
1
|
|
my ($self, $path) = @_; |
|
292
|
|
|
|
|
|
|
#return $self->parent->exists_in_filemap($path); |
|
293
|
0
|
|
|
|
|
|
return $self->source_root->exists_in_filemap($path); |
|
294
|
|
|
|
|
|
|
} |
|
295
|
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
sub item_in_filemap { |
|
298
|
0
|
|
|
0
|
0
|
|
my ($self, $path) = @_; |
|
299
|
|
|
|
|
|
|
#return $self->parent->item_in_filemap($path); |
|
300
|
0
|
|
|
|
|
|
return $self->source_root->item_in_filemap($path); |
|
301
|
|
|
|
|
|
|
} |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=head2 source_root_path |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
$source_root_path = $item->source_root_path; |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
Get the root source path which is an argument of HTML::SiteTear::CopyTo. |
|
308
|
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
=cut |
|
310
|
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
sub source_root_path { |
|
312
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
313
|
0
|
|
|
|
|
|
return $self->source_root->source_path; |
|
314
|
|
|
|
|
|
|
} |
|
315
|
|
|
|
|
|
|
|
|
316
|
|
|
|
|
|
|
=head2 rel_for_mappedfile |
|
317
|
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
$relativePath = $item->rel_for_mappedfile($source_path, $base_uri); |
|
319
|
|
|
|
|
|
|
|
|
320
|
|
|
|
|
|
|
Get a relative link of the target path corresponding to $source_path based from $base_uri. |
|
321
|
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
=cut |
|
323
|
|
|
|
|
|
|
|
|
324
|
|
|
|
|
|
|
sub rel_for_mappedfile { |
|
325
|
0
|
|
|
0
|
1
|
|
my ($self, $source_path, $base_uri) = @_; |
|
326
|
0
|
|
|
|
|
|
return $self->parent->rel_for_mappedfile($source_path, $base_uri); |
|
327
|
|
|
|
|
|
|
} |
|
328
|
|
|
|
|
|
|
|
|
329
|
|
|
|
|
|
|
##== accessors |
|
330
|
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
=head2 source_path |
|
332
|
|
|
|
|
|
|
|
|
333
|
|
|
|
|
|
|
$item->source_path; |
|
334
|
|
|
|
|
|
|
$item->source_path($path); |
|
335
|
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
Get and set the source path of this objcet. |
|
337
|
|
|
|
|
|
|
|
|
338
|
|
|
|
|
|
|
=cut |
|
339
|
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
sub source_path { |
|
341
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
|
342
|
|
|
|
|
|
|
|
|
343
|
0
|
0
|
|
|
|
|
if (@_) { |
|
344
|
|
|
|
|
|
|
#my $path = Cwd::abs_path($_[0]); |
|
345
|
0
|
|
|
|
|
|
my $path = shift @_; |
|
346
|
0
|
|
|
|
|
|
$self->{'source_path'} = $path; |
|
347
|
0
|
|
|
|
|
|
my $uri = URI::file->new_abs($path); |
|
348
|
0
|
|
|
|
|
|
$self->source_uri($uri); |
|
349
|
0
|
|
|
|
|
|
$self->base_uri($uri); |
|
350
|
|
|
|
|
|
|
} |
|
351
|
0
|
0
|
|
|
|
|
if ($self->source_uri) { |
|
352
|
0
|
|
|
|
|
|
return $self->source_uri->file; |
|
353
|
|
|
|
|
|
|
} else { |
|
354
|
0
|
|
|
|
|
|
return $self->{'source_path'}; |
|
355
|
|
|
|
|
|
|
} |
|
356
|
|
|
|
|
|
|
} |
|
357
|
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
=head2 target_path |
|
359
|
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
$item->taget_path; |
|
361
|
|
|
|
|
|
|
$item->target_path($path); |
|
362
|
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
Get and set the target path which is the copy destination of $source_path. This method is called from "copy_to_linkpath()". Before calling this method, $path must be exists. |
|
364
|
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
=cut |
|
366
|
|
|
|
|
|
|
|
|
367
|
|
|
|
|
|
|
sub target_path { |
|
368
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
|
369
|
|
|
|
|
|
|
|
|
370
|
0
|
0
|
|
|
|
|
if (@_) { |
|
371
|
0
|
|
|
|
|
|
my $path = $_[0]; |
|
372
|
0
|
|
|
|
|
|
$self->{'target_path'} = $path; |
|
373
|
0
|
|
|
|
|
|
my $uri = URI::file->new($path); |
|
374
|
0
|
|
|
|
|
|
$self->target_uri($uri); |
|
375
|
|
|
|
|
|
|
} |
|
376
|
|
|
|
|
|
|
|
|
377
|
0
|
|
|
|
|
|
return $self->{'target_path'}; |
|
378
|
|
|
|
|
|
|
} |
|
379
|
|
|
|
|
|
|
|
|
380
|
|
|
|
|
|
|
=head2 linkpath |
|
381
|
|
|
|
|
|
|
|
|
382
|
|
|
|
|
|
|
$item->linkpath; |
|
383
|
|
|
|
|
|
|
$item->linkpath($path); |
|
384
|
|
|
|
|
|
|
|
|
385
|
|
|
|
|
|
|
Get and set the new link path from $parent. Usually called from the method "change_path" of the parent object. |
|
386
|
|
|
|
|
|
|
|
|
387
|
|
|
|
|
|
|
=head2 page_folder_name |
|
388
|
|
|
|
|
|
|
|
|
389
|
|
|
|
|
|
|
$item->page_folder_name; |
|
390
|
|
|
|
|
|
|
$item->page_folder_name('pages'); |
|
391
|
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
Get and set name of a folder to store HTML files linked from $source_path. If $item does not have the name, $parent give the name. |
|
393
|
|
|
|
|
|
|
|
|
394
|
|
|
|
|
|
|
=cut |
|
395
|
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
sub page_folder_name { |
|
397
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
|
398
|
|
|
|
|
|
|
|
|
399
|
0
|
0
|
|
|
|
|
if (@_) { |
|
400
|
0
|
|
|
|
|
|
return $self->{'page_folder_name'} = shift @_; |
|
401
|
|
|
|
|
|
|
} |
|
402
|
|
|
|
|
|
|
|
|
403
|
0
|
0
|
|
|
|
|
if (exists $self->{'page_folder_name'}) { |
|
404
|
0
|
|
|
|
|
|
return $self->{'page_folder_name'}; |
|
405
|
|
|
|
|
|
|
} |
|
406
|
|
|
|
|
|
|
else { |
|
407
|
0
|
|
|
|
|
|
return $self->parent->page_folder_name; |
|
408
|
|
|
|
|
|
|
} |
|
409
|
|
|
|
|
|
|
} |
|
410
|
|
|
|
|
|
|
|
|
411
|
|
|
|
|
|
|
=head2 resource_folder_name |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
$item->resource_folder_name; |
|
414
|
|
|
|
|
|
|
$item->resource_folder_name('assets'); |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
Get and set name of a folder to store not HTML files(javascript, image, CSS) linked from $source_path. If $item does not have the name, $parent gives the name. |
|
417
|
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=cut |
|
419
|
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
sub resource_folder_name { |
|
421
|
0
|
|
|
0
|
1
|
|
my $self = shift @_; |
|
422
|
|
|
|
|
|
|
|
|
423
|
0
|
0
|
|
|
|
|
if (@_) { |
|
424
|
0
|
|
|
|
|
|
return $self->{'resource_folder_name'} = shift @_; |
|
425
|
|
|
|
|
|
|
} |
|
426
|
|
|
|
|
|
|
|
|
427
|
0
|
0
|
|
|
|
|
if (exists $self->{'resource_folder_name'}) { |
|
428
|
0
|
|
|
|
|
|
return $self->{'resource_folder_name'}; |
|
429
|
|
|
|
|
|
|
} |
|
430
|
|
|
|
|
|
|
else { |
|
431
|
0
|
|
|
|
|
|
return $self->parent->resource_folder_name; |
|
432
|
|
|
|
|
|
|
} |
|
433
|
|
|
|
|
|
|
} |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
436
|
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
L, L, L, L |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
=head1 AUTHOR |
|
440
|
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
Tetsuro KURITA |
|
442
|
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
=cut |
|
444
|
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
1; |