NAME
CGI::WPM::MultiPage - Demo of CGI::Portable that resolves navigation for one level in the web site page hierarchy from a parent node to its children, encapsulates and returns its childrens' returned web page components, and can make a navigation bar to child pages.
DEPENDENCIES
Perl Version
5.004
Standard Modules
I<none>
Nonstandard Modules
CGI::Portable 0.41
CGI::WPM::Base 0.41
SYNOPSIS
A multiple page website with static html, mail, gb, redir, usage tracking
#!/usr/bin/perl
use strict;
require CGI::Portable;
my $globals = CGI::Portable->new();
use Cwd;
$globals->file_path_root( cwd() ); # let us default to current working dir
$globals->file_path_delimiter( $^O=~/Mac/i ? ":" : $^O=~/Win/i ? "\\" : "/" );
require CGI::WPM::SimpleUserIO;
my $io = CGI::WPM::SimpleUserIO->new( 1 );
$io->give_user_input_to_cgi_portable( $globals );
if( $globals->user_query_param( 'debugging' ) eq 'on' ) {
$globals->is_debug( 1 );
$globals->url_query_param( 'debugging', 'on' );
}
$globals->default_application_title( 'Demo Web Site' );
$globals->default_maintainer_name( 'Tony Simons' );
$globals->default_maintainer_email_address( 'tony@aardvark.net' );
$globals->default_maintainer_email_screen_url_path( '/mailme' );
my $content = $globals->make_new_context();
$content->current_user_path_level( 1 );
$content->navigate_file_path( 'content' );
$content->set_prefs( 'content_prefs.pl' );
$content->call_component( 'CGI::WPM::MultiPage' );
$globals->take_context_output( $content );
my $usage = $globals->make_new_context();
$usage->http_redirect_url( $globals->http_redirect_url() );
$usage->navigate_file_path( $globals->is_debug() ? 'usage_debug' : 'usage' );
$usage->set_prefs( '../usage_prefs.pl' );
$usage->call_component( 'CGI::WPM::Usage' );
if( $globals->is_debug() ) {
$globals->append_page_body( <<__endquote );
<P>Debugging is currently turned on.</P>
__endquote
}
$globals->search_and_replace_page_body( {
__mailme_url__ => "__url_path__=/mailme",
__external_id__ => "__url_path__=/external&url",
} );
$globals->search_and_replace_url_path_tokens( '__url_path__' );
$io->send_user_output_from_cgi_portable( $globals );
1;
Content of settings file "content_prefs.pl"
my $rh_preferences = {
page_header => <<__endquote,
__endquote
page_footer => <<__endquote,
<P><EM>Demo Web Site was created and is maintained for personal use by
<A HREF="__mailme_url__">Tony Simons</A>. All content and source code was
created by me, unless otherwise stated. Content that I did not create is
used with permission from the creators, who are appropriately credited where
it is used and in the Works Cited section of this site.</EM></P>
__endquote
page_css_code => [
'BODY {background-color: white; background-image: none}'
],
page_replace => {
__graphics_directories__ => 'http://www.aardvark.net/graphics_directories',
__graphics_webring__ => 'http://www.aardvark.net/graphics_webring',
},
vrp_handlers => {
external => {
wpm_module => 'CGI::WPM::Redirect',
wpm_prefs => {},
},
frontdoor => {
wpm_module => 'CGI::WPM::Static',
wpm_prefs => { filename => 'frontdoor.html' },
},
intro => {
wpm_module => 'CGI::WPM::Static',
wpm_prefs => { filename => 'intro.html' },
},
whatsnew => {
wpm_module => 'CGI::WPM::Static',
wpm_prefs => { filename => 'whatsnew.html' },
},
timelines => {
wpm_module => 'CGI::WPM::Static',
wpm_prefs => { filename => 'timelines.html' },
},
indexes => {
wpm_module => 'CGI::WPM::Static',
wpm_prefs => { filename => 'indexes.html' },
},
cited => {
wpm_module => 'CGI::WPM::MultiPage',
wpm_subdir => 'cited',
wpm_prefs => 'cited_prefs.pl',
},
mailme => {
wpm_module => 'CGI::WPM::MailForm',
wpm_prefs => {},
},
guestbook => {
wpm_module => 'CGI::WPM::GuestBook',
wpm_prefs => {
custom_fd => 1,
field_defn => 'guestbook_questions.txt',
fd_in_seqf => 1,
fn_messages => 'guestbook_messages.txt',
},
},
links => {
wpm_module => 'CGI::WPM::Static',
wpm_prefs => { filename => 'links.html' },
},
webrings => {
wpm_module => 'CGI::WPM::Static',
wpm_prefs => { filename => 'webrings.html' },
},
},
def_handler => 'frontdoor',
menu_items => [
{
menu_name => 'Front Door',
menu_path => '',
is_active => 1,
}, {
menu_name => 'Welcome to DemoWeb',
menu_path => 'intro',
is_active => 1,
}, {
menu_name => "What's New",
menu_path => 'whatsnew',
is_active => 1,
}, 1, {
menu_name => 'Story Timelines',
menu_path => 'timelines',
is_active => 1,
}, {
menu_name => 'Issue Indexes',
menu_path => 'indexes',
is_active => 1,
}, {
menu_name => 'Works Cited',
menu_path => 'cited',
is_active => 1,
}, {
menu_name => 'Preview Database',
menu_path => 'dbprev',
is_active => 0,
}, 1, {
menu_name => 'Send Me E-mail',
menu_path => 'mailme',
is_active => 1,
}, {
menu_name => 'Guest Book',
menu_path => 'guestbook',
is_active => 1,
}, 1, {
menu_name => 'External Links',
menu_path => 'links',
is_active => 1,
}, {
menu_name => 'Webrings',
menu_path => 'webrings',
is_active => 1,
},
],
menu_cols => 4,
# menu_colwid => 100,
menu_showdiv => 0,
# menu_bgcolor => '#ddeeff',
page_showdiv => 1,
};
Content of settings file "usage_prefs.pl"
Please see the POD for CGI::WPM::Usage for this file; that Synopsis POD is being made in conjunction with the POD for CGI::WPM::MultiPage.
DESCRIPTION
This Perl 5 object class is part of a demonstration of CGI::Portable in use. It is one of a set of "application components" that takes its settings and user input through CGI::Portable and uses that class to send its user output. This demo module set can be used together to implement a web site complete with static html pages, e-mail forms, guest books, segmented text document display, usage tracking, and url-forwarding. Of course, true to the intent of CGI::Portable, each of the modules in this demo set can be used independantly of the others.
SYNTAX
This class does not export any functions or methods, so you need to call them using object notation. This means using Class->function() for functions and $object->method() for methods. If you are inheriting this class for your own modules, then that often means something like $self->method().
PUBLIC FUNCTIONS AND METHODS
main( GLOBALS )
You invoke this method to run the application component that is encapsulated by this class. The required argument GLOBALS is an CGI::Portable object that you have previously configured to hold the instance settings and user input for this class. When this method returns then the encapsulated application will have finished and you can get its user output from the CGI::Portable object.
PREFERENCES HANDLED BY THIS MODULE
This POD is coming when I get the time to write it.
vrp_handlers # match wpm handler to a vrp
def_handler # if vrp undef, which handler?
menu_items # items in site menu, vrp for each
menu_cols # menu divided into n cols
menu_colwid # width of each col, in pixels
menu_showdiv # show dividers btwn menu groups?
menu_bgcolor # background for menu
menu_showdiv # show dividers btwn menu groups?
page_showdiv # do we use HRs to sep menu?
PROPERTIES OF ELEMENTS IN vrp_handlers HASH
wpm_module # wpm module making content
wpm_subdir # subdir holding wpm support files
wpm_prefs # prefs hash/fn we give to wpm mod
PROPERTIES OF ELEMENTS IN menu_items ARRAY
menu_name # visible name appearing in site menu
menu_path # vrp used in url for menu item
is_active # is menu item enabled or not?
AUTHOR
Copyright (c) 1999-2001, Darren R. Duncan. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. However, I do request that this copyright information remain attached to the file. If you modify this module and redistribute a changed version then please attach a note listing the modifications.
I am always interested in knowing how my work helps others, so if you put this module to use in any of your own code then please send me the URL. Also, if you make modifications to the module because it doesn't work the way you need, please send me a copy so that I can roll desirable changes into the main release.
Address comments, suggestions, and bug reports to perl@DarrenDuncan.net.
SEE ALSO
perl(1), CGI::Portable, CGI::WPM::Base, CGI::WPM::SimpleUserIO.