##  
##  kwiki-apache.conf -- Apache Configuration for Kwiki
##

#   convenience URL redirection
RedirectMatch ^/kwiki$ /kwiki/

#   run-time URL aliasing
Alias /kwiki/ @l_prefix@/var/kwiki/

#   run-time directory configuration
<Directory @l_prefix@/var/kwiki>
    #   access control
    Order allow,deny
    Allow from all

    #   local server configuration
    AllowOverride All
    Options ExecCGI
    DirectoryIndex index.cgi

    #   run-time engine selection
    <IfModule mod_perl.c>
        #   use accelerating mod_perl
        <Files *.cgi>
            SetHandler perl-script
            PerlHandler Apache::Registry
        </Files>
    </IfModule>
    <IfModule !mod_perl.c>
        #   use standardized mod_cgi
        AddHandler cgi-script .cgi
    </IfModule>
</Directory>
<Directory @l_prefix@/var/kwiki/admin>
    #   access control
    Require user admin
    AuthType Basic
    AuthName Restricted
    AuthUserFile @l_prefix@/var/kwiki/admin/passwd
    <Files passwd>
        Order allow,deny
        Deny from all
        Satisfy All
    </Files>

    #   local server configuration
    Options +FollowSymLinks
</Directory>
<Directory @l_prefix@/var/kwiki/plugin/attachments>
    #   access control
    Allow from all
</Directory>

#   optional mod_perl setup
<IfModule mod_perl.c>
    <Perl>
        #   support optional lib/ subdir similar to index.cgi 
        use lib "@l_prefix@/var/kwiki/lib";

        #   pre-load all Kiwki plugins
        use CGI;
        use Spoon;
        use Spiffy;
        use Kwiki;
        use IO::File;
        my $io = new IO::File "<@l_prefix@/var/kwiki/plugins" or die;
        my $run = ''; $run .= $_ while (<$io>);
        $io->close();
        $run =~ s|^(Kwiki::.+)$|use $1;|mg;
        eval "$run";
    </Perl>
</IfModule>

