diff --git a/byg/src/DependencyGenerator.hs b/byg/src/DependencyGenerator.hs index be1c392..bfb2704 100644 --- a/byg/src/DependencyGenerator.hs +++ b/byg/src/DependencyGenerator.hs @@ -15,7 +15,7 @@ module DependencyGenerator , joinPaths , fileComponents - , isImageFilename + , isImageExtension , convertedImageFilename , applyTemplate , listDirectory @@ -97,10 +97,9 @@ mapDepGenM_ f input = do _ <- mapDepGenM (\x -> f x >> pure NoToken) input pure () -filterDepGenM :: (Token a -> DepGenM' Bool) -> Token [a] -> DepGenM' [a] -filterDepGenM f input = do - conds <- mapDepGenM f input - genDependency (makeDependency (TupleToken (input, conds)) FilterComp) +filterDepGenM :: Token [Bool] -> Token [a] -> DepGenM' [a] +filterDepGenM mask input = do + genDependency (makeDependency (TupleToken (input, mask)) FilterComp) unzipFstDepGenM :: TokenableTo [(a, b)] t => t -> DepGenM (Token [a]) unzipFstDepGenM t = do @@ -141,8 +140,8 @@ joinPaths (a, b) = do fileComponents :: TokenableTo FilePath a => a -> DepGenM' (String, String) fileComponents a = runFunction FileComponents =<< toToken a -isImageFilename :: TokenableTo FilePath a => a -> DepGenM' Bool -isImageFilename a = runFunction IsImageFilename =<< toToken a +isImageExtension :: TokenableTo FilePath a => a -> DepGenM' Bool +isImageExtension a = runFunction IsImageExtension =<< toToken a convertedImageFilename :: TokenableTo FilePath a => a -> DepGenM' FilePath convertedImageFilename a = runFunction ConvertedImageFilename =<< toToken a diff --git a/byg/src/Evaluation/Function.hs b/byg/src/Evaluation/Function.hs index efe27d4..81fbeff 100644 --- a/byg/src/Evaluation/Function.hs +++ b/byg/src/Evaluation/Function.hs @@ -9,7 +9,7 @@ evalFunction f x = case (f, x) of (JoinPaths, Tuple (String _, String _)) -> String undefined - (IsImageFilename, String _) -> + (IsImageExtension, String _) -> Bool undefined (ConvertedImageFilename, String _) -> diff --git a/byg/src/SiteGenerator.hs b/byg/src/SiteGenerator.hs index 23394de..833b13b 100644 --- a/byg/src/SiteGenerator.hs +++ b/byg/src/SiteGenerator.hs @@ -7,7 +7,8 @@ handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> DepGenM handleRecipeDir outputDir template dir = do dirContents <- listDirectory dir (bases, exts) <- unzipDepGenM (mapDepGenM fileComponents dirContents) - imageFilenames <- filterDepGenM isImageFilename dirContents + areImageFilenames <- mapDepGenM isImageExtension exts + imageFilenames <- filterDepGenM areImageFilenames dirContents convertedImageFilenames <- mapDepGenM convertedImageFilename imageFilenames mapDepGenM_ (\files -> convertImage (files, inject $ ResizeToWidth 800)) diff --git a/byg/src/Types/Function.hs b/byg/src/Types/Function.hs index f7ff953..8921677 100644 --- a/byg/src/Types/Function.hs +++ b/byg/src/Types/Function.hs @@ -6,7 +6,7 @@ import Language.Haskell.TH.Syntax (Lift) data Function = JoinPaths | FileComponents - | IsImageFilename + | IsImageExtension | ConvertedImageFilename | ApplyTemplate deriving (Show, Lift)