line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTML::WebMake::DataSource; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
########################################################################### |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# To extend the protocols supported, implement a subclass of DataSourceBase and |
8
|
|
|
|
|
|
|
# add a line of code to get_handler() below. Note that you can get the values |
9
|
|
|
|
|
|
|
# of any tag attributes using the $self->{attrs} hash on this object, so you |
10
|
|
|
|
|
|
|
# can add your own required attributes without modifying this code; just |
11
|
|
|
|
|
|
|
# read them from the hash in your own module. |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
762
|
use HTML::WebMake::DataSources::DirOfFiles; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
14
|
1
|
|
|
1
|
|
618
|
use HTML::WebMake::DataSources::SVFile; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
80
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub get_handler { |
17
|
0
|
|
|
0
|
0
|
|
my ($self, $proto) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
($proto eq 'file') and |
20
|
|
|
|
|
|
|
return new HTML::WebMake::DataSources::DirOfFiles ($self); |
21
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
|
($proto eq 'svfile') and |
23
|
|
|
|
|
|
|
return new HTML::WebMake::DataSources::SVFile ($self); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# ... |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
########################################################################### |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
43
|
|
32
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
747
|
use vars qw{ |
35
|
|
|
|
|
|
|
@ISA |
36
|
1
|
|
|
1
|
|
4
|
}; |
|
1
|
|
|
|
|
1
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
@ISA = qw(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
########################################################################### |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub new ($$$$$) { |
44
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
45
|
0
|
|
0
|
|
|
|
$class = ref($class) || $class; |
46
|
0
|
|
|
|
|
|
my ($main, $src, $name, $attrs) = @_; |
47
|
0
|
|
|
|
|
|
local ($_); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $self = { %$attrs }; |
50
|
0
|
|
|
|
|
|
bless ($self, $class); |
51
|
0
|
|
|
|
|
|
$self->{main} = $main; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$_ = $name; |
54
|
0
|
0
|
|
|
|
|
if (!defined $_) { |
55
|
0
|
|
|
|
|
|
$_ = $self->{main}->{metadata}->get_attrdefault ('name'); |
56
|
|
|
|
|
|
|
} |
57
|
0
|
|
|
|
|
|
$self->{name} = $_; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
$_ = $src; |
60
|
0
|
0
|
|
|
|
|
if (!defined $_) { |
61
|
0
|
|
|
|
|
|
$_ = $self->{main}->{metadata}->get_attrdefault ('src'); |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
$self->{src} = $_; |
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
$self->{attrs} = $attrs; |
66
|
0
|
|
|
|
|
|
for my $attr (qw(prefix suffix namesubst nametr listname)) { |
67
|
0
|
0
|
|
|
|
|
next if (defined $self->{attrs}->{$attr}); |
68
|
0
|
|
|
|
|
|
$self->{attrs}->{$attr} = |
69
|
|
|
|
|
|
|
$self->{main}->{metadata}->get_attrdefault ($attr); |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
|
$self->{proto} = 'file'; |
73
|
0
|
|
|
|
|
|
$self->{file_list} = [ ]; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# try to strip the proto from the src URL. |
76
|
0
|
0
|
|
|
|
|
if ($self->{src} =~ s/^([A-Za-z0-9]+)://) { |
77
|
0
|
|
|
|
|
|
$self->{proto} = $1; |
78
|
0
|
|
|
|
|
|
$self->{proto} =~ tr/A-Z/a-z/; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$self->{hdlr} = $self->get_handler ($self->{proto}); |
82
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if (!defined $self->{hdlr}) { |
84
|
0
|
|
|
|
|
|
warn "Unsupported ".$self->as_string()." protocol: ".$self->{proto}."\n"; |
85
|
|
|
|
|
|
|
} |
86
|
0
|
|
|
|
|
|
$self; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub fixname { |
92
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
if (defined $self->{attrs}->{prefix}) { |
95
|
0
|
|
|
|
|
|
$name = $self->{attrs}->{prefix}.$name; |
96
|
|
|
|
|
|
|
} |
97
|
0
|
0
|
|
|
|
|
if (defined $self->{attrs}->{suffix}) { |
98
|
0
|
|
|
|
|
|
$name .= $self->{attrs}->{suffix}; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
0
|
|
|
|
|
if (defined $self->{attrs}->{namesubst}) { |
102
|
0
|
0
|
|
|
|
|
if ($self->{main}->{paranoid}) { goto para_on; } |
|
0
|
|
|
|
|
|
|
103
|
0
|
0
|
|
|
|
|
eval '$name =~ '.$self->{attrs}->{namesubst}.';1;' |
104
|
|
|
|
|
|
|
or warn "namesubst failed: $!\n"; |
105
|
|
|
|
|
|
|
} |
106
|
0
|
0
|
|
|
|
|
if (defined $self->{attrs}->{nametr}) { |
107
|
0
|
0
|
|
|
|
|
if ($self->{main}->{paranoid}) { goto para_on; } |
|
0
|
|
|
|
|
|
|
108
|
0
|
0
|
|
|
|
|
eval '$name =~ '.$self->{attrs}->{nametr}.';1;' |
109
|
|
|
|
|
|
|
or warn "nametr failed: $!\n"; |
110
|
|
|
|
|
|
|
} |
111
|
0
|
|
|
|
|
|
return $name; |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
para_on: |
114
|
|
|
|
|
|
|
warn "Paranoid mode on: not processing namesubst\n"; |
115
|
0
|
|
|
|
|
|
return $name; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub add_file_to_list { |
119
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
120
|
|
|
|
|
|
|
|
121
|
0
|
|
|
|
|
|
push (@{$self->{file_list}}, $name); |
|
0
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
sub add { |
127
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
HTML::WebMake::Main::dbg ($self->as_string(). |
130
|
|
|
|
|
|
|
": src=$self->{proto}:$self->{src}"); |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
|
|
|
|
if (!defined $self->{hdlr}) { return; } |
|
0
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
$self->{hdlr}->add (); |
134
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
my $lname = $self->{attrs}->{listname}; |
136
|
0
|
0
|
|
|
|
|
if (defined $lname) { |
137
|
|
|
|
|
|
|
# add onto any existing values already there. |
138
|
|
|
|
|
|
|
# the ? at the end means "return '' if not defined" |
139
|
0
|
|
|
|
|
|
my $val = $self->{main}->curly_subst ($HTML::WebMake::Main::SUBST_EVAL, $lname.'?'); |
140
|
0
|
0
|
|
|
|
|
if ($val ne '') { $val .= ' '; } |
|
0
|
|
|
|
|
|
|
141
|
0
|
|
|
|
|
|
$val .= join (' ', @{$self->{file_list}}); |
|
0
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$self->{main}->set_unmapped_content ($lname, $val); |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
} |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub get_location_contents { |
150
|
0
|
|
|
0
|
0
|
|
my ($self, $fname) = @_; |
151
|
0
|
0
|
|
|
|
|
if (!defined $self->{hdlr}) { return; } |
|
0
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
$self->{hdlr}->get_location_contents ($fname); |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub get_location_mod_time { |
158
|
0
|
|
|
0
|
0
|
|
my ($self, $fname) = @_; |
159
|
0
|
0
|
|
|
|
|
if (!defined $self->{hdlr}) { return; } |
|
0
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
$self->{hdlr}->get_location_mod_time ($fname); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
1; |