Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed 3cf8bda

Added the skeleton of version 0.2.0.

  • Participants
  • Tags releases/0.2.0

Comments (0)

Files changed (9)

File Catalyst-Plugin-SanitizeUrl/Changes

+Revision history for Perl extension Catalyst::Plugin::SanitizeUrl.
+
+0.2.0   Tue 05 May 2005
+    - First release.

File Catalyst-Plugin-SanitizeUrl/MANIFEST

+Changes
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README
+t/01use.t
+t/02pod.t
+lib/
+lib/Catalyst/Plugin/SanitizeUrl/PrepAction.pm
+lib/Catalyst/Plugin/SanitizeUrl.pm

File Catalyst-Plugin-SanitizeUrl/META.yml

+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!!  It will change in the future!!! XXXXX#
+name:         Catalyst-Plugin-SanitizeUrl
+version:      0.2.0
+version_from: lib/Catalyst/Plugin/SanitizeUrl.pm
+installdirs:  site
+requires:
+    Catalyst:                      5.23
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17

File Catalyst-Plugin-SanitizeUrl/Makefile.PL

+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME      => 'Catalyst::Plugin::SanitizeUrl',
+    AUTHOR    => 'Shlomi Fish (shlomif@iglu.org.il',
+    PREREQ_PM => {
+        Catalyst            => '5.23',
+    },
+    VERSION_FROM => 'lib/Catalyst/Plugin/SanitizeUrl.pm'
+);
+

File Catalyst-Plugin-SanitizeUrl/README

+Make sure that trailing slashes in Catalyst URLs are not ignored.
+

File Catalyst-Plugin-SanitizeUrl/lib/Catalyst/Plugin/SanitizeUrl.pm

+package Catalyst::Plugin::SanitizeUrl;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.2.0';
+
+use base 'Catalyst::Plugin::SanitizeUrl::PrepAction';
+
+sub get_action_path
+{
+    my $c    = shift;
+    my $path = $c->req->path;
+    return [ split /\//, $c->req->path, (-1) ];
+}
+
+1;
+
+__END__
+=head1 NAME
+
+Catalyst::Plugin::SanitizeUrl - Make sure Catalyst does not ignore trailing slashes
+
+=head1 SYNOPSIS
+
+    use Catalyst 'SanitizeUrl';
+
+=head1 DESCRIPTION
+
+This plugin makes sure Catalyst is not agnostic to trailing slashes in the 
+URLs passed to it by the user agent.
+
+By default Catalyst will treat the following URLs:
+
+    http://localhost:3000/one/two
+
+And
+
+    http://localhost:3000/one/two/
+
+As the same, even though user agents treat them differently as far as relative
+URLs are concerned.
+
+This plugin will cause the trailing slashes to be included in the Catalyst
+path.
+
+=head2 EXTENDED METHODS
+
+=head3 prepare
+
+Sets up $c->{form}
+
+=head1 SEE ALSO
+
+L<Catalyst>
+
+=head1 AUTHOR
+
+Shlomi Fish, C<shlomif@iglu.org.il>
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it under
+the terms of the MIT X11 license.
+
+(Just note that the ::PrepAction module is derived from the Catalyst code 
+itself and so is distributed under the same terms as Perl itself).
+
+=cut
+

File Catalyst-Plugin-SanitizeUrl/lib/Catalyst/Plugin/SanitizeUrl/PrepAction.pm

+package Catalyst::Plugin::SanitizeUrl::PrepAction;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.2.0';
+
+=head1 Catalyst::Plugin::SanitizeUrl::PrepAction 
+
+A class to abstract functionality out of the prepare_action method.
+
+=item $c->get_action_path
+
+Calculate the path components for the action. Returns an array reference
+containing the 
+=cut
+
+sub get_action_path {
+    my $c    = shift;
+    my $path = $c->req->path;
+    return [ split /\//, $c->req->path ];
+}
+
+=item $c->prepare_action
+
+Prepare action. This function is nearly identical to the one in Catalyst.pm
+with the only difference is the extraction of the get_action_path() 
+method. <sigh />
+
+=cut
+
+
+sub prepare_action {
+    my $c    = shift;
+    my $path;    
+    my @path = @{$c->get_action_path};
+    $c->req->args( \my @args );
+
+    while (@path) {
+        $path = join '/', @path;
+        if ( my $result = ${ $c->get_action($path) }[0] ) {
+
+            # It's a regex
+            if ($#$result) {
+                my $match    = $result->[1];
+                my @snippets = @{ $result->[2] };
+                $c->log->debug(
+                    qq/Requested action is "$path" and matched "$match"/)
+                  if $c->debug;
+                $c->log->debug(
+                    'Snippets are "' . join( ' ', @snippets ) . '"' )
+                  if ( $c->debug && @snippets );
+                $c->req->action($match);
+                $c->req->snippets( \@snippets );
+            }
+
+            else {
+                $c->req->action($path);
+                $c->log->debug(qq/Requested action is "$path"/) if $c->debug;
+            }
+
+            $c->req->match($path);
+            last;
+        }
+        unshift @args, pop @path;
+    }
+
+    unless ( $c->req->action ) {
+        $c->req->action('default');
+        $c->req->match('');
+    }
+
+    $c->log->debug( 'Arguments are "' . join( '/', @args ) . '"' )
+      if ( $c->debug && @args );
+}
+
+=head1 AUTHOR
+
+Sebastian Riedel, C<sri@cpan.org>
+
+Modified by Shlomi Fish, C<shlomif@iglu.org.il>
+
+=head1 LICENSE
+
+This program is free software. You may copy or redistribute it under the same 
+terms as Perl itself.
+
+=cut
+

File Catalyst-Plugin-SanitizeUrl/t/01use.t

+use strict;
+use Test::More tests => 1;
+
+BEGIN { use_ok('Catalyst::Plugin::SanitizeUrl') }

File Catalyst-Plugin-SanitizeUrl/t/02pod.t

+use Test::More;
+
+eval "use Test::Pod 1.14";
+plan skip_all => 'Test::Pod 1.14 required' if $@;
+plan skip_all => 'set TEST_POD to enable this test' unless $ENV{TEST_POD};
+
+all_pod_files_ok();