line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
=head1 NAME |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
Content - a content item. |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 SYNOPSIS |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
<{perl |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
$cont = get_content_object ("foo.txt"); |
12
|
|
|
|
|
|
|
[... etc.] |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
}> |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This object allows manipulation of WebMake content items directly. |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 METHODS |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over 4 |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=cut |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package HTML::WebMake::Content; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
57
|
|
30
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
31
|
1
|
|
|
1
|
|
5
|
use locale; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
32
|
|
|
|
|
|
|
|
33
|
1
|
|
|
|
|
2433
|
use vars qw{ |
34
|
|
|
|
|
|
|
@ISA |
35
|
|
|
|
|
|
|
%SORT_SUBS |
36
|
1
|
|
|
1
|
|
29
|
}; |
|
1
|
|
|
|
|
1
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
@ISA = qw(); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
%SORT_SUBS = (); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
########################################################################### |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub new ($$$$$$$) { |
46
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
47
|
0
|
|
0
|
|
|
|
$class = ref($class) || $class; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my ($name, $file, $attrs, $text, $datasource, $ismetadata) = @_; |
50
|
0
|
|
|
|
|
|
my $attrval; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $self = { %$attrs }; # copy the attrs |
53
|
0
|
|
|
|
|
|
bless ($self, $class); |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
$self->{name} = $name; |
56
|
0
|
|
|
|
|
|
$self->{main} = $file->{main}; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if (defined $text) { |
59
|
0
|
|
|
|
|
|
$self->{text} = $text; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
0
|
|
|
|
|
|
my $metadata = $self->{main}->{metadata}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# check this content item's format. text/html is the default, so |
65
|
|
|
|
|
|
|
# if it's set to that, delete it to save space; otherwise, convert |
66
|
|
|
|
|
|
|
# it to a compressed representation to save space. |
67
|
0
|
|
|
|
|
|
$attrval = $attrs->{'format'}; |
68
|
0
|
|
0
|
|
|
|
$attrval ||= $metadata->get_attrdefault ('format'); |
69
|
0
|
0
|
|
|
|
|
if (defined $attrval) { |
70
|
0
|
0
|
|
|
|
|
if ($attrval eq 'text/html') { |
71
|
0
|
|
|
|
|
|
delete $self->{format}; |
72
|
|
|
|
|
|
|
} else { |
73
|
0
|
|
|
|
|
|
$self->{format} = |
74
|
|
|
|
|
|
|
HTML::WebMake::FormatConvert::format_name_to_zname($attrval); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$self->{location} = \$file->{filename}; |
79
|
0
|
|
|
|
|
|
$self->{deps} = $self->mk_deps ($file->get_deps()); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# sitemap support. |
82
|
0
|
|
|
|
|
|
$attrval = $attrs->{'up'}; |
83
|
0
|
|
0
|
|
|
|
$attrval ||= $metadata->get_attrdefault ('up'); |
84
|
0
|
0
|
|
|
|
|
if (defined $attrval) { |
85
|
0
|
|
|
|
|
|
$self->{up_name} = $attrval; |
86
|
0
|
|
|
|
|
|
delete $self->{'up'}; # in case it was set as an attr |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$self; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
0
|
|
|
0
|
0
|
|
sub dbg { HTML::WebMake::Main::dbg (@_); } |
93
|
0
|
|
|
0
|
0
|
|
sub vrb { HTML::WebMake::Main::vrb (@_); } |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item $text = $cont->get_name(); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Return the content item's name. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=cut |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub get_name { |
104
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
105
|
0
|
|
|
|
|
|
$self->{name}; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item $text = $cont->as_string(); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
A textual description of the object for debugging purposes; currently it's |
111
|
|
|
|
|
|
|
name. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=cut |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
sub as_string { |
116
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
117
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item $fname = $cont->get_filename(); |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Get the filename or datasource location that this content was loaded from. |
125
|
|
|
|
|
|
|
Datasource locations look like this: |
126
|
|
|
|
|
|
|
C:C, e.g. C or |
127
|
|
|
|
|
|
|
C. |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=cut |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub get_filename { |
132
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
133
|
0
|
|
|
|
|
|
return ${$self->{location}}; |
|
0
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item @filenames = $cont->get_deps(); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Return an array of filenames and locations that this content depends on, i.e. |
139
|
|
|
|
|
|
|
the filenames or locations that it contains variable references to. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=cut |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub get_deps { |
144
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
map { |
147
|
0
|
0
|
|
|
|
|
if ($_ eq "\001") { $self->{location}; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
148
|
0
|
|
|
|
|
|
else { $_; } |
149
|
|
|
|
|
|
|
} split (/\0/, $self->{deps}); |
150
|
|
|
|
|
|
|
} |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub mk_deps { |
153
|
0
|
|
|
0
|
0
|
|
my ($self, $deps) = @_; |
154
|
0
|
|
|
|
|
|
my @compressed = (); |
155
|
|
|
|
|
|
|
|
156
|
0
|
|
|
|
|
|
foreach my $dep (@{$deps}) { |
|
0
|
|
|
|
|
|
|
157
|
0
|
0
|
|
|
|
|
if ($dep eq $HTML::WebMake::Main::SUBST_DEP_IGNORE) { next; } |
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
158
|
0
|
|
|
|
|
|
elsif ($dep eq $HTML::WebMake::Main::SUBST_META) { next; } |
159
|
0
|
|
|
|
|
|
elsif ($dep eq $self->{location}) { push (@compressed, "\001"); next; } |
|
0
|
|
|
|
|
|
|
160
|
0
|
|
|
|
|
|
push (@compressed, $dep); |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
0
|
|
|
|
|
|
join ("\0", @compressed); |
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=item $flag = $cont->is_generated_content(); |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Whether or not a content item was generated from Perl code, or is metadata. |
169
|
|
|
|
|
|
|
Generated content items cannot themselves hold metadata. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=cut |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub is_generated_content { |
174
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
175
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item $val = $cont->expand() |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
Expand a content item, as if in a curly-bracket content reference. If the |
183
|
|
|
|
|
|
|
content item has not been expanded before, the current output file will be |
184
|
|
|
|
|
|
|
noted as the content item's ''main'' URL. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub expand { |
189
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
190
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item $val = $cont->expand_no_ref() |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Expand a content item, as if in a curly-bracket content reference. The current |
196
|
|
|
|
|
|
|
output file will not be used as the content item's ''main'' URL. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
sub expand_no_ref { |
201
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
202
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
203
|
|
|
|
|
|
|
} |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=item $val = $cont->get_metadata($metaname); |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Get an item of this object's metadata, e.g. |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
$score = $cont->get_metadata("score"); |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
The metadatum is converted to its native type, e.g. C is return as an |
214
|
|
|
|
|
|
|
integer, C as a string, etc. If the metadatum is not provided, the |
215
|
|
|
|
|
|
|
default value for that item, defined in HTML::WebMake::Metadata, is used. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
sub get_metadata { |
220
|
0
|
|
|
0
|
1
|
|
my ($self, $key) = @_; |
221
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub create_extra_metas_if_needed { |
227
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
228
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
sub load_metadata { |
234
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
235
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=item $score = $cont->get_score(); |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
Return a content item's score. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
=cut |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
sub get_score { |
247
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
248
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
249
|
|
|
|
|
|
|
} |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=item $title = $cont->get_title(); |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
Return a content item's title. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
sub get_title { |
258
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
259
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
260
|
|
|
|
|
|
|
} |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
=item $modtime = $cont->get_modtime(); |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Return a content item's modification date, in UNIX time_t format, |
267
|
|
|
|
|
|
|
ie. seconds since Jan 1 1970. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=cut |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub get_modtime { |
272
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
273
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
sub set_declared { |
279
|
0
|
|
|
0
|
0
|
|
my ($self, $order) = @_; |
280
|
0
|
|
|
|
|
|
$self->{decl_order} = $order; |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
=item $order = $cont->get_declared(); |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
Returns the content item's declaration order. This is a number representing |
286
|
|
|
|
|
|
|
when the content item was first encountered in the WebMake file; earlier |
287
|
|
|
|
|
|
|
content items have a lower declaration order. Useful for sorting. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=cut |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub get_declared { |
292
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
293
|
0
|
|
|
|
|
|
return $self->{decl_order}; |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
sub get_magic_metadata { |
299
|
0
|
|
|
0
|
0
|
|
my ($self, $from, $key) = @_; |
300
|
0
|
|
|
|
|
|
my $val; |
301
|
|
|
|
|
|
|
|
302
|
0
|
0
|
|
|
|
|
if ($key eq 'name') { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
303
|
0
|
|
|
|
|
|
return $self->get_name(); |
304
|
|
|
|
|
|
|
} |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
elsif ($key eq 'url') { |
307
|
0
|
0
|
|
|
|
|
return "" if ($self->is_generated_content()); |
308
|
0
|
|
|
|
|
|
$val = $self->get_url(); |
309
|
0
|
0
|
|
|
|
|
if (!defined $val) { |
310
|
0
|
|
|
|
|
|
vrb ("no URL defined for content \${".$self->{name}. |
311
|
|
|
|
|
|
|
".$key} in \"$from\"."); |
312
|
0
|
|
|
|
|
|
return ""; |
313
|
|
|
|
|
|
|
} |
314
|
0
|
|
|
|
|
|
return $val; |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
elsif ($key eq 'mtime') { |
318
|
0
|
|
|
|
|
|
return $self->get_modtime(); |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
elsif ($key eq 'declared') { |
322
|
0
|
|
|
|
|
|
return $self->get_declared(); |
323
|
|
|
|
|
|
|
} |
324
|
|
|
|
|
|
|
|
325
|
|
|
|
|
|
|
elsif ($key eq 'is_generated') { |
326
|
0
|
0
|
|
|
|
|
return ($self->is_generated_content()) ? '1' : '0'; |
327
|
|
|
|
|
|
|
} |
328
|
|
|
|
|
|
|
|
329
|
0
|
|
|
|
|
|
return undef; |
330
|
|
|
|
|
|
|
} |
331
|
|
|
|
|
|
|
|
332
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
333
|
|
|
|
|
|
|
|
334
|
|
|
|
|
|
|
sub add_kid { |
335
|
0
|
|
|
0
|
0
|
|
my ($self, $kid) = @_; |
336
|
|
|
|
|
|
|
|
337
|
0
|
0
|
|
|
|
|
return if ($kid eq $self); |
338
|
|
|
|
|
|
|
|
339
|
0
|
0
|
|
|
|
|
if (!defined $self->{kids}) { |
340
|
0
|
|
|
|
|
|
$self->{kids} = [ ]; |
341
|
|
|
|
|
|
|
} |
342
|
|
|
|
|
|
|
|
343
|
0
|
|
|
|
|
|
push (@{$self->{kids}}, $kid); |
|
0
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
} |
345
|
|
|
|
|
|
|
|
346
|
|
|
|
|
|
|
sub has_any_kids { |
347
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
348
|
0
|
0
|
|
|
|
|
if (!defined $self->{kids}) { return 0; } |
|
0
|
|
|
|
|
|
|
349
|
0
|
0
|
|
|
|
|
if ($#{$self->{kids}} >= 0) { return 1; } |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
350
|
0
|
|
|
|
|
|
return 0; |
351
|
|
|
|
|
|
|
} |
352
|
|
|
|
|
|
|
|
353
|
|
|
|
|
|
|
=item @kidobjs = $cont->get_kids ($sortstring); |
354
|
|
|
|
|
|
|
|
355
|
|
|
|
|
|
|
Get the child content items for this item. The ''child'' content items |
356
|
|
|
|
|
|
|
are items that use this content as their C metadatum. |
357
|
|
|
|
|
|
|
|
358
|
|
|
|
|
|
|
Returns a list of content objects in unsorted order. |
359
|
|
|
|
|
|
|
|
360
|
|
|
|
|
|
|
=cut |
361
|
|
|
|
|
|
|
|
362
|
|
|
|
|
|
|
sub get_kids { |
363
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
364
|
0
|
0
|
|
|
|
|
if (!defined $self->{kids}) { return (); } |
|
0
|
|
|
|
|
|
|
365
|
0
|
|
|
|
|
|
@{$self->{kids}}; |
|
0
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
} |
367
|
|
|
|
|
|
|
|
368
|
|
|
|
|
|
|
=item @kidobjs = $cont->get_sorted_kids ($sortstring); |
369
|
|
|
|
|
|
|
|
370
|
|
|
|
|
|
|
Get the child content items for this item. The ''child'' content items |
371
|
|
|
|
|
|
|
are items that use this content as their C metadatum. |
372
|
|
|
|
|
|
|
|
373
|
|
|
|
|
|
|
Returns a list of content objects sorted by the provided sort string. |
374
|
|
|
|
|
|
|
|
375
|
|
|
|
|
|
|
=cut |
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
sub get_sorted_kids { |
378
|
0
|
|
|
0
|
1
|
|
my ($self, $sortby) = @_; |
379
|
|
|
|
|
|
|
|
380
|
0
|
|
|
|
|
|
my $sortsub; |
381
|
0
|
0
|
|
|
|
|
if (defined $sortby) { |
|
|
0
|
|
|
|
|
|
382
|
0
|
|
|
|
|
|
$sortsub = $self->get_sort_sub($sortby); |
383
|
|
|
|
|
|
|
} elsif (defined $self->{kid_sort_str}) { |
384
|
0
|
|
|
|
|
|
$sortsub = $self->get_sort_sub($self->{kid_sort_str}); |
385
|
|
|
|
|
|
|
} else { |
386
|
0
|
|
|
|
|
|
$sortsub = $self->get_sort_sub('score title declared'); |
387
|
|
|
|
|
|
|
} |
388
|
0
|
|
|
|
|
|
sort $sortsub ($self->get_kids()); |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
|
391
|
|
|
|
|
|
|
sub set_sort_string { |
392
|
0
|
|
|
0
|
0
|
|
my ($self, $str) = @_; |
393
|
0
|
|
|
|
|
|
$self->{kid_sort_str} = $str; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
397
|
|
|
|
|
|
|
|
398
|
|
|
|
|
|
|
# get and eval() a sort subroutine for the given sorting criteria. |
399
|
|
|
|
|
|
|
# stores cached sort sub { } refs in the %SORT_SUBS global array to |
400
|
|
|
|
|
|
|
# avoid re-evaluating the same piece of perl code repeatedly. |
401
|
|
|
|
|
|
|
# |
402
|
|
|
|
|
|
|
sub get_sort_sub { |
403
|
0
|
|
|
0
|
0
|
|
my ($self, $sortstr) = @_; |
404
|
|
|
|
|
|
|
|
405
|
0
|
0
|
|
|
|
|
if (!defined $SORT_SUBS{$sortstr}) { |
406
|
0
|
|
|
|
|
|
my $sortsubstr = $self->{main}->{metadata}->string_to_sort_sub ($sortstr); |
407
|
0
|
|
|
|
|
|
my $sortsub = eval $sortsubstr; |
408
|
0
|
|
|
|
|
|
$SORT_SUBS{$sortstr} = $sortsub; |
409
|
|
|
|
|
|
|
} |
410
|
|
|
|
|
|
|
|
411
|
0
|
|
|
|
|
|
$SORT_SUBS{$sortstr}; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
|
414
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
415
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
sub get_format { |
417
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
418
|
0
|
0
|
|
|
|
|
if (!defined $self->{format}) { return 'text/html'; } |
|
0
|
|
|
|
|
|
|
419
|
0
|
|
|
|
|
|
return HTML::WebMake::FormatConvert::format_zname_to_name($self->{format}); |
420
|
|
|
|
|
|
|
} |
421
|
|
|
|
|
|
|
|
422
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
sub get_text_as { |
425
|
0
|
|
|
0
|
0
|
|
my ($self, $format) = @_; |
426
|
0
|
|
|
|
|
|
croak "undefined by subclass"; |
427
|
|
|
|
|
|
|
} |
428
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
430
|
|
|
|
|
|
|
|
431
|
0
|
|
|
0
|
0
|
|
sub unload_text { } |
432
|
|
|
|
|
|
|
|
433
|
0
|
|
|
0
|
0
|
|
sub is_from_datasource { 0; } |
434
|
|
|
|
|
|
|
|
435
|
0
|
|
|
0
|
0
|
|
sub touch_last_used { } |
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
sub get_up_content { |
440
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
441
|
0
|
|
|
|
|
|
my $cont; |
442
|
|
|
|
|
|
|
|
443
|
0
|
0
|
|
|
|
|
if (defined $self->{up_obj}) { return $self->{up_obj}; } |
|
0
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
|
445
|
|
|
|
|
|
|
# magic variables do not appear in the tree. |
446
|
0
|
0
|
|
|
|
|
if ($self->{name} =~ /^WebMake\./) { return undef; } |
|
0
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
# see if we got an "up" attr passed in. |
449
|
0
|
0
|
|
|
|
|
if (defined $self->{up_name}) { |
450
|
0
|
|
|
|
|
|
$cont = $self->up_name_to_content ($self->{up_name}); |
451
|
0
|
0
|
|
|
|
|
if (defined $cont) { return $cont; } |
|
0
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
# else, it's not valid; clear it. |
453
|
0
|
|
|
|
|
|
undef $self->{up_name}; |
454
|
|
|
|
|
|
|
} |
455
|
|
|
|
|
|
|
|
456
|
|
|
|
|
|
|
# see if we have an "up" metadatum. |
457
|
0
|
0
|
|
|
|
|
if (!$self->is_generated_content()) { |
458
|
0
|
|
|
|
|
|
my $meta = $self->{main}->quiet_curly_meta_subst |
459
|
|
|
|
|
|
|
($HTML::WebMake::Main::SUBST_META, $self->{name}.".up"); |
460
|
0
|
0
|
0
|
|
|
|
if (defined $meta && $meta ne '') { |
461
|
0
|
|
|
|
|
|
$cont = $self->up_name_to_content ($meta); |
462
|
0
|
0
|
|
|
|
|
if (defined $cont) { |
463
|
0
|
|
|
|
|
|
return $cont; |
464
|
|
|
|
|
|
|
} |
465
|
|
|
|
|
|
|
} |
466
|
|
|
|
|
|
|
} |
467
|
|
|
|
|
|
|
|
468
|
|
|
|
|
|
|
# ach, no "up" item. Use the root content. |
469
|
0
|
|
|
|
|
|
return $self->up_name_to_content ($HTML::WebMake::SiteMap::ROOTNAME); |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
sub up_name_to_content { |
473
|
0
|
|
|
0
|
0
|
|
my ($self, $name) = @_; |
474
|
|
|
|
|
|
|
|
475
|
0
|
|
|
|
|
|
my $cont; |
476
|
0
|
0
|
|
|
|
|
if ($name eq $HTML::WebMake::SiteMap::ROOTNAME) { |
477
|
0
|
|
|
|
|
|
$cont = $self->{main}->getmapper()->get_root(); |
478
|
0
|
0
|
|
|
|
|
if (!defined $cont) { return undef; } |
|
0
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
} else { |
480
|
0
|
|
|
|
|
|
$cont = $self->{main}->get_content_obj($name); |
481
|
|
|
|
|
|
|
} |
482
|
|
|
|
|
|
|
|
483
|
0
|
0
|
|
|
|
|
if (defined $cont) { |
484
|
0
|
|
|
|
|
|
$self->{up_name} = $name; |
485
|
0
|
|
|
|
|
|
$self->{up_obj} = $cont; |
486
|
0
|
|
|
|
|
|
return $cont; |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
0
|
|
|
|
|
|
warn $self->as_string().": \"up\" content not found: \$\{". |
490
|
|
|
|
|
|
|
$name."\}\n"; |
491
|
0
|
|
|
|
|
|
return undef; |
492
|
|
|
|
|
|
|
} |
493
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
495
|
|
|
|
|
|
|
|
496
|
|
|
|
|
|
|
sub add_ref_from_url { |
497
|
0
|
|
|
0
|
0
|
|
croak "undefined by subclass"; |
498
|
|
|
|
|
|
|
} |
499
|
|
|
|
|
|
|
|
500
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
501
|
|
|
|
|
|
|
|
502
|
|
|
|
|
|
|
=item $text = $cont->get_url(); |
503
|
|
|
|
|
|
|
|
504
|
|
|
|
|
|
|
Get a content item's URL. The URL is defined as the first page listed in the |
505
|
|
|
|
|
|
|
WebMake file's out tags which refers to that item of content. |
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
Note that, in some cases, the content item may not have been referred to yet by |
508
|
|
|
|
|
|
|
the time it's get_url() method is called. In this case, WebMake will insert a |
509
|
|
|
|
|
|
|
symbolic tag, hold the file in memory, and defer writing the file in question |
510
|
|
|
|
|
|
|
until all other output files have been processed and the URL has been found. |
511
|
|
|
|
|
|
|
|
512
|
|
|
|
|
|
|
=cut |
513
|
|
|
|
|
|
|
|
514
|
|
|
|
|
|
|
sub get_url { |
515
|
0
|
|
|
0
|
1
|
|
croak "undefined by subclass"; |
516
|
|
|
|
|
|
|
} |
517
|
|
|
|
|
|
|
|
518
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
sub set_next { |
521
|
0
|
|
|
0
|
0
|
|
my ($self, $cont) = @_; |
522
|
0
|
|
|
|
|
|
$self->{next_content} = $cont; |
523
|
|
|
|
|
|
|
} |
524
|
|
|
|
|
|
|
|
525
|
|
|
|
|
|
|
sub set_prev { |
526
|
0
|
|
|
0
|
0
|
|
my ($self, $cont) = @_; |
527
|
0
|
|
|
|
|
|
$self->{prev_content} = $cont; |
528
|
|
|
|
|
|
|
} |
529
|
|
|
|
|
|
|
|
530
|
|
|
|
|
|
|
sub set_up { |
531
|
0
|
|
|
0
|
0
|
|
my ($self, $cont) = @_; |
532
|
0
|
|
|
|
|
|
$self->{up_content} = $cont; |
533
|
|
|
|
|
|
|
} |
534
|
|
|
|
|
|
|
|
535
|
0
|
|
|
0
|
0
|
|
sub invalidate_cached_nav_metadata { } |
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
538
|
|
|
|
|
|
|
|
539
|
|
|
|
|
|
|
sub is_only_usable_from_deferred_refs { |
540
|
0
|
|
|
0
|
0
|
|
croak "undefined by subclass"; |
541
|
|
|
|
|
|
|
} |
542
|
|
|
|
|
|
|
|
543
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
544
|
|
|
|
|
|
|
|
545
|
|
|
|
|
|
|
1; |