[move browsedir into misc thomashartman1@gmail.com**20081004114852] hunk ./src/Controller.hs 157 -browsedir :: String -> ServerPartT IO Response -browsedir d = multi [ - ServerPartT $ \rq -> do - let rqp = ( pathstring $ rqPaths rq ) - if (not $ isInfixOf d rqp) - then noHandle - else do - isDir <- liftIO $ doesDirectoryExist rqp - if isDir - then do - fs <- liftIO $ getDirectoryContents rqp - let fs1 = map g fs - where g f = simpleLink (f,f) - return . toResponse . HtmlString $ concatMap p fs hunk ./src/Controller.hs 158 - else do - isfile <- liftIO $ doesFileExist rqp - f <- liftIO $ readFile rqp - return . toResponse $ f - ] hunk ./src/Controller.hs 160 - + hunk ./src/Controller.hs 173 -ifHaskellFile = spsIf endsInHS - where endsInHS rq = - let url = rqURL rq - extension = drop (length url - 3) url - in extension == ".hs" - +ifHaskellFile = spsIf reqHS + where reqHS rq = isHaskellFile (rqURL rq) hunk ./src/Controller.hs 176 +isHaskellFile :: FilePath -> Bool +isHaskellFile filename = + (drop (length filename - 3) n) == ".hs" + || (drop (length filename - 3) n) == ".lhs" + where n = map toLower filename hunk ./src/Controller.hs 186 --- Windows/Unix/Mac compatible -pathstring pathparts = - let sep :: String - sep = [pathSeparator] - in intercalate sep pathparts + hunk ./src/Misc.hs 177 +browsedir :: String -> ServerPartT IO Response +browsedir d = multi [ + ServerPartT $ \rq -> do + let rqp = ( pathstring $ rqPaths rq ) + if (not $ isInfixOf d rqp) + then noHandle + else do + isDir <- liftIO $ doesDirectoryExist rqp + if isDir + then do + fs <- liftIO $ getDirectoryContents rqp + + let + flinks = map g . filter (not . boringfile ) . sort $ fs + where g f = simpleLink ('/' : (combine rqp f)) f + return . toResponse . HtmlString $ "

" ++ rqp ++ "

\n