line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# content items used for media items. In reality this is just |
3
|
|
|
|
|
|
|
# used as a placeholder for metadata. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package HTML::WebMake::MediaContent; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
7
|
use HTML::WebMake::Content; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
54
|
|
9
|
1
|
|
|
1
|
|
12
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
10
|
1
|
|
|
1
|
|
4
|
use locale; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
1921
|
use vars qw{ |
13
|
|
|
|
|
|
|
@ISA |
14
|
|
|
|
|
|
|
$MIN_FMT_CACHE_LEN |
15
|
1
|
|
|
1
|
|
33
|
}; |
|
1
|
|
|
|
|
2
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@ISA = qw(HTML::WebMake::Content); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
$MIN_FMT_CACHE_LEN = 1024; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
########################################################################### |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
25
|
0
|
|
0
|
|
|
|
$class = ref($class) || $class; |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
my ($main, $name, $attrs) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new ($name, |
30
|
|
|
|
|
|
|
$main->{ignore_for_dependencies}, |
31
|
|
|
|
|
|
|
$attrs, '', undef); |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
bless ($self, $class); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# do some references now to avoid doing them later, minor speedup |
36
|
0
|
|
|
|
|
|
my $util = $main->{util}; |
37
|
0
|
|
|
|
|
|
my $metadata = $main->{metadata}; |
38
|
0
|
|
|
|
|
|
my $attrval; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# see if we have 'map=false' as an attribute |
41
|
0
|
|
|
|
|
|
$attrval = $attrs->{'map'}; |
42
|
0
|
|
0
|
|
|
|
$attrval ||= $metadata->get_attrdefault ('map'); |
43
|
0
|
0
|
|
|
|
|
if (defined $attrval) { |
44
|
0
|
0
|
|
|
|
|
if (!$util->parse_boolean ($attrval)) { |
45
|
0
|
|
|
|
|
|
$self->{no_map} = 1; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
delete $self->{'map'}; # in case it was set as an attr |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
|
$self->{keep_as_is} = 1; |
51
|
0
|
|
|
|
|
|
$metadata->add_metadefaults ($self); |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$main->add_new_content_to_map ($name, $self); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$self; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
|
|
0
|
0
|
|
sub dbg { HTML::WebMake::Main::dbg (@_); } |
59
|
0
|
|
|
0
|
0
|
|
sub dbg2 { HTML::WebMake::Main::dbg2 (@_); } |
60
|
0
|
|
|
0
|
0
|
|
sub vrb { HTML::WebMake::Main::vrb (@_); } |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub as_string { |
65
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
66
|
0
|
|
|
|
|
|
"\$\{".$self->{name}."\}"; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub is_generated_content { |
72
|
0
|
|
|
0
|
1
|
|
0; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub expand { |
78
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
79
|
0
|
|
|
|
|
|
return $self->{main}->curly_subst ($self->{name}, $self->{name}); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub expand_no_ref { |
83
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
84
|
0
|
|
|
|
|
|
return $self->{main}->fileless_subst ($self->{name}, '${'.$self->{name}.'}'); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
sub get_metadata { |
90
|
0
|
|
|
0
|
1
|
|
my ($self, $key) = @_; |
91
|
|
|
|
|
|
|
|
92
|
0
|
0
|
|
|
|
|
if (!defined $self->{cached_metas}) { |
93
|
0
|
|
|
|
|
|
$self->{cached_metas} = { }; |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my $val = $self->{cached_metas}->{$key}; |
97
|
0
|
|
|
|
|
|
my $main = $self->{main}; |
98
|
|
|
|
|
|
|
|
99
|
0
|
0
|
|
|
|
|
if (!defined $val) { |
100
|
0
|
|
|
|
|
|
$val = $main->quiet_curly_meta_subst ($HTML::WebMake::Main::SUBST_META, $self->{name}.".".$key); |
101
|
0
|
|
0
|
|
|
|
$val ||= $main->{metadata}->get_default_value ($key); |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
$val = $main->{metadata}->convert_to_type ($key, $val); |
104
|
0
|
|
|
|
|
|
$self->{cached_metas}->{$key} = $val; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
return $val; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
sub create_extra_metas_if_needed { |
113
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
114
|
0
|
0
|
|
|
|
|
if (!defined $self->{extra_metas}) { |
115
|
0
|
|
|
|
|
|
$self->{extra_metas} = { }; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub load_metadata { |
122
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
123
|
|
|
|
|
|
|
|
124
|
0
|
0
|
|
|
|
|
if (!defined ($self->{parsed_metadata_tags})) { |
125
|
0
|
|
|
|
|
|
$self->add_extra_metas ($self->{name}); |
126
|
0
|
|
|
|
|
|
$self->infer_implicit_metas(); |
127
|
0
|
|
|
|
|
|
$self->{parsed_metadata_tags} = 1; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
sub parse_metadata_tags { |
134
|
0
|
|
|
0
|
0
|
|
return; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub infer_implicit_metas { |
140
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
141
|
|
|
|
|
|
|
|
142
|
0
|
0
|
0
|
|
|
|
if (defined $self->{main}->{metadatas}->{"this.title"} |
143
|
|
|
|
|
|
|
&& defined $self->{main}->{metadatas}->{$self->{name}.".title"}) |
144
|
|
|
|
|
|
|
{ |
145
|
0
|
|
|
|
|
|
return; # no need to infer it, it's already defined |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
# TODO? read titles from GIF comments etc? |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
|
my $val = $self->{name}; |
151
|
0
|
|
|
|
|
|
$val =~ s,^.*[/\\],,g; |
152
|
0
|
|
|
|
|
|
$val =~ s,\.(?:gif|jp[eg]+|mp[eg3]+|xpm|bmp|tif+|mov|ra|ram|png|mng)$,,ig; |
153
|
0
|
|
|
|
|
|
$val =~ s/_/ /gs; |
154
|
0
|
|
|
|
|
|
$self->add_inferred_metadata ("title", $val); |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub add_inferred_metadata { |
160
|
0
|
|
|
0
|
0
|
|
my ($self, $name, $val) = @_; |
161
|
|
|
|
|
|
|
|
162
|
0
|
|
|
|
|
|
my $attrs = { }; |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
|
$val =~ s/<[^>]+>//g; # trim wayward HTML tags |
165
|
0
|
|
|
|
|
|
$val =~ s/^\s+//; |
166
|
0
|
|
|
|
|
|
$val =~ s/\s+$//; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
|
dbg ("inferring $name metadata from image: \"$val\""); |
169
|
0
|
|
|
|
|
|
$self->{main}->add_metadata ($self->{name}, $name, $val, $attrs, 0); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub add_extra_metas { |
175
|
0
|
|
|
0
|
0
|
|
my ($self, $from) = @_; |
176
|
|
|
|
|
|
|
# also add our own extra metadata from nav links, tags |
177
|
|
|
|
|
|
|
# etc. |
178
|
0
|
|
|
|
|
|
my ($metaname, $val); |
179
|
0
|
|
|
|
|
|
while (($metaname, $val) = each %{$self->{extra_metas}}) { |
|
0
|
|
|
|
|
|
|
180
|
0
|
|
|
|
|
|
$self->{main}->add_metadata ($from, $metaname, $val, { }, 1); |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub get_score { |
187
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
188
|
0
|
|
|
|
|
|
return $self->get_metadata ("score"); |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub get_title { |
192
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
193
|
0
|
|
|
|
|
|
return $self->get_metadata ("title"); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub get_modtime { |
199
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
200
|
0
|
|
|
|
|
|
return $self->{main}->cached_get_modtime ($self->get_filename()); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
sub get_text_as { |
206
|
0
|
|
|
0
|
0
|
|
my ($self, $format) = @_; |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
# TODO -- return an tag for images etc.? |
209
|
0
|
|
|
|
|
|
return ''; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub load_text_if_needed { |
215
|
0
|
|
|
0
|
0
|
|
return; |
216
|
|
|
|
|
|
|
} |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
sub unload_text { |
219
|
0
|
|
|
0
|
0
|
|
return; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub is_from_datasource { |
223
|
0
|
|
|
0
|
0
|
|
return 0; |
224
|
|
|
|
|
|
|
} |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub touch_last_used { |
227
|
0
|
|
|
0
|
0
|
|
return; |
228
|
|
|
|
|
|
|
} |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
sub add_ref_from_url { |
233
|
0
|
|
|
0
|
0
|
|
my ($self, $filename) = @_; |
234
|
|
|
|
|
|
|
|
235
|
0
|
0
|
|
|
|
|
return if ($filename =~ /^\(/); # (eval), (dep_ignore) etc. |
236
|
|
|
|
|
|
|
|
237
|
0
|
0
|
|
|
|
|
if (!defined $self->{reffed_in_url}) { |
238
|
0
|
|
|
|
|
|
$self->{reffed_in_url} = $filename; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub get_url { |
243
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
244
|
|
|
|
|
|
|
|
245
|
0
|
|
|
|
|
|
my $url = $self->{reffed_in_url}; |
246
|
0
|
0
|
|
|
|
|
if (defined $url) { return $url; } |
|
0
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
|
248
|
0
|
|
|
|
|
|
$url = $self->{main}->getcache()->get_metadata ($self->{name}.".url"); |
249
|
|
|
|
|
|
|
|
250
|
0
|
0
|
|
|
|
|
if (defined $url) { |
251
|
0
|
|
|
|
|
|
$self->{reffed_in_url} = $url; |
252
|
0
|
|
|
|
|
|
return $url; |
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
|
255
|
0
|
|
|
|
|
|
$url = $self->{main}->make_deferred_url ($self->{name}); |
256
|
0
|
|
|
|
|
|
return $url; |
257
|
|
|
|
|
|
|
} |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
sub add_navigation_metadata { |
262
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
263
|
|
|
|
|
|
|
|
264
|
0
|
0
|
0
|
|
|
|
return if ($self->{no_map} || $self->is_generated_content()); |
265
|
0
|
0
|
|
|
|
|
return if ($self->{added_nav_metas_flag}); |
266
|
0
|
|
|
|
|
|
$self->{added_nav_metas_flag} = 1; |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
$self->create_extra_metas_if_needed(); |
269
|
0
|
0
|
|
|
|
|
if (defined ($self->{up_content})) { |
270
|
0
|
|
|
|
|
|
$self->{extra_metas}->{'nav_up'} = $self->{up_content}->get_name(); |
271
|
|
|
|
|
|
|
} |
272
|
0
|
0
|
|
|
|
|
if (defined ($self->{next_content})) { |
273
|
0
|
|
|
|
|
|
$self->{extra_metas}->{'nav_next'} = $self->{next_content}->get_name(); |
274
|
|
|
|
|
|
|
} |
275
|
0
|
0
|
|
|
|
|
if (defined ($self->{prev_content})) { |
276
|
0
|
|
|
|
|
|
$self->{extra_metas}->{'nav_prev'} = $self->{prev_content}->get_name(); |
277
|
|
|
|
|
|
|
} |
278
|
|
|
|
|
|
|
} |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
sub invalidate_cached_nav_metadata { |
281
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
282
|
0
|
|
|
|
|
|
$self->{added_nav_metas_flag} = 0; |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
sub is_only_usable_from_deferred_refs { |
288
|
0
|
|
|
0
|
0
|
|
0; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
1; |