### Combo test configuration
#	This file sets up a testing environment for Combo.  It assumes that
#	the server root is /var/www (as it is in, e.g., RedHat 7.x) and that
#	$SERVER_ROOT/Ccgi is a symlink to the Combo/cgi subdirectory of the
#	working tree.  It can either be "Include"d in httpd.conf or symlinked
#	from srm.conf (which is really cheating).

# === Eventually this should end up in a config file generated by a script
# === from a global configuration file that says where ServerRoot,
# === DocumentRoot, /site, and Combo are.  

### There may be two virtual hosts:  the normal one and the edit/upload one.
### The document root and Ccgi directory are shared.


# Map the CGI directory into URL space.  It doesn't have to be browsable,
# but there's no real reason for it not to be.  Since this is a test
# configuration, we go ahead.  Use ScriptAlias to make it invisible.

Alias /Ccgi /var/www/Ccgi
<Directory "/var/www/Ccgi">
    AllowOverride None
    Options ExecCGI Indexes MultiViews Includes FollowSymLinks
    AddType text/html .cgi

    AddHandler cgi-script .cgi
    #AddHandler perl-script .cgi
    #PerlHandler Apache::Registry

        <Limit GET HEAD POST PUT OPTIONS PROPFIND>
	    Order allow,deny
	    Allow from all
        </Limit>
</Directory>

<Directory "/var/www/html">
    #DAV on
</Directory>

<Directory "/home/*/WWW">
    #DAV on
</Directory>
<Directory "/home/*/public_html">
    #DAV on
</Directory>

# The DAV lock database has to be in a directory writable by the server.
# it is usually DOC_ROOT/var
DAVLockDB /var/www/var/DAVLock

### This stanza describes the normal host.

<VirtualHost _default_:80>

    ### Rewrite Rules:
    #	Minor magic to turn, e.g., /c//Steve into /c/S/St/Steve
    #
    #	Expand the // etc. internally, but make sure we redirect to the
    #	cannonical form externally.
    #
    # NOTE:  These rules have to be inside a VirtualHost in order to work.
    #	     That means we need to put them into an include file.

    RewriteEngine on

    # make net.html the top-level home page
    #RewriteRule ^/$ /net.html

    RewriteMap uc int:toupper
    RewriteMap lc int:tolower

    # redirect index entries back to cannonical 2-slash form:
    # === Might want to also handle ...//...; this only does ...// 
    RewriteRule ^/([^/]+)/[a-zA-Z0-9]/[a-zA-Z0-9][a-zA-Z0-9]/([a-zA-Z0-9]+)/$ \
        /$1//$2/ [R]

    # === Should probably extend this to one-level indices everyplace except
    # === immediately under a single-character top-level directory.

    # Quietly rewrite // -> 2-level index.
    # Note that we uc the first character and lc the second
    # === why do we accept digits here??? === Calendars?  ...//20020313/...
    # === better to simply rewrite 2002-03-13 as 2002/03/13 ===
    RewriteRule ^/([^/]+)//([a-zA-Z])([a-zA-Z])(.*)$ \
    		 /$1/${uc:$2}/${uc:$2}${lc:$3}/$2$3$4
    #RewriteRule ^/([^/]+)//([a-zA-Z])([a-zA-Z])(.*)$  /$1/$2/$2$3/$2$3$4

    DirectoryIndex index.html index.ht /Ccgi/dir-index.cgi

    # This stuff makes view.cgi the handler for .ht and .wt files
    Action processHT /Ccgi/view.cgi
    AddHandler processHT .ht
    AddHandler processHT .wt
    AddType text/html .ht
    AddType text/html .wt

    Script PROPFIND /Ccgi/file.cgi

    SetEnv COMBO_EDIT_URL http://moseisley.thestarport.org:8080

    <Directory "/var/www/html">
        <Limit GET HEAD POST OPTIONS PROPFIND>
	    Order allow,deny
	    Allow from all
        </Limit>
    </Directory>

</VirtualHost>


### This stanza describes the edit host

Listen *:8080
<VirtualHost _default_:8080>
    SetEnv COMBO_EDIT_HOST

    # All file-handling is done using DAV; just need indices for navigation
    # dir-index needs to detect when it's being run on the edit site.
    # maybe we don't need it; just go to controls.
    #DirectoryIndex /Ccgi/dir-index.cgi

    #Action fileHT /Ccgi/file.cgi
    #AddHandler processHT .ht
    #AddHandler processHT .wt
    #AddType text/plain .ht
    #AddType text/plain .wt

    # === text/sgml ???

    SetEnv COMBO_VIEW_URL http://moseisley.thestarport.org

    # Note that this needs to redirect the opposite way from the regular
    # server:  it recognizes // but treats .../X/Xy/... as cannonical
    RewriteRule ^/([^/]+)//([a-zA-Z])([a-zA-Z])(.*)$ \
    		 /$1/${uc:$2}/${uc:$2}${lc:$3}/$2$3$4		[R]

    <Directory "/var/www/html">
        <Limit GET HEAD POST OPTIONS PROPFIND >
	    Order allow,deny
	    Allow from all
        </Limit>

       # === goes into .htaccess files in individual directories!
       #<Limit PUT MKCOL COPY MOVE PROPPATCH >
       #    Order allow,deny
       #    Allow from all (?) 
       #    Require [user]
       #</Limit>
    </Directory>
</VirtualHost>

