LibWeb:: - HTML display for libweb applications
use LibWeb::HTML::Default; my $rc_file = '/absolute/path/to/dot_lwrc'; my $html = new LibWeb::HTML::Default($rc_file); $html->fatal( -msg => 'You have not typed in the stock symbol.', -alertMsg => 'Try to view stock quotes without a symbol.', -helpMsg => $html->hit_back_and_edit() ) unless ($stock_symbol); my $display = $html->display( -content => [ $news, $stock_quotes, $weather ], -sheader=> [ $tabbed_navigation_bar ], -lpanel=> [ $banner_ad ], -rpanel=> [ $back_issues, $downloads ], -header=> undef, -footer=> undef ); print "Content-Type: text/html\n\n"; print $$display;
I pass the absolute path to my LibWeb's rc (config) file to
LibWeb::HTML::Default::new() so that LibWeb can do things according to my site's preferences. A sample rc file is included in the eg directory, if you could not find that, go to the following address to down load a standard distribution of LibWeb,
This synopsis also demonstrated how I have handled error by calling the
fatal() method. For the
display() call, I passed
-footer to demonstrate how to tell the display to use default header and footer.
Finally, I de-referenced
$display (by appending
$ in front of the variable) to print out the HTML page. Please see the synopsis of LibWeb::Themes::Default to see how I have prepared
$news, $weather, $stock_quotes, $back_issues and $tabbed_navigation_bar.
If I would like to customize the HTML display of LibWeb, I would have ISAed LibWeb::HTML::Default, say a class called
MyHTML and I just have to replace the following two lines,
use LibWeb::HTML::Default; my $html = new LibWeb::HTML::Default( $rc_file );
use MyHTML; my $html = new MyHTML( $rc_file );
A sample MyHTML.pm is included in the distribution for your hacking pleasure.
This class is a sub-class of LibWeb::HTML::Standard, LibWeb::HTML::Error and LibWeb::Themes::Default and therefore it handles both standard and error display (HTML) for a LibWeb application. To customize the behavior of
display_error() and built-in error/help messages, you can make a sub-class of LibWeb::HTML::Default (an example can be found in the eg directory. If you could not find it, download a standard distribution from the following address). In the sub-class you made, you can also add your own error messages. You may want to take a look at LibWeb::HTML::Error to see what error messages are built into LibWeb. To override the standard error messages, you re-define them in the sub-class you made.
The current version of LibWeb::HTML::Default is available at
Several LibWeb applications (LEAPs) have be written, released and are available at
All `error/help messages' mentioned can be found at LibWeb::HTML::Error and they can be customized by ISA (making a sub-class of) LibWeb::HTML::Default. Error/help messages are used when you call LibWeb::Core::fatal, see LibWeb::Core for details. Method's parameters in square brackets means optional.
my $html = new LibWeb::HTML::Default( $rc_file );
This implements the base class method: LibWeb::HTML::Standard::display().
-content=>, [ -sheader=>, -lpanel=>, -rpanel=>, -header=>, -footer=> ]
-footereach must be an ARRAY reference to elements which are scalars/SCALAR references/ARRAY references,
-sheaderstands for ``sub header'' and default is
Each of the following methods return an ARRAY reference to partial HTML. These are the defaults used by the