Data-TreeDumper-Renderer-DHTML-0.09/0000755000076400001440000000000011123014404016000 5ustar nadimusersData-TreeDumper-Renderer-DHTML-0.09/Todo0000755000076400001440000000170307053631520016647 0ustar nadimusersTodo for Data/TreeDumper/Renderer/DHTML ======================================= Add the possibility to expand collaps and link (explorer style) change module name to DHTML::Simple Add DHTML::Arrow module for the example with red/green arrow add module that displays +/- images located in the current directory (try with inline base64 encoded images too) #Integrate latest staffan's modifications (the one verified with W3C validator) #Add search option can't do on closed nodes! #Add links between nodes open node when clicking on a link to it (like for search) #Have a single Expand/collapse button #Expand collapse buttons should have a unique id per dumped data! Add pathes opening and closing in the renderers interface #start expanded/collapsed option flash target glyph, link, address, size, perl_address should have different classes #Javascripts should be specific for a the tree to allow us to dump multiple trees in the same document Data-TreeDumper-Renderer-DHTML-0.09/README0000755000076400001440000000135211116742111016671 0ustar nadimusersData/TreeDumper/Renderer/DHTML ============================== Data::TreeDumper::Renderer::DHTML Rendering plug-in for Data::TreeDumper See Changes for information about this release: INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Data::TreeDumper COPYRIGHT AND LICENCE Copyright (c) 2003-2005 Nadim Ibn Hamouda el Khemir and Staffan Maalén. All rights reserved. This program is free software; you can redis- tribute it and/or modify it under the same terms as Perl itself. If you find any value in this module, mail me! All hints, tips, flammes and wishes are welcome at . Data-TreeDumper-Renderer-DHTML-0.09/Changes0000755000076400001440000000313011116742147017311 0ustar nadimusersRevision history for Perl extension Data::TreeDumper::Renderer::DHTML. 0.08 Sunday Dec 7 13:30:00 2008 FIXED: properly close ul+li after last element to allow proper display of consecutive data dump 0.07 Saturday Oct 22 20:00:00 2005 FIXED: RT 15191, no address displayed when node is not terminal CHANGED: Refactored node rendering code 0.06 Mon Aug 22 22:00:00 2005 FIXED: possibility to have multiple dumps in a single page and still have the expand collapse buttons working ADDED: example for multiple dump ADDED: a working, though simple, search functionality CHANGED: the documentation accordingly 0.05 Mon Oct 11 20:00:00 2004 FIXED: Javascript element was not taken into acount (I have to learn to test better!) ADDED: output example (dhtml_test.html) FIXED: Error in validaty text 0.04 Thu Sep 30 20:00:00 2004 ADDED: Expand and collapse buttons ADDED: TD link is now a real html link FIXED: HTML source indentation FIXED: W3C validation PROTOTYPE: very simple search ADDED: example 0.03 Mon July 1 21:30:00 2004 FIXED: replaced
 with 
	
0.02  Mon Jun 28 22:30:00 2004
	FIXED: unique IDs
	FIXED: separate dump from style
	FIXED: tag to lower case
	FIXED: use of unique class
	CHANGED: glyphs are output byt the renderer instead for relying on browser
	ADDED: {RENDERER}{NO_GLYPHS}
	ADDED: {RENDERER}{STYLE}
	ADDED: {RENDERER}{NO_STYLE}
	ADDED: {RENDERER}{CLASS}
	CHANGED: use 
 instead for  
	ADDED: Attempt to support older browsers
	
0.01  Sat Jun 26 23:29:05 2004
	- original version; created by h2xs 1.21 with options
		-X -n Data::TreeDumper::Renderer::DHTML

Data-TreeDumper-Renderer-DHTML-0.09/dhtml_test.html0000644000076400001440000007010011123014104021030 0ustar  nadimusers

     



Data







Data-TreeDumper-Renderer-DHTML-0.09/test.pl0000755000076400001440000000100107053631520017322 0ustar nadimusers# Before `make install' is performed this script should be runnable with # `make test'. After `make install' it should work as `perl test.pl' ######################### # change 'tests => 1' to 'tests => last_test_to_print'; use Test; BEGIN { plan tests => 1 }; use Data::TreeDumper::Renderer::DHTML; ok(1); # If we made it this far, we're ok. ######################### # Insert your test code below, the Test module is use()ed here so read # its man page ( perldoc Test ) for help writing this test script. Data-TreeDumper-Renderer-DHTML-0.09/dhtml_test.pl0000755000076400001440000000436611123013014020514 0ustar nadimusers use strict ; use Data::TreeDumper ; #------------------------------------------------------------------------------- # the renderer can return a default style. This is needed as styles must be at the top of the document my $style ; my $body = DumpTree ( GetData(), 'Data' , DISPLAY_ADDRESS => 0 , DISPLAY_ROOT_ADDRESS => 1 #~ , DISPLAY_PERL_ADDRESS => 1 #~ , DISPLAY_PERL_SIZE => 1 , RENDERER => { NAME => 'DHTML' , STYLE => \$style , BUTTON => { COLLAPSE_EXPAND => 1 , SEARCH => 1 } } ) ; my $body2 = '' ; my $style2 = '' ; my $body2 = DumpTree ( GetData(), 'Data2' , DISPLAY_ROOT_ADDRESS => 1 #~ , DISPLAY_PERL_ADDRESS => 1 #~ , DISPLAY_PERL_SIZE => 1 , RENDERER => { NAME => 'DHTML' , STYLE => \$style2 , COLLAPSED => 1 , CLASS => 'collapse_test' , BUTTON => { COLLAPSE_EXPAND => 1 , SEARCH => 1 } } ) ; print < Data $style $style2 $body $body2 EOT #------------------------------------------------------------------------------- sub GetData { my $s = { 'REGEX' => q#(<|>|&|\'|\"  )#, 'STDIN' => \*STDIN, 'RS' => \4, 'A' => { 'a' => {}, 'code1' => sub { "DUMMY" }, 'b' => { 'a' => 0, 'b' => 1, 'c' => { 'a' => 1, 'b' => 1, 'c' => 1, } }, 'b2' => { 'a' => 1, 'b' => 1, 'c' => 1, } }, 'C' => { 'b' => { 'a' => { 'c' => 42, 'a' => 3, 'b' => sub { "DUMMY" }, 'empty' => undef } } }, 'ARRAY' => [ 'elment_1', 'element_2', 'element_3', [1, 2], {a => 1, b => 2} ] }; ${$s->{'A'}{'code3'}} = $s->{'A'}{'code1'}; $s->{'A'}{'code2'} = $s->{'A'}{'code1'}; $s->{'CopyOfARRAY'} = $s->{'ARRAY'}; $s->{'C1'} = \($s->{'C2'}); $s->{'C2'} = \($s->{'C1'}); $s->{za} = $s->{A} ; my $object = bless {A =>[], B => 123}, 'SuperObject' ; $s->{object} = $object ; return($s) ; } Data-TreeDumper-Renderer-DHTML-0.09/Makefile.PL0000755000076400001440000000077311123013240017761 0ustar nadimusersuse ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( 'NAME' => 'Data::TreeDumper::Renderer::DHTML', 'VERSION_FROM' => 'DHTML.pm', # finds $VERSION 'PREREQ_PM' => {}, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'DHTML.pm', # retrieve abstract from module AUTHOR => 'Nadim ibn Hamouda el Khemir') : ()), ); Data-TreeDumper-Renderer-DHTML-0.09/META.yml0000644000076400001440000000065111123014404017253 0ustar nadimusers--- #YAML:1.0 name: Data-TreeDumper-Renderer-DHTML version: 0.09 abstract: DHTML renderer for B license: ~ author: - Nadim ibn Hamouda el Khemir generated_by: ExtUtils::MakeMaker version 6.44 distribution_type: module requires: meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.3.html version: 1.3 Data-TreeDumper-Renderer-DHTML-0.09/DHTML.pm0000644000076400001440000003536511123014036017223 0ustar nadimuserspackage Data::TreeDumper::Renderer::DHTML; use 5.006; use strict; use warnings; require Exporter; use AutoLoader qw(AUTOLOAD); our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw() ] ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); our @EXPORT = qw(); our $VERSION = '0.09'; use constant DHTML_CLASS => 'data_treedumper_dhtml' ; my $uuuid = int(rand(100_000)) ; my %ascii_to_html = ( '<' => '<', '>' => '>', '&' => '&', "'" => ''', '"' => '"', ' ' => ' ', ) ; #------------------------------------------------------------------------------------------- sub GetRenderer { my $expand_collapse_button_id = "expand_collapse_button_${uuuid}" ; $uuuid++ ; my $search_button_id = "search_button_${uuuid}" ; $uuuid++ ; return ( { BEGIN => \&RenderDhtmlBegin, NODE => \&RenderDhtmlNode, END => \&RenderDhtmlEnd, # data needed by the renderer EXPAND_COLLAPSE_BUTTON_ID => $expand_collapse_button_id, SEARCH_BUTTON_ID => $search_button_id, PREVIOUS_LEVEL => -1, PREVIOUS_ADDRESS => "c_${uuuid}_ROOT", TABULATION => 0, @_, } ) ; } #------------------------------------------------------------------------------------------- sub RenderDhtmlBegin { my ($title, $td_address, $element, $perl_size, $perl_address, $setup) = @_ ; my $class = $setup->{RENDERER}{CLASS} || DHTML_CLASS ; my $button_container = '' ; if(exists $setup->{RENDERER}{BUTTON}) { $button_container .= "
\n" ; if($setup->{RENDERER}{BUTTON}{COLLAPSE_EXPAND}) { if($setup->{RENDERER}{COLLAPSED}) { $button_container .= " \n" ; } else { $button_container .= " \n" ; } } if($setup->{RENDERER}{BUTTON}{SEARCH}) { $button_container .= " \n" ; } $button_container .= "
\n\n" ; } my $collapsed = '' ; if($setup->{RENDERER}{COLLAPSED}) { $collapsed = "ul.$class ul {display: none}" ; } my $style = < .$class li {list-style-type:none ; margin:0 ; padding:0 ; line-height: 1em ;} .$class ul {margin:0 ; padding:0 ;} ul.$class {font-family:monospace ; white-space: nowrap ;} $collapsed EOS if(defined $setup->{RENDERER}{STYLE}) { if('SCALAR' eq ref $setup->{RENDERER}{STYLE}) { ${$setup->{RENDERER}{STYLE}} = $style ; $style = '' ; } else { $style = $setup->{RENDERER}{STYLE} ; } } $style = '' if(exists $setup->{RENDERER}{NO_STYLE}) ; $perl_size = "<$perl_size>" if $perl_size ne '' ; my $address = $setup->{DISPLAY_ADDRESS} ? "[$td_address] " : ''; my $header = <
  • $title $address $perl_size $perl_address EOH $setup->{RENDERER}{TABULATION} = 2 ; push @{$setup->{RENDERER}{NODES}{A_IDS}}, "\"a_${uuuid}_ROOT\""; push @{$setup->{RENDERER}{NODES}{COLLAPSABLE_IDS}}, "\"c_${uuuid}_ROOT\"" ; $setup->{RENDERER}{PREVIOUS_ADDRESS} = "c_${uuuid}_ROOT" ; $uuuid++ ; return($style . $button_container . $header) ; } #------------------------------------------------------------------------------------------- sub RenderDhtmlNode { my ( $element, $level, $is_terminal, $previous_level_separator, $separator, $element_name, $element_value, $td_address, $address_link, $perl_size, $perl_address, $setup, ) = @_ ; # HTMLify args my $glyph = '' ; unless ($setup->{RENDERER}{NO_GLYPH}) { $glyph = $previous_level_separator. $separator ; $glyph =~ s/ / /g ; } $perl_size = "<$perl_size>" if $perl_size ne '' ; if($element_value ne '') { $element_value =~ s/(<|>|&|\'|\"|\ )/$ascii_to_html{$1}/eg ; $element_value = " = $element_value" ; } #setup my $tabulation = $setup->{RENDERER}{TABULATION} ; my $class = $setup->{RENDERER}{CLASS} || DHTML_CLASS ; my $node = '' ; # HTML list formating if($level > $setup->{RENDERER}{PREVIOUS_LEVEL}) { if($setup->{RENDERER}{COLLAPSED}) { $node = ' ' x $tabulation . "\n" ; $tabulation-- ; $closing_ul_li .= ' ' x $tabulation . "
  • \n" ; } unless(exists $setup->{RENDERER}{BUTTON}) { "$closing_ul_li \n\n" ; } else { my $a_ids = join "\n\t\t, ", @{$setup->{RENDERER}{NODES}{A_IDS}} ; my $collapsable_ids = join "\n\t\t\t\t, ", @{$setup->{RENDERER}{NODES}{COLLAPSABLE_IDS}} ; my $collapsed = 0 ; $collapsed++ if($setup->{RENDERER}{COLLAPSED}) ; my $class = $setup->{RENDERER}{CLASS} || DHTML_CLASS ; < EOS } } #------------------------------------------------------------------------------------------- 1 ; __END__ =head1 NAME Data::TreeDumper::Renderer::DHTML - DHTML renderer for B =head1 SYNOPSIS use Data::TreeDumper ; #------------------------------------------------------------------------------- my $style ; my $body = DumpTree ( GetData(), 'Data', DISPLAY_ROOT_ADDRESS => 1, DISPLAY_PERL_ADDRESS => 1, DISPLAY_PERL_SIZE => 1, RENDERER => { NAME => 'DHTML', STYLE => \$style, BUTTON => { COLLAPSE_EXPAND => 1, SEARCH => 1, }, }, ) ; print < Data $style $body

    Valid HTML 4.01!

    EOT =head1 DESCRIPTION Simple DHTML renderer for B. Thanks to Stevan Little author of Tree::Simple::View for giving me the idea and providing some code I could snatch. =head1 EXAMPLE Check B for a complete example of two structure dumps within the same HTML file. =head1 OPTIONS =head2 Style CSS style is dumped to $setup->{RENDERER}{STYLE} (a ref to a scalar) if it exists. This allows you to collect all the CSS then output it at the top of the HTML code. my $style ; my $body = DumpTree ( ... RENDERER => { NAME => 'DHTML', STYLE => \$style, }, ) ; {RENDERER}{NO_STYLE} removes style section generation. This is usefull when you defined your styles by hand. my $style ; my $body = DumpTree ( ... RENDERER => { NAME => 'DHTML', NO_STYLE => 1, }, ) ; =head2 Class The output will use class 'data_tree_dumper_dhtml' for
  • and
      . The class can be renamed with the help of {RENDERER}{CLASS}. This allows you to dump multiple data structures and display them with a diffrent styles. my $style ; my $body = DumpTree ( ... RENDERER => { NAME => 'DHTML', CLASS => 'my_class_name', }, ) ; =head2 Glyphs B outputs the tree lines as ASCII text by default. If {RENDERER}{NO_GLYPH} and RENDERER}{NO_STYLE} are defined, no lines are output and the indentation will be the default
    • style. If you would like to specify a specific style for your tree dump, defined you own CSS and set the appropriate class through {RENDERER}{CLASS}. =head2 Expand/Collapse Setting {RENDERER}{COLLAPSED} to a true value will display the tree collapsed. this is false by default. $setup->{RENDERER}{COLLAPSED}++ ; If {RENDERER}{BUTTON}{COLLAPSE_EXPAND} is set, the rendered will add a button to allow the user to collapse and expand the tree. $setup->{RENDERER}{BUTTON}{COLLAPSE_EXPAND} =head2 Search If {RENDERER}{BUTTON}{SEARCH} is set, the rendered will add a button to allow the user to search the tree. This is a primitive search and has no other value than for test. =head1 Bugs I'll hapilly hand this module over to someone who knows what he does :-) Check the TODO file. =head1 EXPORT None =head1 AUTHORS Khemir Nadim ibn Hamouda. Staffan Maahlén. Copyright (c) 2003 Nadim Ibn Hamouda el Khemir and Staffan Maahlén. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perlitself. If you find any value in this module, mail me! All hints, tips, flames and wishes are welcome at . =head1 SEE ALSO B. =cut Data-TreeDumper-Renderer-DHTML-0.09/MANIFEST0000755000076400001440000000024707053631520017152 0ustar nadimusersChanges DHTML.pm Makefile.PL MANIFEST README dhtml_test.pl dhtml_test.html test.pl Todo META.yml Module meta-data (added by MakeMaker)