130 |
log => 'log4perl.conf', |
log => 'log4perl.conf', |
131 |
detail_url => sub { |
detail_url => sub { |
132 |
my $mfn = shift; |
my $mfn = shift; |
133 |
my $path = "./out/thes/${mfn}.html"; |
my $path = "thes/${mfn}.html"; |
134 |
return $path if (-e $path); |
return $path if (-e "./out/$path"); |
135 |
}, |
}, |
136 |
|
iframe_base => '../', |
137 |
); |
); |
138 |
|
|
139 |
C<tree> is tree array with levels of tree described above. |
C<tree> is tree array with levels of tree described above. |
144 |
C<detail_url> code ref to check if detail html exists (and return URL if |
C<detail_url> code ref to check if detail html exists (and return URL if |
145 |
it does). |
it does). |
146 |
|
|
147 |
|
C<iframe_base> is relative path from C<dir> defiend in C<output> to root |
148 |
|
(which is inserted in all html). |
149 |
|
|
150 |
=cut |
=cut |
151 |
|
|
152 |
sub new { |
sub new { |
184 |
template_dir => './output_template/', |
template_dir => './output_template/', |
185 |
template_tree => 'tree.tt', |
template_tree => 'tree.tt', |
186 |
template_node => 'node.tt', |
template_node => 'node.tt', |
187 |
|
nodes => 'nodes', |
188 |
js => 'tree-ids.js', |
js => 'tree-ids.js', |
189 |
); |
); |
190 |
|
|
200 |
C<template_node> is (optional) name of template for node (if C<iframe> |
C<template_node> is (optional) name of template for node (if C<iframe> |
201 |
options is used within tree definition). |
options is used within tree definition). |
202 |
|
|
203 |
|
C<nodes> is directory in C<dir> in which html for iframes will be located. |
204 |
|
See also C<iframe_base> for relative dir out of this directory. |
205 |
|
|
206 |
C<js> is name of JavaScript file with shown and hidden ids. |
C<js> is name of JavaScript file with shown and hidden ids. |
207 |
|
|
208 |
=cut |
=cut |
340 |
$mfn_link = $self->{'detail_url'}->($mfn) if ($self->{'detail_url'}); |
$mfn_link = $self->{'detail_url'}->($mfn) if ($self->{'detail_url'}); |
341 |
|
|
342 |
if ($mfn_link) { |
if ($mfn_link) { |
343 |
$term =~ s, *#C# *, <img src="${base_path}img/crovoc.png" border="0">,; |
$term =~ s/ *#C# */ <img src="${base_path}img\/crovoc.png" border="0">/; |
344 |
$html .= " " x $level . |
$html .= " " x $level . |
345 |
qq{<li>${link_start}<span id="o$mfn">${term}</span>${link_end}}. |
qq{<li>${link_start}<span id="o$mfn">${term}</span>${link_end}}. |
346 |
qq{ <a href="${base_path}${mfn_link}" onClick="javascript:return popup(this);"><img src="${base_path}img/listic.png" border="0"></a></li>\n}; |
qq{ <a href="${base_path}${mfn_link}" onClick="javascript:return popup(this);"><img src="${base_path}img/listic.png" border="0"></a></li>\n}; |
349 |
$log->warn("file 'out/$mfn_link' doesn't exist, skipping"); |
$log->warn("file 'out/$mfn_link' doesn't exist, skipping"); |
350 |
} |
} |
351 |
|
|
352 |
|
# save mfn for iframe |
353 |
|
push @{$self->{'mfn_arr'}}, $mfn; |
354 |
|
|
355 |
unless ($have_children) { |
unless ($have_children) { |
356 |
next; |
next; |
357 |
} |
} |
373 |
push @{$self->{'show_ids'}}, "id$mfn"; |
push @{$self->{'show_ids'}}, "id$mfn"; |
374 |
} |
} |
375 |
|
|
376 |
|
|
377 |
if ($tree->[$level]->{'iframe'}) { |
if ($tree->[$level]->{'iframe'}) { |
378 |
|
|
379 |
|
# reset list of current mfns |
380 |
|
$self->{'mfn_arr'} = (); |
381 |
|
|
382 |
# unroll to separate file |
# unroll to separate file |
383 |
$self->{'node_html'}->{$mfn} = $self->unroll($next_level, $have_children, '../'); |
$self->{'node_html'}->{$mfn} = $self->unroll($next_level, $have_children, $self->{'iframe_base'}); |
384 |
|
$html .= " " x $level . |
385 |
|
qq{<iframe id="i$mfn" name="i$mfn" width="100%" height="10" frameborder="0" border="0"></iframe>}; |
386 |
|
@{$self->{'iframe_mfn'}->{$mfn}} = @{$self->{'mfn_arr'}}; |
387 |
|
$log->debug("in this iframe: ", sub { Dump($self->{'iframe_mfn'}->{$mfn}) }); |
388 |
|
|
389 |
} else { |
} else { |
390 |
# unroll at base HTML |
# unroll at base HTML |
424 |
open(JS, ">", $js_file) || $log->logdie("can't open '$js_file': $!"); |
open(JS, ">", $js_file) || $log->logdie("can't open '$js_file': $!"); |
425 |
print JS "var show = ['",join("','",@{$self->{'show_ids'}}),"'];\n"; |
print JS "var show = ['",join("','",@{$self->{'show_ids'}}),"'];\n"; |
426 |
print JS "var hide = ['",join("','",@{$self->{'hide_ids'}}),"'];\n"; |
print JS "var hide = ['",join("','",@{$self->{'hide_ids'}}),"'];\n"; |
427 |
|
|
428 |
|
print JS "var mfn_iframe = [\n"; |
429 |
|
foreach my $if (keys %{$self->{'iframe_mfn'}}) { |
430 |
|
print JS " ",join(",",map { "[$_:$if]" } @{$self->{'iframe_mfn'}->{$if}}),",\n"; |
431 |
|
} |
432 |
|
print JS " null\n]\n"; |
433 |
|
|
434 |
close(JS); |
close(JS); |
435 |
|
|
436 |
$log->debug("stored ",scalar @{$self->{'show_ids'}}," shown and ",scalar @{$self->{'hide_ids'}}," hidden elements"); |
$log->debug("stored ",scalar @{$self->{'show_ids'}}," shown and ",scalar @{$self->{'hide_ids'}}," hidden elements"); |