#!/bin/rc
rfork e
w=`{basename -d $"request}
f=`{basename $"request}
echo '<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>'$w'</title>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>
<body>
<img src="/image/logo.png" alt="Logo" style="float:right;margin-right:0">
<img src="/image/addr.png" alt="address" style="float:right;margin-left:0">
<h1>'$w'</h1>'
if(test -e README){
	echo '<h3>README</h3>
	<pre>'
	cat README
	echo '</pre><p><hr>'
	}
if(test -e INDEX){
	awk 'BEGIN{print "<h3>INDEX</h3>\n<dl>"}
	/^[\t ].+/{printf "%s<br>\n", $0; next}
	/.+/{printf "<dt><a href=\"%s\">%s</a>\n<dd>", $1, $1}
	END{print "</dl>"}' INDEX
	}
if not if(test -e /doc$w){
	echo '<h3>Contents</h3><pre>'
	ls  -l | awk '{
	if(substr($1,1,1) == "d")
		printf "%10d <a href=\"%s/\">%s/</a>\n", 0, $10, $10
	else if(substr($10,1,1) != ".")
		printf "%10d <a href=\"%s\">%s</a>\n", $6, $10, $10
	}'
	echo '</pre>'
	}
echo '</body></html>'
