]> git.decadent.org.uk Git - maypole.git/blob - lib/CGI/Maypole.pm
Add refactored CGI::Maypole to the mix.
[maypole.git] / lib / CGI / Maypole.pm
1 package CGI::Maypole;
2 use base 'Maypole';
3
4 use strict;
5 use warnings;
6 our $VERSION = "0.3";
7
8 sub run {
9         my $self = shift;
10         return $self->handler();
11 }
12
13 sub get_request {
14         require CGI::Simple;
15         shift->{cgi} = CGI::Simple->new();
16 }
17
18 sub parse_location {
19      my $self = shift;
20      $self->{path} = $self->{cgi}->url(-absolute=>1, -path_info=>1);
21      my $loc = $self->{cgi}->url(-absolute=>1);
22      no warnings 'uninitialized';
23      $self->{path} =~ s/^($loc)?\///;
24      $self->parse_path;
25      $self->{params} = { $self->{cgi}->Vars };
26      $self->{query}  = { $self->{cgi}->Vars };
27 }
28
29 sub send_output {
30      my $r = shift;     
31         print $r->{cgi}->header(-type => $r->{content_type},
32                                           -content_length => length $r->{output},
33                                           );
34      print $r->{output};
35 }
36
37 sub get_template_root {
38      my $r = shift;
39      $r->{cgi}->document_root . "/". $r->{cgi}->url(-relative=>1);
40 }
41
42
43 1;
44
45 =head1 NAME
46
47 CGI::Maypole - CGI-based front-end to Maypole
48
49 =head1 SYNOPSIS
50
51      package BeerDB;
52      use base 'CGI::Maypole;
53      BeerDB->setup("dbi:mysql:beerdb");
54      BeerDB->config->{uri_base} = "http://your.site/cgi-bin/beer.cgi/";
55      BeerDB->config->{display_tables} = [qw[beer brewery pub style]];
56      # Now set up your database:
57      # has-a relationships
58      # untaint columns
59
60      1;
61
62      ## example beer.cgi:
63         
64      #!/usr/bin/perl -w
65      use strict;
66      use BeerDB;
67      BeerDB->run();
68
69 =head1 DESCRIPTION
70
71 This is a handler for Maypole which will use the CGI instead of Apache's
72 C<mod_perl> 1.x. This handler can also be used for Apache 2.0.
73
74 =head1 AUTHORS
75
76 Dave Ranney C<dave@sialia.com>
77
78 Simon Cozens C<simon@cpan.org>