diff --git a/byg/src/DependencyGenerator.hs b/byg/src/DependencyGenerator.hs index 6d3ab1d..b7dd983 100644 --- a/byg/src/DependencyGenerator.hs +++ b/byg/src/DependencyGenerator.hs @@ -25,6 +25,7 @@ module DependencyGenerator , readTemplate , convertImage , saveFile + , copyFile , makeDir , runPandoc ) where @@ -197,6 +198,12 @@ saveFile (a, b) = do b' <- toToken b runFunctionIO' SaveFile $ TupleToken (a', b') +copyFile :: (TokenableTo FilePath a, TokenableTo FilePath b) => (a, b) -> DepGenM () +copyFile (a, b) = do + a' <- toToken a + b' <- toToken b + runFunctionIO' CopyFile $ TupleToken (a', b') + makeDir :: TokenableTo FilePath a => a -> DepGenM () makeDir a = runFunctionIO' MakeDir =<< toToken a diff --git a/byg/src/Evaluation/FunctionIO.hs b/byg/src/Evaluation/FunctionIO.hs index 05f3e31..bcd7cbb 100644 --- a/byg/src/Evaluation/FunctionIO.hs +++ b/byg/src/Evaluation/FunctionIO.hs @@ -18,6 +18,9 @@ evalFunctionIO f x = case (f, x) of (SaveFile, Tuple (String _, String _)) -> pure $ Empty + (CopyFile, Tuple (String _, String _)) -> + pure $ Empty + (MakeDir, String _) -> pure $ Empty diff --git a/byg/src/SiteGenerator.hs b/byg/src/SiteGenerator.hs index e0ba404..20b2de3 100644 --- a/byg/src/SiteGenerator.hs +++ b/byg/src/SiteGenerator.hs @@ -15,7 +15,9 @@ handleRecipeDir outputDir template indexName dir = do exts <- unzipSndDepGenM (mapDepGenM fileComponents dirContents) areImageFilenames <- mapDepGenM isImageExtension exts imageFilenames <- filterDepGenM areImageFilenames dirContents - imagePaths <- mapDepGenM (curry joinPaths outputDir) imageFilenames + imagePaths <- mapDepGenM (curry joinPaths dir) imageFilenames + imagePathsOut <- mapDepGenM (curry joinPaths outputDir) imageFilenames + mapDepGenM_ ((copyFile =<<) . untupleDepGenM) (ZipToken (imagePaths, imagePathsOut)) thumbnailImagePaths <- mapDepGenM (thumbnailImagePath outputDir) imageFilenames mapDepGenM_ (\files -> convertImage (files, inject $ ResizeToWidth 800)) diff --git a/byg/src/Types/FunctionIO.hs b/byg/src/Types/FunctionIO.hs index ce6ab2e..24276f9 100644 --- a/byg/src/Types/FunctionIO.hs +++ b/byg/src/Types/FunctionIO.hs @@ -8,6 +8,7 @@ data FunctionIO = ListDirectory | ReadTemplate | ConvertImage | SaveFile + | CopyFile | MakeDir | RunPandoc deriving (Show, Lift)