]> git.decadent.org.uk Git - maypole.git/blob - lib/CGI/Maypole.pm
Added parse_args to Maypole::CLI and CGI::Maypole
[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->parse_args;
26 }
27
28 sub parse_args {
29      my $self = shift;
30      $self->{params} = { $self->{cgi}->Vars };
31      $self->{query}  = { $self->{cgi}->Vars };
32 }
33
34 sub send_output {
35      my $r = shift;     
36         print $r->{cgi}->header(-type => $r->{content_type},
37                                           -content_length => length $r->{output},
38                                           );
39      print $r->{output};
40 }
41
42 sub get_template_root {
43      my $r = shift;
44      $r->{cgi}->document_root . "/". $r->{cgi}->url(-relative=>1);
45 }
46
47
48 1;
49
50 =head1 NAME
51
52 CGI::Maypole - CGI-based front-end to Maypole
53
54 =head1 SYNOPSIS
55
56      package BeerDB;
57      use base 'CGI::Maypole;
58      BeerDB->setup("dbi:mysql:beerdb");
59      BeerDB->config->{uri_base} = "http://your.site/cgi-bin/beer.cgi/";
60      BeerDB->config->{display_tables} = [qw[beer brewery pub style]];
61      # Now set up your database:
62      # has-a relationships
63      # untaint columns
64
65      1;
66
67      ## example beer.cgi:
68         
69      #!/usr/bin/perl -w
70      use strict;
71      use BeerDB;
72      BeerDB->run();
73
74 =head1 DESCRIPTION
75
76 This is a handler for Maypole which will use the CGI instead of Apache's
77 C<mod_perl> 1.x. This handler can also be used for Apache 2.0.
78
79 =head1 AUTHORS
80
81 Dave Ranney C<dave@sialia.com>
82
83 Simon Cozens C<simon@cpan.org>