| 1 | package CGI::Builder::GetPageName; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use vars qw/$VERSION/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | $VERSION = '0.03'; | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 3 | $Carp::Internal{+__PACKAGE__}++; | |||||||||||||||||||||||||||
| 9 | 3 | $Carp::Internal{__PACKAGE__.'::_'}++; | |||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | # Override | ||||||||||||||||||||||||||||
| 12 | 3 | ▶ | sub get_page_name { | ||||||||||||||||||||||||||
|
Subroutine
get_page_name: called CC=5 SCAR=18.4
Pod
documented
| |||||||||||||||||||||||||||||
| 13 | 3 | my $s = shift; | |||||||||||||||||||||||||||
| 14 | my $p | ||||||||||||||||||||||||||||
| 15 | = $s->cgi->param($s->cgi_page_param) | ||||||||||||||||||||||||||||
| 16 | 3 | ▶ | || do { | ||||||||||||||||||||||||||
|
Condition33%1/3
$s->cgi->param($s->cgi_page_param) || do {
my $path = $ENV{'PATH_INFO'} || '/';
my @path_entries = split(m[/], $path, 0);
join '_', @path_entries[1 .. $#path_entries]
}
MC/DC0%0/2
$s->cgi->param($s->cgi_page_param) || do {
my $path = $ENV{'PATH_INFO'} || '/';
my @path_entries = split(m[/], $path, 0);
join '_', @path_entries[1 .. $#path_entries]
}
$s->cgi->param($s->cgi_page_param)
do {
my $path = $ENV{'PATH_INFO'} || '/';
my @path_entries = split(m[/], $path, 0);
join '_', @path_entries[1 .. $#path_entries]
}
Truth table33%1/3
A || B
A= $s->cgi->param($s->cgi_page_param)B= do {
my $path = $ENV{'PATH_INFO'} || '/';
my @path_entries = split(m[/], $path, 0);
join '_', @path_entries[1 .. $#path_entries]
}
| |||||||||||||||||||||||||||||
| 17 | 3 | ▶ | my $path = $ENV{PATH_INFO} || '/'; | ||||||||||||||||||||||||||
|
Condition50%1/2
$ENV{'PATH_INFO'} || '/'
MC/DC0%0/1
$ENV{'PATH_INFO'} || '/'
$ENV{'PATH_INFO'}
Truth table50%1/2
A
A= $ENV{'PATH_INFO'}
| |||||||||||||||||||||||||||||
| 18 | 3 | my @path_entries = split( '/' , $path ); | |||||||||||||||||||||||||||
| 19 | 3 | join( '_' , @path_entries[1..$#path_entries] ); | |||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | ; | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | $s->page_name( $p ) if defined( $p ) && length( $p ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $p and length $p
MC/DC0%0/2
defined $p and length $p
defined $p
length $p
Truth table33%1/3
A and B
A= defined $pB= length $p
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | } | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 3 | 1; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | =head1 NAME | ||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | CGI::Builder::GetPageName - GetPageName from path info. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | This extention allow you to set page name from $ENV{PATH_INFO} instead of | ||||||||||||||||||||||||||||
| 37 | p(Qerystring). You can check SYNOPSYS out and you will know what this mean. :-) | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | This class is extention of CGI::Builder, I love CGI::Builder. | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | =head1 SYNOPSYS | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | start.cgi | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | #!/usr/bin/perl -w | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | use strict; | ||||||||||||||||||||||||||||
| 48 | use Your::CGI::Builder; | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | my $app = Your::CGI::Builder->new(); | ||||||||||||||||||||||||||||
| 51 | $app->process(); | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # you can set page name this way if you want but in this way | ||||||||||||||||||||||||||||
| 54 | # you do not need to use this extention :-p | ||||||||||||||||||||||||||||
| 55 | #$app->process( 'page_name' ); | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | Your CGI::Builder Package. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | package Your::CGI::Builder; | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | use CGI::Builder qw/ | ||||||||||||||||||||||||||||
| 64 | CGI::Builder::GetPageName | ||||||||||||||||||||||||||||
| 65 | /; | ||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | sub PH_foo_bar { | ||||||||||||||||||||||||||||
| 68 | my $s = shift; | ||||||||||||||||||||||||||||
| 69 | $s->page_content( 'my URL is http://localhost/script.cgi/foo/bar/?foo=whatever !!!!' ); | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | sub PH_hoge { | ||||||||||||||||||||||||||||
| 73 | my $s = shift; | ||||||||||||||||||||||||||||
| 74 | $s->page_content = 'my URL is http://localhost/script.cgi/hoge/ !!!' ; | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head1 MORE FUN? | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Use ScriptAlias !!! This allow you to hide .cgi extension. Very fun. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | ScriptAlias /secure /var/www/httpdoc/secure.cgi | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | # You have this start script. | ||||||||||||||||||||||||||||
| 85 | http://localhost/secure.cgi | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | # You set script alias so , you can also access with this URL. | ||||||||||||||||||||||||||||
| 88 | http://localhost/secure | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | # Then now... | ||||||||||||||||||||||||||||
| 91 | sub PH_foo_bar { | ||||||||||||||||||||||||||||
| 92 | my $s = shift; | ||||||||||||||||||||||||||||
| 93 | $s->page_content = 'my URL is http://localhost/secure/foo/bar/?foo=whatever !!!' ; | ||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =head1 OVERRIDE MODULES | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head2 get_page_name | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | I override this method but I guess you do not need to care. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | CGI::Builder | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | =head1 CREDITS | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | Thanks to Domizio Demichelis for everything! | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | Tomohiro Teranishi <tomohiro.teranishi+cpan@gmail.com> | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | This program is distributed under the Artistic License | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =cut | ||||||||||||||||||||||||||||