line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::SiteTear::Root; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
1
|
|
|
1
|
|
5
|
use File::Spec; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
6
|
1
|
|
|
1
|
|
5
|
use File::Basename; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
70
|
|
7
|
|
|
|
|
|
|
#use Cwd; |
8
|
1
|
|
|
1
|
|
785
|
use URI::file; |
|
1
|
|
|
|
|
16399
|
|
|
1
|
|
|
|
|
32
|
|
9
|
1
|
|
|
1
|
|
9
|
use base qw(Class::Accessor); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
573
|
|
10
|
|
|
|
|
|
|
HTML::SiteTear::Root->mk_accessors(qw(source_path |
11
|
|
|
|
|
|
|
source_root_uri |
12
|
|
|
|
|
|
|
resource_folder_name |
13
|
|
|
|
|
|
|
page_folder_name |
14
|
|
|
|
|
|
|
target_path |
15
|
|
|
|
|
|
|
site_root_path |
16
|
|
|
|
|
|
|
site_root_file_uri |
17
|
|
|
|
|
|
|
site_root_uri |
18
|
|
|
|
|
|
|
allow_abs_link |
19
|
|
|
|
|
|
|
only_subitems)); |
20
|
|
|
|
|
|
|
#use Data::Dumper; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '1.43'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 NAME |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
HTML::SiteTear::Root - a root object in a parent chain. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 SYMPOSIS |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use HTML::SiteTear::Root; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
$root = HTML::SiteTear::Root->new('source_path' => $source_path, |
33
|
|
|
|
|
|
|
'target_path' => $destination_path); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
An instanece of this module is for a root object in a parent chain and manage a relation tabel of all source pathes and target pathes. Also gives default folder names. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
our $defaultpage_folder_name = 'pages'; |
42
|
|
|
|
|
|
|
our $defaultresource_folder_name = 'assets'; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 METHODS |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 new |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
$root = HTML::SiteTear::Root->new('source_path' => $source_path, |
49
|
|
|
|
|
|
|
'target_path' => $destination_path); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
make a new instance. |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=cut |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub new { |
56
|
0
|
|
|
0
|
1
|
|
my $class = shift @_; |
57
|
0
|
|
|
|
|
|
my %args = @_; |
58
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new(\%args); |
59
|
0
|
|
|
|
|
|
$self->{'fileMapRef'} = {}; |
60
|
0
|
|
|
|
|
|
$self->{'copiedFiles'} = []; |
61
|
0
|
|
|
|
|
|
$self->set_default_folder_names; |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
0
|
|
|
|
if ($self->site_root_path and $self->site_root_uri) { |
64
|
0
|
|
|
|
|
|
$self->allow_abs_link(1); |
65
|
0
|
|
|
|
|
|
$self->site_root_file_uri(URI::file->new($self->site_root_path)); |
66
|
0
|
|
|
|
|
|
$self->site_root_uri(URI->new($self->site_root_uri)); |
67
|
|
|
|
|
|
|
} |
68
|
0
|
|
|
|
|
|
$self->source_root_uri(URI::file->new($self->source_path)); |
69
|
0
|
|
|
|
|
|
return $self; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub set_default_folder_names { |
73
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
74
|
0
|
|
|
|
|
|
$self->resource_folder_name($defaultresource_folder_name); |
75
|
0
|
|
|
|
|
|
$self->page_folder_name($defaultpage_folder_name); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 add_to_copyied_files |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
$item->add_to_copyied_files($source_path) |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
Add a file path already copied to the copiedFiles table of the root object of the parent chain. |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=cut |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub add_to_copyied_files { |
87
|
0
|
|
|
0
|
1
|
|
my ($self, $path) = @_; |
88
|
|
|
|
|
|
|
#$path = Cwd::realpath($path); |
89
|
0
|
|
|
|
|
|
push @{$self->{'copiedFiles'}}, $path; |
|
0
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
return $path; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 exists_in_copied_files |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
$item->exists_in_copied_files($source_path) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Check existance of $source_path in the copiedFiles entry. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=cut |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub exists_in_copied_files { |
102
|
0
|
|
|
0
|
1
|
|
my ($self, $path) = @_; |
103
|
0
|
|
|
|
|
|
return grep(/^$path$/, @{$self->{'copiedFiles'}}); |
|
0
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 add_to_filemap |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$root->add_to_filemap($source_path, $destination_uri); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Add to copyied file information into the internal table "filemap". |
111
|
|
|
|
|
|
|
A fragment of $destination_uri is dropped. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub add_to_filemap { |
116
|
0
|
|
|
0
|
1
|
|
my ($self, $source_path, $destination_uri) = @_; |
117
|
0
|
|
|
|
|
|
$destination_uri->fragment(undef); |
118
|
0
|
|
|
|
|
|
$self->{'fileMapRef'}->{$source_path} = $destination_uri; |
119
|
0
|
|
|
|
|
|
return $destination_uri; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 exists_in_filemap |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
$root->exists_in_filemap($source_path); |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
check $source_path is entry in FileMap |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub exists_in_filemap { |
131
|
0
|
|
|
0
|
1
|
|
my ($self, $path) = @_; |
132
|
0
|
|
|
|
|
|
return exists($self->{fileMapRef}->{$path}); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
sub item_in_filemap { |
136
|
0
|
|
|
0
|
0
|
|
my ($self, $path) = @_; |
137
|
0
|
|
|
|
|
|
return $self->{'fileMapRef'}->{$path}; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 rel_for_mappedfile |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
$root->rel_for_mappedfile($source_path, $base_uri); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
get relative URI of copied file of $source_path from $base_uri. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub rel_for_mappedfile { |
149
|
0
|
|
|
0
|
1
|
|
my ($self, $source_path, $base_uri) = @_; |
150
|
0
|
|
|
|
|
|
my $target_uri = $self->{'fileMapRef'}->{$source_path}; |
151
|
0
|
|
|
|
|
|
return $target_uri->rel($base_uri); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
sub source_root_path { |
155
|
0
|
|
|
0
|
0
|
|
my $self = shift @_; |
156
|
0
|
|
|
|
|
|
return $self->source_path; |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub source_root { |
160
|
0
|
|
|
0
|
0
|
|
my $self = shift @_; |
161
|
0
|
|
|
|
|
|
return $self |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 SEE ALSO |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L, L, L, L |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 AUTHOR |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
Tetsuro KURITA |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
1; |