1 package Catalyst::Controller::MovableType;
3 BEGIN { extends 'Catalyst::Controller::WrapCGI'; }
5 use namespace::autoclean;
9 has 'perl' => (is => 'rw', default => 'perl');
11 has 'mt_home' => (is => 'rw'); # /my/app/root/mt/
13 # Use chaining here, so that Catalyst::Controller::WrapCGI::wrap_cgi can properly
14 # populate $ENV{SCRIPT_NAME} with $c->uri_for($c->action, $c->req->captures)->path,
15 # so that MovableType can then extract the correct path of location.
16 sub capture_mt_script :Chained('/') :PathPart('mt') :CaptureArgs(1) { }
18 sub run_mt_script :Chained('capture_mt_script') :PathPart('') :Args {
20 my $captures = $c->req->captures;
21 my $cgi_script = $captures->[0];
37 ) # mt-config.cgi intentionally left out
40 # http://www.movabletype.org/documentation/installation/install-movable-type.html#start-blogging states:
41 # Warning: because the mt-check.cgi script displays server details which could be useful to a hacker, it
42 # is recommended that this script be removed or renamed.
44 # Allow it only in debug mode.
45 $mt_scripts{'mt_check.cgi'} = 1 if ($c->debug());
47 $self->not_found($c) unless ($mt_scripts{$cgi_script});
49 $ENV{MT_HOME} = $self->mt_home;
51 $self->cgi_to_response($c, sub {
52 system($self->perl, $self->mt_home.$cgi_script);
56 sub not_found :Private {
58 $c->response->status(404);
59 $c->response->body('Not found!');
69 Catalyst::Controller::MovableType - Run Movable Type through Catalyst
73 Runs Movable Type 5 through Catalyst.
74 Download Movable Type 5 from http://www.movabletype.org/
78 package MyApp::Controller::Mt;
81 BEGIN {extends 'Catalyst::Controller::MovableType'; }
88 Install Movable Type by extracting the zip into your template root directory.
89 Move mt-static to root/static/mt. See Synopsis on how to inherit the Controller
90 in your app. Presuming you installed Movable Type into root/mt, in your App's
98 mt_home = /full/path/to/MyApp/root/mt/
100 <capture_script_name>
102 </capture_script_name>
106 The cgi_* directives are always given for the Root controller, no matter what
107 the Root controller is.
109 You can modify the path where the script matches by configuring the PathPart as
110 shown above. This controller defaults to match on the path "/mt".
112 Finally, make sure that the Static::Simple doesn't affect the Movable Type's
113 installation directory. An example:
116 name => 'TerveinkansaFi',
118 # first ignore all extensions, then specify static directories!
119 'ignore_extensions' => [ qr/.*/ ],
120 'dirs' => [ qw/static/ ]
126 =head2 capture_mt_script
128 Captures the path of the Movable Type.
132 Runs the requested Movable Type .cgi script transparently with cgi_to_response.
136 Sets the response to a simple 404 Not found page. You can override this method
145 L<Catalyst::Controller::WrapCGI>
149 Oskari 'Okko' Ojala <perl@okko.net>
153 Matt S. Trout <mst@shadowcatsystems.co.uk>
155 =head1 COPYRIGHT & LICENSE
157 Copyright 2010 the above author(s).
159 This sofware is free software, and is licensed under the same terms as Perl itself.