From: Sebastian Riedel Date: Wed, 29 Sep 2004 20:55:32 +0000 (+0000) Subject: added rewrite_path() X-Git-Tag: 2.10~150 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=6f3e2ec142b6dd83d7d4960cf15acd6ca8b73e1d;p=maypole.git added rewrite_path() git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@212 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/Changes b/Changes index b108b73..1b9235f 100644 --- a/Changes +++ b/Changes @@ -21,6 +21,7 @@ Revision history for Perl extension Maypole - moved doc/*.pod to lib/Maypole/Manual - added Maypole::Model::Base::is_public() to make it simple to overload :Exported behavior + - added rewrite_path() 1.7 Sat Jul 17 20:15:26 BST 2004 - Emergency release - we lost the "use Maypole::Constants" from diff --git a/lib/Apache/MVC.pm b/lib/Apache/MVC.pm index 5eb1e4d..4fcd8df 100644 --- a/lib/Apache/MVC.pm +++ b/lib/Apache/MVC.pm @@ -30,6 +30,7 @@ sub parse_location { my $loc = $self->{ar}->location; no warnings 'uninitialized'; $self->{path} =~ s/^($loc)?\///; + $self->rewrite_path; $self->parse_path; $self->parse_args; } diff --git a/lib/CGI/Maypole.pm b/lib/CGI/Maypole.pm index 67cbf92..8d9508c 100644 --- a/lib/CGI/Maypole.pm +++ b/lib/CGI/Maypole.pm @@ -21,6 +21,7 @@ sub parse_location { my $loc = $self->{cgi}->url( -absolute => 1 ); no warnings 'uninitialized'; $self->{path} =~ s/^($loc)?\///; + $self->rewrite_path; $self->parse_path; $self->parse_args; } diff --git a/lib/Maypole.pm b/lib/Maypole.pm index 9c67ad6..7ab6cb3 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -130,8 +130,9 @@ sub is_applicable { $config->ok_tables || $config->ok_tables( $config->display_tables ); $config->ok_tables( { map { $_ => 1 } @{ $config->ok_tables } } ) if ref $config->ok_tables eq "ARRAY"; - warn "We don't have that table ($self->{table}).\n". - "Available tables are: ".join (",", @{ $config->{display_tables} }) + warn "We don't have that table ($self->{table}).\n" + . "Available tables are: " + . join( ",", @{ $config->{display_tables} } ) if $self->debug and not $config->ok_tables->{ $self->{table} }; return DECLINED() unless exists $config->ok_tables->{ $self->{table} }; @@ -172,6 +173,8 @@ sub authenticate { return OK } sub exception { return ERROR } +sub rewrite_path { } + sub parse_path { my $self = shift; $self->{path} ||= "frontpage"; diff --git a/lib/Maypole/CLI.pm b/lib/Maypole/CLI.pm index 49f2675..0fd3fa3 100644 --- a/lib/Maypole/CLI.pm +++ b/lib/Maypole/CLI.pm @@ -22,10 +22,11 @@ sub get_template_root { $ENV{MAYPOLE_TEMPLATES} || "." } sub parse_location { my $self = shift; - my $url = URI->new(shift @ARGV); - my $root = URI->new($self->config->uri_base)->path; + my $url = URI->new( shift @ARGV ); + my $root = URI->new( $self->config->uri_base )->path; $self->{path} = $url->path; $self->{path} =~ s/^$root//i if $root; + $self->rewrite_path; $self->parse_path; $self->parse_args($url); }