module Dir (createDirListing) where import System.Directory import Response import Config -- XXX is_head? content_type? last_modified? -- XXX move elsewhere! -- perhaps it would be best to return a ResponseBody here and -- let the upper layers handle the rest? createDirListing :: String -> String -> IO (ResponseBody,String) createDirListing urlpath dir = do fs <- getDirectoryContents dir let l = htmlFiles [f | f <- fs, (head f) /= '.'] title = "Directory " ++ urlpath -- XXX html quoted! parent = "Parent Directory\n" s = sec title (parent ++ l) p = page title s return (HereItIs p, contentTypeHeader "text/html") -- XXX this should probably be elsewhere htmlFiles fs = unlines (["