@@ -63,20 +63,20 @@ removeSpaces = map swap
64-- | Given a path to a file, try to make the path writable by making
64-- | Given a path to a file, try to make the path writable by making
65-- all directories on the path.
65-- all directories on the path.
66−makeDirectories :: FilePath -> IO ()
66+makeDirectories :: FilePath -> Hakyll ()
67−makeDirectories path = createDirectoryIfMissing True dir
67+makeDirectories path = liftIO $ createDirectoryIfMissing True dir
69 dir = takeDirectory path
69 dir = takeDirectory path
71-- | Get all contents of a directory. Note that files starting with a dot (.)
71-- | Get all contents of a directory. Note that files starting with a dot (.)
72-- will be ignored.
72-- will be ignored.
73−getRecursiveContents :: FilePath -> IO [FilePath]
73+getRecursiveContents :: FilePath -> Hakyll [FilePath]
74getRecursiveContents topdir = do
74getRecursiveContents topdir = do
75− names <- getDirectoryContents topdir
75+ names <- liftIO $ getDirectoryContents topdir
76 let properNames = filter isProper names
76 let properNames = filter isProper names
77 paths <- forM properNames $ \name -> do
77 paths <- forM properNames $ \name -> do
78 let path = topdir </> name
78 let path = topdir </> name
79− isDirectory <- doesDirectoryExist path
79+ isDirectory <- liftIO $ doesDirectoryExist path
80 if isDirectory
80 if isDirectory
81 then getRecursiveContents path
81 then getRecursiveContents path
82 else return [path]
82 else return [path]
@@ -87,20 +87,24 @@ getRecursiveContents topdir = do
87-- | A filter that takes all file names with a given extension. Prefix the
87-- | A filter that takes all file names with a given extension. Prefix the
88-- extension with a dot:
88-- extension with a dot:
90−-- > havingExtension ".markdown" ["index.markdown", "style.css"] == ["index.markdown"]
90+-- > havingExtension ".markdown" [ "index.markdown"
92+-- > ] == ["index.markdown"]
91havingExtension :: String -> [FilePath] -> [FilePath]
93havingExtension :: String -> [FilePath] -> [FilePath]
92havingExtension extension = filter ((==) extension . takeExtension)
94havingExtension extension = filter ((==) extension . takeExtension)
94−-- | Perform an IO action on every file in a given directory.
96+-- | Perform a Hakyll action on every file in a given directory.
95directory :: (FilePath -> Hakyll ()) -> FilePath -> Hakyll ()
97directory :: (FilePath -> Hakyll ()) -> FilePath -> Hakyll ()
96directory action dir = do
98directory action dir = do
97− contents <- liftIO $ getRecursiveContents dir
99+ contents <- getRecursiveContents dir
98 mapM_ action contents
100 mapM_ action contents
100-- | Check if a cache file is still valid.
102-- | Check if a cache file is still valid.
101−isCacheValid :: FilePath -> [FilePath] -> IO Bool
103+isCacheValid :: FilePath -> [FilePath] -> Hakyll Bool
102−isCacheValid cache depends = doesFileExist cache >>= \exists ->
104+isCacheValid cache depends = do
105+ exists <- liftIO $ doesFileExist cache
103− if not exists then return False
107+ then return False
104− else do dependsModified <- (mapM getModificationTime depends) >>= return . maximum
108+ else do dependsModified <- liftIO $ mapM getModificationTime depends
105− cacheModified <- getModificationTime cache
109+ cacheModified <- liftIO $ getModificationTime cache
106− return (cacheModified >= dependsModified)
110+ return (cacheModified >= maximum dependsModified)