#!/usr/bin/perl # -*- Mode: cperl; cperl-indent-level: 4 -*- use strict; use warnings; use base qw(HTTP::Server::Simple::CGI); use SVN::Web; use Getopt::Long; =head1 NAME svnweb-server - simple webserver for SVN::Web =head1 SYNOPSIS svnweb-server [--root DIR] [--port PORT] [--net-server Net::Server] =head1 DESCRIPTION svnweb-server is a webserver that runs SVN::Web. It's an easy way to use SVN::Web without having to set up Apache (or any other web server). The tradeoff is that the server is very simple. But for light use then it may be perfectly acceptable. =head1 OPTIONS =over =item --root DIR The directory in which you ran C. Optional, defaults to C<.>. =item --port PORT The port the server should listen on. Options, defaults to C<8080>. =item --net-server Net::Server The Net::Server subclass to use to create the server. A single, non-forking server is created by default. Other types of server can be created by giving the correct Net::Server subclass. For example, to use a server that forks to handle each request, use C<--net-server Net::Server::Fork>. =back =cut my %options = ( 'root' => '.', 'port' => '8080', 'net_server' => undef ); GetOptions( 'root=s' => \$options{root}, 'port=i' => \$options{port}, 'net-server=s' => \$options{net_server}, ); sub handle_request { my($self, $cgi) = @_; if($cgi->path_info() =~ m{^/css/}) { # Pass /css requests straight through my $file = $cgi->path_info(); $file =~ s/^\///g; open(FILE, $file) or die "Can't open() $file: $!\n"; local $/ = undef; print ; close FILE; } else { $ENV{SCRIPT_NAME} = 'http://' . $self->host() . ':' . $self->port(); print "HTTP/1.1 200 OK\n"; SVN::Web::run_cgi(cgi_class => 'CGI'); } } use CGI::Carp qw(fatalsToBrowser); if(!-f "$options{root}/config.yaml") { print <new($options{port}); $server->net_server($options{net_server}) if defined $options{net_server}; $server->run(); exit; =head1 SEE ALSO L =head1 BUGS This is a simple server. Accordingly, a few features do not work properly at the moment. =over =item Redirects L will redirect the client if the URL is missing a trailing C. That redirection does not work with this server. That's not an issue for any URLs generated by L, but may be an issue for URLs that are entered by hand. This will also affect L's C option. =item cgi_class The C declaration (if any) in F is ignored. L is always used as the CGI class. =back Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 AUTHOR The current maintainer is Nik Clayton, . =head1 COPYRIGHT AND LICENSE Copyright 2006-2007 Nik Clayton. All Rights Reserved.