--- trunk2/lib/WebPAC/Tree.pm 2004/10/19 17:43:52 530 +++ trunk2/lib/WebPAC/Tree.pm 2004/11/01 22:52:44 580 @@ -6,6 +6,7 @@ use Carp; use Log::Log4perl qw(get_logger :levels); use YAML; +use Template; =head1 NAME @@ -14,7 +15,7 @@ =head1 DESCRIPTION This module will create tree from lookup data. It requires quite complicated -data structure, but once you get hang of that, it's peace of case :-) +data structure, but once you get hang of that, it's peace of cake :-) Data structure for tree definition is non-recursive, and defines each level of tree individually (so you can limit depth of tree) like this: @@ -33,6 +34,7 @@ lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, have_children => sub { return $l->{$_[1]} }, + iframe => 1, },{ # level 1 code_arr => sub { @{$_[0]} }, @@ -45,6 +47,7 @@ lookup_term => sub { shift @{$l->{"d:".$_[0]}} }, lookup_mfn => sub { shift @{$l->{"900_mfn:".$_[0]}} }, have_children => sub { 0 }, + style => 'display: none', )}; You can, however, create recursion with C discussed @@ -105,6 +108,15 @@ It's safe to return undef just for next level data (C<$next_lvl> in example above) to stop recursion. +=item iframe + +This optional option will create all children nodes in separate file, and iframe in tree html, +so that generated tee html will have resonable size with large number of nodes. + +=item style + +Optional option to specify style of this node. + =back =head1 METHODS @@ -116,6 +128,12 @@ my $tree = new WebPAC::Tree( tree => \@tree, log => 'log4perl.conf', + detail_url => sub { + my $mfn = shift; + my $path = "thes/${mfn}.html"; + return $path if (-e "./out/$path"); + }, + nodes_dir => 'nodes', ); C is tree array with levels of tree described above. @@ -123,6 +141,12 @@ C is optional parametar which specify filename of L config file. Default is C. +C code ref to check if detail html exists (and return URL if +it does). + +C is relative path from output directory where tree nodes for +iframes will be created. + =cut sub new { @@ -140,6 +164,15 @@ $self->{'show_ids'} = []; $self->{'hide_ids'} = []; + # figure out relative URL to other content from nodes_dir + my $iframe_base = $self->{'nodes_dir'}; + if ($iframe_base) { + $iframe_base = s#[^/]*##g; + $iframe_base = '../' x ( length($iframe_base) ); + $self->{'iframe_base'} = $iframe_base; + $log->debug("nodes dir is '",$self->{'nodes_dir'},"' so iframe_base is '",$self->{'iframe_base'},"'"); + } + $self->{'tree_html'} = $self->unroll(0,()); if (! $self->{'tree_html'}) { @@ -157,7 +190,9 @@ $tree->output( dir => './out', html => 'browse.html', - template => './output_template/tree.tt', + template_dir => './output_template/', + template_tree => 'tree.tt', + template_node => 'node.tt', js => 'tree-ids.js', ); @@ -166,8 +201,12 @@ C is name of output html file. -C