NAME

DemoTextFile - Demo of CGI::Portable that displays the content of a static html or text file, which can be in multiple segments.

DEPENDENCIES

Perl Version

5.004

Standard Modules

I<none>

Nonstandard Modules

CGI::Portable 0.50
CGI::Portable::AppStatic 0.50

SYNOPSIS

Display An HTML File By Itself

#!/usr/bin/perl
use strict;
use warnings;

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 ? "\\" : "/" );

my %CONFIG = ( filename => 'intro.html' );

$globals->set_prefs( \%CONFIG );
$globals->call_component( 'DemoTextFile' );

require CGI::Portable::AdapterCGI;
my $io = CGI::Portable::AdapterCGI->new();
$io->send_user_output( $globals );

1;

Display A Plain Text File By Itself -- HTML Escaped

my %CONFIG = ( filename => 'mycode.txt', is_text => 1 );

Display A Text File In Multiple Segments With Headings

my %CONFIG = (
	title => 'Index of the World',
	author => 'Jules Verne',
	created => 'Version 1.0, first created 1993 June 24',
	updated => 'Version 3.1, last modified 2000 November 18',
	filename => 'jv_world.txt',
	segments => 24,
	is_text => 1,
);

You need to have a subdirectory named "jv_world" that contains the 24 files that correspond to the segments, named "jv_world_001.txt" through "...024.txt".

Display A Text File All On One Page With Headings

my %CONFIG = (
	title => 'Pizza Joints In New York',
	author => 'Oscar Wilder',
	created => 'Version 0.5, first created 1997 February 17',
	updated => 'Version 1.2, last modified 1998 March 8',
	filename => 'ow_pizza.txt',
	segments => 1,  # also the default
	is_text => 1,
);

You need to have a single file named "ow_pizza.txt", not in a subdirectory.

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.

filename # common part of filename for pieces
is_text  # true if file is not html, but text
title    # title of the document
author   # who made the document
created  # date and number of first version
updated  # date and number of newest version
segments # number of pieces doc is in

AUTHOR

Copyright (c) 1999-2004, 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 and credits remain attached to the file. If you modify this module and redistribute a changed version then please attach a note listing the modifications. This module is available "as-is" and the author can not be held accountable for any problems resulting from its use.

I am always interested in knowing how my work helps others, so if you put this module to use in any of your own products or services then I would appreciate (but not require) it if you send me the website url for said product or service, so I know who you are. Also, if you make non-proprietary changes to the module because it doesn't work the way you need, and you are willing to make these freely available, then 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::Portable::AppStatic, CGI::Portable::AdapterCGI.