NAME

CGI::QuickApp - Prototyping reusable web-apps very quickly

SUPER QUICK USAGE

# In "SuperQuickWebApp.pm" ...
package SuperQuickWebApp;
use CGI::QuickApp [qw(mode1 mode2 mode3)];
__END__


# Create the files for web app
% perl -MCGI::QuickApp::Create SuperQuickWebApp.pm

# It creates the following files:

  mylib/SuperQuickWebApp/mode1.pm
  mylib/SuperQuickWebApp/mode2.pm
  mylib/SuperQuickWebApp/mode3.pm
  template/mode1
  template/mode2
  template/mode3
  webapp.cgi

DESCRIPTION

CGI::QuickApp may help you build web-based applications more quickly and more concisely. It is built upon CGI::Application, so it retains the strong points of run modes, but the interface is much cleaner.

AUTOMATIC FILE CREATION

CGI::QuickApp::Create is designed for creating related files automatically for you. Once you have the web app module written up, CGI::QuickApp::Create may create related files for you.

% perl -MCGI::QuickApp::Create YourWebApp.pm
   --script-name you_cgi_script         # default => webapp.cgi
   --template-dir your_template_dir     # default => template/
   --include-dir your_path_for_modules  # default => qw(mylib .)
   --force-create                       # use when webapp.cgi exists

The options can be omitted if you just like default settings.

A FULL EXAMPLE

The following is the full example showing available parameters for configuring your WebApp.

    package WebApp;

    use CGI::QuickApp

    # Specify run modes
    run_modes => [qw(mode1 mode2 mode3 mode4 err)],

    # Specify handlers that don't agree with names of run modes
    run_mode_handlers => {
	# if 'use' or 'sub' is omitted,
	# 'use' is assumed for creating files.
        mode3 => 'use WebApp::Mode3',
	mode4 => 'sub handler_for_mode4',

        # if the handler is a subroutine, the subroutine
        # will be write back to the original webapp module.
        # This doesn't seem the best solution. I'll see to that.
    },

    # Specify the parameter name of run modes
    # The default is 'm'
    mode_param => 'm',

    # Specify start mode
    # If the start mode is not given, first element of run modes
    # will be the start mode
    start_mode => 'mode1',

    # Specify the mode for handling error
    error_mode => 'err',

    # Specify template name for run modes.
    # By default, the template name is the same as the mode's name
    templates => {
	mode2 => 'template_name_for_mode2',
	err => 'template_name_for_error_mode',
    },

    # Specify the directory for template files
    # Default config is  { INCLUDE_PATH => 'template' }
    # It will be forwarded to the constructor of Template Toolkit
    template_conf => {
	INCLUDE_PATH => 'template',
    },


    # Specify the arguments for mode handlers
    # default argument is   ( scalar($self->query()->Vars) )
    handler_args => q+ scalar($self->query()->Vars) +,


    # Specify header information
    # default character set is 'utf8'
    # default content type is 'text/html'
    header_props => {
        -charset => 'utf8',
	-type => 'text/html',
    },

    # Set application-wide parameters
    params => {
    },
    ;


    # The same as cgiapp_init(), cgiapp_prerun(), cgiapp_postrun()
    # but prefix is stripped for brevity
    sub init {}
    sub prerun {}
    sub postrun {}
    sub teardown {}

NOTE

Currently, only Template Toolkit is supported. Apology to CGI::Application users! Support is coming soon.

THE AUTHOR

Yung-chung Lin (a.k.a. xern) <xern@cpan.org>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself