# Blosxom 3 Plugin: DumpContent # Version: 2005-01-14 # Author: Bernie Simon (http://carelesshand.net) use strict; package Blosxom::Plugin::DumpContent; #---------------------------------------------------------------------- # Configuration variables # The portions of $self to print @Blosxom::Plugin::DumpContent::keys = qw (state settings request response); #---------------------------------------------------------------------- # To be called from handlers.flow sub run { my $self = shift; print "Content-type: text/html\n\n"; print "Dump Content\n"; print "\n"; print "

Dump Content

\n"; foreach my $key (@Blosxom::Plugin::DumpContent::keys) { my $value = render ($self->{$key}); $key = uc ($key); print "

$key

\n$value\n"; } print "\n\n"; $self->{state}->{stop}->{handlers}->{flow} = 1; } #---------------------------------------------------------------------- # Render a complex data structure as html sub render { my ($data) = @_; my $text; my $ref = ref ($data); if (! $ref) { $text = $data; } else { if ($ref eq 'SCALAR') { $text = $$data; } elsif ($ref eq 'ARRAY') { $text = "\n"; } elsif ($ref eq 'HASH') { $text = "\n"; } else { $text = $data; } } return $text; } 1; __END__ =head1 NAME Blosxom 3.0 Plugin: DumpContent =head1 VERSION 2005-01-14 =head1 AUTHOR Bernie Simon (http://carelesshand.net) =head1 DESCRIPTION This plugin helps you debug problems with your Blosxom installation by dumping the contents of portions of the self variable formatted as html. The dump output replaces the normal output of Blosxom. =head1 INSTALLATION Place this file in the plugins directory. Then add the line Blosxom::Plugin::DumpContent::run to the data/.settings/handlers.flow file somewhere before Blosxom::output_response. Where you place it depend on what you're debugging, I guess. The portion of the data structure displayed depends upon the values listed in @keys, which is in the configuration section at the top of the script. =head1 BUGS Because the version of Blosxom 3 that is currently being distributed ignores the handlers.flow file, you need to first install a patch to Blosxom 3 to fix this problem, such as the one distributed on this site. The rendering code doesn't check for loops in its input and if you hand it a data structure containing one, it will go into a endless loop and never display anything. Watch out in particular for the cgi scturcture.