@@ -63,20 +63,20 @@ removeSpaces = map swap
6363
6464-- | Given a path to a file, try to make the path writable by making
6565-- all directories on the path.
66−makeDirectories :: FilePath -> IO ()
67−makeDirectories path = createDirectoryIfMissing True dir
66+makeDirectories :: FilePath -> Hakyll ()
67+makeDirectories path = liftIO $ createDirectoryIfMissing True dir
6868 where
6969 dir = takeDirectory path
7070
7171-- | Get all contents of a directory. Note that files starting with a dot (.)
7272-- will be ignored.
73−getRecursiveContents :: FilePath -> IO [FilePath]
73+getRecursiveContents :: FilePath -> Hakyll [FilePath]
7474getRecursiveContents topdir = do
75− names <- getDirectoryContents topdir
75+ names <- liftIO $ getDirectoryContents topdir
7676 let properNames = filter isProper names
7777 paths <- forM properNames $ \name -> do
7878 let path = topdir </> name
79− isDirectory <- doesDirectoryExist path
79+ isDirectory <- liftIO $ doesDirectoryExist path
8080 if isDirectory
8181 then getRecursiveContents path
8282 else return [path]
@@ -87,20 +87,24 @@ getRecursiveContents topdir = do
8787-- | A filter that takes all file names with a given extension. Prefix the
8888-- extension with a dot:
8989--
90−-- > havingExtension ".markdown" ["index.markdown", "style.css"] == ["index.markdown"]
90+-- > havingExtension ".markdown" [ "index.markdown"
91+-- > , "style.css"
92+-- > ] == ["index.markdown"]
9193havingExtension :: String -> [FilePath] -> [FilePath]
9294havingExtension extension = filter ((==) extension . takeExtension)
9395
94−-- | Perform an IO action on every file in a given directory.
96+-- | Perform a Hakyll action on every file in a given directory.
9597directory :: (FilePath -> Hakyll ()) -> FilePath -> Hakyll ()
9698directory action dir = do
97− contents <- liftIO $ getRecursiveContents dir
99+ contents <- getRecursiveContents dir
98100 mapM_ action contents
99101
100102-- | Check if a cache file is still valid.
101−isCacheValid :: FilePath -> [FilePath] -> IO Bool
102−isCacheValid cache depends = doesFileExist cache >>= \exists ->
103− if not exists then return False
104− else do dependsModified <- (mapM getModificationTime depends) >>= return . maximum
105− cacheModified <- getModificationTime cache
106− return (cacheModified >= dependsModified)
103+isCacheValid :: FilePath -> [FilePath] -> Hakyll Bool
104+isCacheValid cache depends = do
105+ exists <- liftIO $ doesFileExist cache
106+ if not exists
107+ then return False
108+ else do dependsModified <- liftIO $ mapM getModificationTime depends
109+ cacheModified <- liftIO $ getModificationTime cache
110+ return (cacheModified >= maximum dependsModified)