CGI::Builder::GetPageName - GetPageName from path info.


CGI-Builder-GetPageName documentation Contained in the CGI-Builder-GetPageName distribution.

Index


Code Index:

NAME

Top

CGI::Builder::GetPageName - GetPageName from path info.

DESCRIPTION

Top

This extention allow you to set page name from $ENV{PATH_INFO} instead of p(Qerystring). You can check SYNOPSYS out and you will know what this mean. :-)

This class is extention of CGI::Builder, I love CGI::Builder.

SYNOPSYS

Top

start.cgi

 #!/usr/bin/perl -w

 use strict;
 use Your::CGI::Builder;

 my $app = Your::CGI::Builder->new();
 $app->process();

 # you can set page name this way if you want but in this way
 # you do not need to use this extention :-p
 #$app->process( 'page_name' );

 __END__

Your CGI::Builder Package.

 package Your::CGI::Builder;

 use CGI::Builder qw/
    CGI::Builder::GetPageName
 /;

 sub PH_foo_bar {
    my $s = shift;
    $s->page_content( 'my URL is http://localhost/script.cgi/foo/bar/?foo=whatever !!!!' );
 }

 sub PH_hoge {
    my $s = shift;
    $s->page_content = 'my URL is http://localhost/script.cgi/hoge/ !!!' ;
 }

MORE FUN?

Top

Use ScriptAlias !!! This allow you to hide .cgi extension. Very fun.



 ScriptAlias /secure /var/www/httpdoc/secure.cgi

 # You have this start script.
 http://localhost/secure.cgi 

 # You set script alias so , you can also access with this URL.
 http://localhost/secure

 # Then now...
 sub PH_foo_bar {
    my $s = shift;
    $s->page_content = 'my URL is http://localhost/secure/foo/bar/?foo=whatever !!!' ;
 }

OVERRIDE MODULES

Top

get_page_name

I override this method but I guess you do not need to care.

SEE ALSO

Top

CGI::Builder

CREDITS

Top

Thanks to Domizio Demichelis for everything!

AUTHOR

Top

Tomohiro Teranishi <tomohiro.teranishi+cpan@gmail.com>

COPYRIGHT

Top


CGI-Builder-GetPageName documentation Contained in the CGI-Builder-GetPageName distribution.

package CGI::Builder::GetPageName;

use strict;
use vars qw/$VERSION/;

$VERSION = '0.03';

$Carp::Internal{+__PACKAGE__}++;
$Carp::Internal{__PACKAGE__.'::_'}++;

# Override
sub get_page_name {
    my $s = shift;
    my $p 
        =  $s->cgi->param($s->cgi_page_param)
        || do {
                my $path         = $ENV{PATH_INFO} || '/';
                my @path_entries = split( '/' , $path );
                join( '_' , @path_entries[1..$#path_entries] );
           }
         ;

    $s->page_name( $p ) if defined( $p ) && length( $p );

}


1;