Initial commit with the functionality.
[catagits/Catalyst-Controller-MovableType.git] / lib / Catalyst / Controller / MovableType.pm
CommitLineData
ebf8ace2 1package Catalyst::Controller::MovableType;
2use Moose;
0f45bc49 3BEGIN { extends 'Catalyst::Controller::WrapCGI'; }
4use utf8;
ebf8ace2 5use namespace::autoclean;
6
0f45bc49 7has 'perl' => (is => 'rw', default => 'perl');
8
9has 'mt_home' => (is => 'rw'); # /my/app/root/mt/
10
11sub run_mt_script :Path {
12 my ($self, $c, $cgi_script) = @_;
13
14 my %mt_scripts
15 = map +($_ => 1),
16 qw( mt-add-notify.cgi
17 mt-atom.cgi
18 mt.cgi
19 mt-comments.cgi
20 mt-feed.cgi
21 mt-ftsearch.cgi
22 mt-search.cgi
23 mt-tb.cgi
24 mt-testbg.cgi
25 mt-upgrade.cgi
26 mt-wizard.cgi
27 mt-xmlrpc.cgi
28 ) # mt-config.cgi intentionally left out
29 ;
30
31 # http://www.movabletype.org/documentation/installation/install-movable-type.html#start-blogging states:
32 # Warning: because the mt-check.cgi script displays server details which could be useful to a hacker, it
33 # is recommended that this script be removed or renamed.
34 #
35 # Allow it only in debug mode.
36 $mt_scripts{'mt_check.cgi'} = 1 if ($c->debug());
37
38 $self->not_found() unless ($mt_scripts{$cgi_script});
39
40 $ENV{MT_HOME} = $self->mt_home;
41
42 $self->cgi_to_response($c, sub {
43 system($self->perl, $self->mt_home.$cgi_script);
44 });
45}
46
47sub not_found :Private {
48 my ($self, $c) = @_;
49 $c->response->status(404);
50 $c->response->body('Not found!');
51 $c->detach();
52}
53
ebf8ace2 541;
55
0f45bc49 56__END__
57
ebf8ace2 58=head1 NAME
59
0f45bc49 60Catalyst::Controller::MovableType - Run Movable Type through Catalyst
61
62=head1 SYNOPSIS
63
64package MyApp::Controller::Mt;
65
66use Moose;
67BEGIN {extends 'Catalyst::Controller::MT'; }
68use utf8;
69
701;
71
72=head1 INSTALLATION
73
74Install Movable Type by extracting the zip into your template root directory.
75Move mt-static to root/static/mt, and configure Movable Type accordingly.
ebf8ace2 76
77=head1 DESCRIPTION
78
0f45bc49 79Runs Movable Type 5 through Catalyst.
80Download Movable Type 5 from http://www.movabletype.org/
81
ebf8ace2 82=head1 METHODS
83
0f45bc49 84=head2 run_mt_script
85
86Runs the requested Movable Type .cgi script transparently with cgi_to_response.
87
88=head2 not_found
89
90Sets the response to a simple 404 Not found page. You can override this method
91with your own.
92
ebf8ace2 93=head1 BUGS
94
0f45bc49 95None known.
96
97=head1 SEE ALSO
98
99L<Catalyst::Controller::WrapCGI>
100
ebf8ace2 101=head1 AUTHOR
102
0f45bc49 103Oskari 'Okko' Ojala <perl@okko.net>
104
105=head1 CONTRIBUTORS
106
107Matt S. Trout <mst@shadowcatsystems.co.uk>
108
ebf8ace2 109=head1 COPYRIGHT & LICENSE
110
0f45bc49 111Copyright 2010 the above author(s).
ebf8ace2 112
0f45bc49 113This sofware is free software, and is licensed under the same terms as Perl itself.
ebf8ace2 114
115=cut
116