--- trunk2/lib/WebPAC/Tree.pm 2004/09/20 19:13:27 455 +++ trunk2/lib/WebPAC/Tree.pm 2004/11/01 22:52:44 580 @@ -5,6 +5,8 @@ use Carp; use Log::Log4perl qw(get_logger :levels); +use YAML; +use Template; =head1 NAME @@ -13,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: @@ -32,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]} }, @@ -44,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 @@ -75,7 +79,7 @@ Lookup value which will be called C<$v900> from now on. - my $v900 = $t->{'lookup_v900'}->($code,$start_code); + my $v900 = $t->{'lookup_v900'}->($code); =item lookup_term @@ -93,17 +97,26 @@ Returns children for next iteration of tree generation or undef. - my $next_lvl = $t->{'have_children'}->($code,$v900,$start_code); + my $next_lvl = $t->{'have_children'}->($code,$v900); =item have_children_at_level Returns children for next iteration and next level. - my ($level,$next_lvl) = $t->{'have_children_at_level'}->($code,$v900,$start_code); + my ($level,$next_lvl) = $t->{'have_children_at_level'}->($code,$v900); 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 @@ -113,29 +126,27 @@ Create new tree object my $tree = new WebPAC::Tree( - dir => './out', - html => 'browse.html', - template => './output_template/tree.tt', - js => 'tree-ids.js', 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 output directory in which html files and JavaScript files will be -created (think of it as C). - -C is name of output html file. - -C