-And copy the templates found in F<templates/factory> into the
-F<catalogue/factory> directory off the web root. When the designers get
-back to you with custom templates, they are to go in
-F<catalogue/custom>. If you need to do override templates on a
-database-table-by-table basis, put the new template in
-F<catalogue/I<table>>.
+Copy the templates found in F<templates/factory> into the F<beer/factory>
+directory off the web root. When the designers get back to you with custom
+templates, they are to go in F<beer/custom>. If you need to override templates
+on a database-table-by-table basis, put the new template in F<beer/I<table>>.
+
+This will automatically give you C<add>, C<edit>, C<list>, C<view> and C<delete>
+commands; for instance, to see a list of breweries, go to
+
+ http://your.site/beer/brewery/list
+
+For more information about how the system works and how to extend it,
+see L<Maypole>.
+
+=head1 Implementation
+
+This class overrides a set of methods in the base Maypole class to provide its
+functionality. See L<Maypole> for these:
+
+=over
+
+=item get_request
+
+=cut
+
+sub get_request {
+ my ($self, $r) = @_;
+ my $ar = (APACHE2) ? Apache2::Request->new($r) : Apache::Request->instance($r);
+ $self->ar($ar);
+}
+
+=item parse_location
+
+=cut
+
+sub parse_location {
+ my $self = shift;
+
+ # Reconstruct the request headers
+ $self->headers_in(Maypole::Headers->new);
+ my %headers;
+ if (APACHE2) { %headers = %{$self->ar->headers_in};
+ } else { %headers = $self->ar->headers_in; }
+ for (keys %headers) {
+ $self->headers_in->set($_, $headers{$_});
+ }
+ my $path = $self->ar->uri;
+ my $loc = $self->ar->location;
+ {
+ no warnings 'uninitialized';
+ $path .= '/' if $path eq $loc;
+ $path =~ s/^($loc)?\///;
+ }
+ $self->path($path);
+
+ $self->parse_path;
+ $self->parse_args;
+}
+
+=item parse_args
+
+=cut
+
+sub parse_args {
+ my $self = shift;
+ $self->params( { $self->_mod_perl_args( $self->ar ) } );
+ $self->query( $self->params );
+}
+
+=item redirect_request
+
+=cut
+
+# FIXME: use headers_in to gather host and other information?
+sub redirect_request
+{
+ my $r = shift;
+ my $redirect_url = $_[0];
+ my $status = "302";
+ if ($_[1]) {
+ my %args = @_;
+ if ($args{url}) {
+ $redirect_url = $args{url};
+ } else {
+ my $path = $args{path} || $r->path;
+ my $host = $args{domain} || $r->ar->hostname;
+ my $protocol = $args{protocol} || $r->get_protocol;
+ $redirect_url = "${protocol}://${host}/${path}";
+ }
+ $status = $args{status} if ($args{status});
+ }