X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=lib%2FCatalyst%2FController.pm;h=5902597e231cdf1236e02ff73ea3efbf038eaf04;hp=03d443ae3defd2dd408d7dd57988025e81e4aa43;hb=e16a6c4e6c4d49e73b5286b3186616af14f3f554;hpb=e5d2cfdb03e4f8678893e7ceb550f2b4303f2d3a diff --git a/lib/Catalyst/Controller.pm b/lib/Catalyst/Controller.pm index 03d443a..5902597 100644 --- a/lib/Catalyst/Controller.pm +++ b/lib/Catalyst/Controller.pm @@ -279,6 +279,38 @@ sub _parse_LocalRegex_attr { sub _parse_LocalRegexp_attr { shift->_parse_LocalRegex_attr(@_); } +sub _parse_Chained_attr { + my ($self, $c, $name, $value) = @_; + + if (defined($value) && length($value)) { + if ($value eq '.') { + $value = '/'.$self->action_namespace($c); + } elsif (my ($rel, $rest) = $value =~ /^((?:\.{2}\/)+)(.*)$/) { + my @parts = split '/', $self->action_namespace($c); + my @levels = split '/', $rel; + + $value = '/'.join('/', @parts[0 .. $#parts - @levels], $rest); + } elsif ($value !~ m/^\//) { + my $action_ns = $self->action_namespace($c); + + if ($action_ns) { + $value = '/'.join('/', $action_ns, $value); + } else { + $value = '/'.$value; # special case namespace '' (root) + } + } + } else { + $value = '/' + } + + return Chained => $value; +} + +sub _parse_ChainedParent_attr { + my ($self, $c, $name, $value) = @_; + return $self->_parse_Chained_attr($c, $name, '../'.$name); +} + sub _parse_PathPrefix_attr { my $self = shift; return PathPart => $self->path_prefix; @@ -368,10 +400,9 @@ Primarily designed for the use of register_actions. Returns the application instance stored by C -=head1 AUTHOR +=head1 AUTHORS -Sebastian Riedel, C -Marcus Ramberg C +Catalyst Contributors, see Catalyst.pm =head1 COPYRIGHT