line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# content items used to store metadata. |
3
|
|
|
|
|
|
|
# main factor here is that these content items cannot, themselves, |
4
|
|
|
|
|
|
|
# have metadata attached. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package HTML::WebMake::MetadataContent; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use HTML::WebMake::Content; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
35
|
|
9
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
349
|
|
10
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
53
|
|
11
|
1
|
|
|
1
|
|
6
|
use locale; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
8
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
970
|
use vars qw{ |
14
|
|
|
|
|
|
|
@ISA |
15
|
1
|
|
|
1
|
|
40
|
}; |
|
1
|
|
|
|
|
2
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
@ISA = qw(HTML::WebMake::Content); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
########################################################################### |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
24
|
0
|
|
0
|
|
|
|
$class = ref($class) || $class; |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new (@_); |
27
|
0
|
|
|
|
|
|
bless ($self, $class); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
$self->{cannot_have_metadata} = 1; |
30
|
0
|
|
|
|
|
|
$self->{no_map} = 1; |
31
|
0
|
|
|
|
|
|
$self; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
0
|
|
|
0
|
0
|
|
sub dbg { HTML::WebMake::Main::dbg (@_); } |
35
|
0
|
|
|
0
|
0
|
|
sub vrb { HTML::WebMake::Main::vrb (@_); } |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub as_string { |
40
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
41
|
0
|
|
|
|
|
|
"\$\[".$self->{name}."\]"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub is_generated_content { |
47
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
48
|
0
|
|
|
|
|
|
1; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub expand { |
54
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
55
|
0
|
|
|
|
|
|
return $self->{main}->curly_subst ($self->{name}, $self->{name}); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub expand_no_ref { |
59
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
60
|
0
|
|
|
|
|
|
return $self->{main}->fileless_subst ($self->{name}, '$['.$self->{name}.']'); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub get_metadata { |
66
|
0
|
|
|
0
|
1
|
|
my ($self, $key) = @_; |
67
|
0
|
|
|
|
|
|
my $val; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# kludge: ensure metadata clusters beside its parent datum |
70
|
|
|
|
|
|
|
# for (full) sitemaps. |
71
|
0
|
0
|
|
|
|
|
if ($key eq 'score') { $val = '0'; } |
|
0
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
if ($key eq 'declared') { $val = $self->get_declared(); } |
|
0
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
|
74
|
0
|
0
|
0
|
|
|
|
if (!defined $val || $val eq '') { |
75
|
0
|
|
|
|
|
|
$val = $self->{main}->{metadata}->get_default_value ($key); |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
$self->{main}->{metadata}->convert_to_type ($key, $val); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
0
|
0
|
|
sub create_extra_metas_if_needed { } |
84
|
0
|
|
|
0
|
0
|
|
sub load_metadata { } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub get_score { |
89
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
90
|
0
|
|
|
|
|
|
return $self->get_metadata ("score"); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub get_title { |
94
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
95
|
0
|
|
|
|
|
|
return $self->get_metadata ("title"); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item $modtime = $cont->get_modtime(); |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
Return a content item's modification date, in UNIX time_t format, |
103
|
|
|
|
|
|
|
ie. seconds since Jan 1 1970. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=cut |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
sub get_modtime { |
108
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
109
|
0
|
|
|
|
|
|
return $self->{main}->cached_get_modtime ($self->get_filename()); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub get_text_as { |
115
|
0
|
|
|
0
|
0
|
|
my ($self, $format) = @_; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
|
if (!defined $format) { |
118
|
0
|
|
|
|
|
|
carp ($self->as_string().": get_text_as with undef arg"); |
119
|
0
|
|
|
|
|
|
return ""; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
0
|
|
|
|
|
|
my $fmt = $self->get_format(); |
123
|
0
|
0
|
|
|
|
|
if (!defined $fmt) { |
124
|
0
|
|
|
|
|
|
carp ($self->as_string().": no format defined"); |
125
|
0
|
|
|
|
|
|
return ""; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $txt = $self->{text}; |
129
|
0
|
0
|
|
|
|
|
if (!defined $txt) { die "undefined text for $self->{name}"; } |
|
0
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
|
131
|
0
|
0
|
|
|
|
|
if ($fmt ne $format) { |
132
|
0
|
|
|
|
|
|
$txt = $self->{main}->{format_conv}->convert |
133
|
|
|
|
|
|
|
($self, $fmt, $format, $txt, 1); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
$self->{main}->subst ($self->{name}, \$txt); |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# always remove leading & trailing whitespace from HTML content. |
139
|
0
|
0
|
|
|
|
|
if ($format eq 'text/html') { |
140
|
0
|
|
|
|
|
|
$txt =~ s/^\s+//s;$txt =~ s/\s+$//s; |
|
0
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
} |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
$txt; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
147
|
|
|
|
|
|
|
|
148
|
0
|
|
|
0
|
0
|
|
sub add_ref_from_url { |
149
|
|
|
|
|
|
|
} |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub get_url { |
152
|
|
|
|
|
|
|
# metadata doesn't have URLs, the content items do |
153
|
0
|
|
|
0
|
1
|
|
""; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub is_only_usable_from_deferred_refs { |
159
|
0
|
|
|
0
|
0
|
|
my ($self) = @_; |
160
|
0
|
|
|
|
|
|
1; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# ------------------------------------------------------------------------- |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |