diff options
Diffstat (limited to 'html-test/accept.hs')
-rw-r--r-- | html-test/accept.hs | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/html-test/accept.hs b/html-test/accept.hs index 82eb3c65..4722dbf9 100644 --- a/html-test/accept.hs +++ b/html-test/accept.hs @@ -1,38 +1,39 @@ import System.Cmd import System.Environment import System.FilePath -import System.Exit import System.Directory import Data.List -import Control.Monad import Control.Applicative - +main :: IO () main = do args <- getArgs dir <- getCurrentDirectory contents <- filter (`notElem` ignore) <$> getDirectoryContents (dir </> "output") - if not $ null args - then - mapM_ copy [ "output" </> file | file <- contents, ".html" `isSuffixOf` file, takeBaseName file `elem` args ] - else - mapM_ copy [ "output" </> file | file <- contents, ".html" `isSuffixOf` file ] + if not $ null args then + mapM_ copy [ "output" </> file | file <- contents, ".html" `isSuffixOf` file, takeBaseName file `elem` args ] + else + mapM_ copy [ "output" </> file | file <- contents] where ignore = [ - "doc-index.html" + "." + , ".." + , "doc-index.html" , "index-frames.html" , "index.html" ] - +copy :: FilePath -> IO () copy file = do let new = "ref" </> takeFileName file - print file - print new - contents <- readFile file - writeFile new (stripLinks contents) - + if ".html" `isSuffixOf` file then do + putStrLn (file ++ " -> " ++ new) + stripLinks <$> readFile file >>= writeFile new + else do + -- copy css, images, etc. + copyFile file new +stripLinks :: String -> String stripLinks str = let prefix = "<a href=\"" in case stripPrefix prefix str of |