aboutsummaryrefslogtreecommitdiff
path: root/html-test/accept.hs
diff options
context:
space:
mode:
authorSimon Hengel <sol@typeful.net>2012-10-15 11:24:57 +0200
committerSimon Hengel <sol@typeful.net>2012-10-15 19:32:42 +0200
commit8be6dc23701dcc1387fd56d61ad05df76a88f790 (patch)
treeb1d43f5e2fd53c1310adb2de837ce592fa7028bb /html-test/accept.hs
parentf21570e5526ce564ac8abeff5310cf753f86ffb8 (diff)
Copy css, images, etc. on accept
Diffstat (limited to 'html-test/accept.hs')
-rw-r--r--html-test/accept.hs31
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