Implemented chaining so that Catalyst::Controller::WrapCGI::wrap_cgi can properly...
okko [Fri, 16 Apr 2010 15:55:52 +0000 (18:55 +0300)]
Changes
lib/Catalyst/Controller/MovableType.pm

diff --git a/Changes b/Changes
index ebf7239..7de3591 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,11 @@
 0.003
         2010-04-xx
-        Fixed not_found call when an unexisting script is requested.
+        Fixed internal not_found call to properly pass $c when an unexisting
+        script was requested.
+
+        Implemented chaining so that Catalyst::Controller::WrapCGI::wrap_cgi
+        can properly populate $ENV{SCRIPT_NAME} with
+        $c->uri_for($c->action, $c->req->captures)->path                                                                                     
 
 0.002
         2010-04-13
index 8718b14..1552419 100644 (file)
@@ -10,8 +10,15 @@ has 'perl' => (is => 'rw', default => 'perl');
 
 has 'mt_home' => (is => 'rw'); # /my/app/root/mt/
 
-sub run_mt_script :Path {
-    my ($self, $c, $cgi_script) = @_;
+# Use chaining here, so that Catalyst::Controller::WrapCGI::wrap_cgi can properly
+# populate $ENV{SCRIPT_NAME} with $c->uri_for($c->action, $c->req->captures)->path,
+# so that MovableType can then extract the correct path of location.
+sub capture_mt_script :Chained('/') :PathPart('mt') :CaptureArgs(1) { }
+sub run_mt_script :Chained('capture_mt_script') :PathPart('') :Args {
+    my ($self, $c) = @_;
+    my $captures = $c->req->captures;
+    my $cgi_script = $captures->[0];
 
     my %mt_scripts
         = map +($_ => 1),
@@ -61,6 +68,21 @@ __END__
 
 Catalyst::Controller::MovableType - Run Movable Type through Catalyst
 
+=head1 DESCRIPTION
+
+Runs Movable Type 5 through Catalyst.
+Download Movable Type 5 from http://www.movabletype.org/
+
+=head1 SYNOPSIS
+
+ package MyApp::Controller::Mt;
+
+ use Moose;
+ BEGIN {extends 'Catalyst::Controller::MovableType'; }
+ use utf8;
+
+ 1;
+
 =head1 INSTALLATION
 
 Install Movable Type by extracting the zip into your template root directory.
@@ -69,15 +91,23 @@ in your app. Presuming you installed Movable Type into root/mt, in your App's
 config add:
 
 <Controller::Root>
-        cgi_root_path mt/
-        cgi_dir mt/
+    cgi_root_path mt/
+    cgi_dir mt/
 </Controller::Root>
 <Controller::Mt>
-        mt_home = /full/path/to/MyApp/root/mt/
+    mt_home = /full/path/to/MyApp/root/mt/
+    <actions>
+        <capture_script_name>
+            PathPart = mt
+        </capture_script_name>
+    </actions>
 </Controller::Mt>
 
 The cgi_* directives are always given for the Root controller, no matter what
-the Root controller is or even if it doesn't even exist.
+the Root controller is.
+
+You can modify the path where the script matches by configuring the PathPart as
+shown above. This controller defaults to match on the path "/mt".
 
 Finally, make sure that the Static::Simple doesn't affect the Movable Type's
 installation directory. An example:
@@ -91,25 +121,11 @@ __PACKAGE__->config(
                         }
 );
 
+=head1 METHODS
 
-=head1 SYNOPSIS
-
- package MyApp::Controller::Mt;
-
- use Moose;
- BEGIN {extends 'Catalyst::Controller::MovableType'; }
- use utf8;
-
- 1;
-
-=head1
-
-=head1 DESCRIPTION
-
-Runs Movable Type 5 through Catalyst.
-Download Movable Type 5 from http://www.movabletype.org/
+=head2 capture_mt_script
 
-=head1 METHODS
+Captures the path of the Movable Type.
 
 =head2 run_mt_script