From 1db2e00bbb813795cf858f69c21fa6c6837091a0 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 2 Dec 2009 16:23:21 +0100 Subject: Fixed some more issues. --- src/Text/Hakyll/Page.hs | 2 +- src/Text/Hakyll/Render.hs | 4 +++- src/Text/Hakyll/Util.hs | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src/Text') diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs index 55e94c2..7e9a76e 100644 --- a/src/Text/Hakyll/Page.hs +++ b/src/Text/Hakyll/Page.hs @@ -17,7 +17,7 @@ import Text.Pandoc type Page = M.Map String String addContext :: String -> String -> Page -> Page -addContext key value = M.insert key value +addContext = M.insert getURL :: Page -> String getURL context = fromMaybe "404.html" $ M.lookup "url" context diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs index 89e6a7c..a36ff7c 100644 --- a/src/Text/Hakyll/Render.hs +++ b/src/Text/Hakyll/Render.hs @@ -32,7 +32,9 @@ renderPage templatePath page = do renderAndWrite :: FilePath -> Page -> IO () renderAndWrite templatePath page = do rendered <- renderPage templatePath page - writeFile (toDestination $ getURL rendered) (getBody rendered) + let destination = toDestination $ getURL rendered + touchDirectories destination + writeFile destination (getBody rendered) static :: FilePath -> IO () static source = do diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs index 3f56a18..f5a9954 100644 --- a/src/Text/Hakyll/Util.hs +++ b/src/Text/Hakyll/Util.hs @@ -14,7 +14,7 @@ touchDirectories path = createDirectoryIfMissing True dir getRecursiveContents :: FilePath -> IO [FilePath] getRecursiveContents topdir = do names <- getDirectoryContents topdir - let properNames = filter (`notElem` [".", ".."]) names + let properNames = filter isProper names paths <- forM properNames $ \name -> do let path = topdir name isDirectory <- doesDirectoryExist path @@ -22,3 +22,4 @@ getRecursiveContents topdir = do then getRecursiveContents path else return [path] return (concat paths) + where isProper = not . (== '.') . head -- cgit v1.2.3