Fixed some more issues.

This commit is contained in:
Jasper Van der Jeugt 2009-12-02 16:23:21 +01:00
parent f716440837
commit 1db2e00bbb
3 changed files with 6 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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