Commit | Line | Data |
ebf8ace2 |
1 | package Catalyst::Controller::MovableType; |
2 | use Moose; |
0f45bc49 |
3 | BEGIN { extends 'Catalyst::Controller::WrapCGI'; } |
4 | use utf8; |
ebf8ace2 |
5 | use namespace::autoclean; |
6 | |
0f45bc49 |
7 | has 'perl' => (is => 'rw', default => 'perl'); |
8 | |
9 | has 'mt_home' => (is => 'rw'); # /my/app/root/mt/ |
10 | |
11 | sub 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 | |
47 | sub not_found :Private { |
48 | my ($self, $c) = @_; |
49 | $c->response->status(404); |
50 | $c->response->body('Not found!'); |
51 | $c->detach(); |
52 | } |
53 | |
ebf8ace2 |
54 | 1; |
55 | |
0f45bc49 |
56 | __END__ |
57 | |
ebf8ace2 |
58 | =head1 NAME |
59 | |
0f45bc49 |
60 | Catalyst::Controller::MovableType - Run Movable Type through Catalyst |
61 | |
62 | =head1 SYNOPSIS |
63 | |
64 | package MyApp::Controller::Mt; |
65 | |
66 | use Moose; |
67 | BEGIN {extends 'Catalyst::Controller::MT'; } |
68 | use utf8; |
69 | |
70 | 1; |
71 | |
72 | =head1 INSTALLATION |
73 | |
74 | Install Movable Type by extracting the zip into your template root directory. |
75 | Move mt-static to root/static/mt, and configure Movable Type accordingly. |
ebf8ace2 |
76 | |
77 | =head1 DESCRIPTION |
78 | |
0f45bc49 |
79 | Runs Movable Type 5 through Catalyst. |
80 | Download Movable Type 5 from http://www.movabletype.org/ |
81 | |
ebf8ace2 |
82 | =head1 METHODS |
83 | |
0f45bc49 |
84 | =head2 run_mt_script |
85 | |
86 | Runs the requested Movable Type .cgi script transparently with cgi_to_response. |
87 | |
88 | =head2 not_found |
89 | |
90 | Sets the response to a simple 404 Not found page. You can override this method |
91 | with your own. |
92 | |
ebf8ace2 |
93 | =head1 BUGS |
94 | |
0f45bc49 |
95 | None known. |
96 | |
97 | =head1 SEE ALSO |
98 | |
99 | L<Catalyst::Controller::WrapCGI> |
100 | |
ebf8ace2 |
101 | =head1 AUTHOR |
102 | |
0f45bc49 |
103 | Oskari 'Okko' Ojala <perl@okko.net> |
104 | |
105 | =head1 CONTRIBUTORS |
106 | |
107 | Matt S. Trout <mst@shadowcatsystems.co.uk> |
108 | |
ebf8ace2 |
109 | =head1 COPYRIGHT & LICENSE |
110 | |
0f45bc49 |
111 | Copyright 2010 the above author(s). |
ebf8ace2 |
112 | |
0f45bc49 |
113 | This sofware is free software, and is licensed under the same terms as Perl itself. |
ebf8ace2 |
114 | |
115 | =cut |
116 | |