diff --git a/byg/src/DependencyGenerator.hs b/byg/src/DependencyGenerator.hs index c02365e..d772ba5 100644 --- a/byg/src/DependencyGenerator.hs +++ b/byg/src/DependencyGenerator.hs @@ -11,6 +11,7 @@ module DependencyGenerator , mapDepGenM , mapDepGenM_ , filterDepGenM + , filterDepGenM' , zipDepGenM , untupleFstDepGenM , untupleSndDepGenM @@ -133,11 +134,16 @@ mapDepGenM_ f input = do _ <- mapDepGenM (\x -> f x >> pure NoToken) input pure () -filterDepGenM :: (TokenableTo [Bool] v, TokenableTo [a] u) => v -> u -> DepGenM' [a] -filterDepGenM mask input = do +filterDepGenM' :: (TokenableTo [Bool] v, TokenableTo [a] u) => v -> u -> DepGenM' [a] +filterDepGenM' mask input = do tup <- toTupleToken input mask genDependency (makeDependency tup FilterComp) +filterDepGenM :: TokenableTo [a] v => (Token a -> DepGenM' Bool) -> v -> DepGenM' [a] +filterDepGenM f input = do + mask <- mapDepGenM f input + filterDepGenM' mask input + zipDepGenM :: (TokenableTo [a] v, TokenableTo [b] u) => v -> u -> DepGenM' [(a, b)] zipDepGenM a b = do a' <- toToken a diff --git a/byg/src/SiteGenerator.hs b/byg/src/SiteGenerator.hs index 0a60254..72e4823 100644 --- a/byg/src/SiteGenerator.hs +++ b/byg/src/SiteGenerator.hs @@ -34,8 +34,7 @@ handleRecipeDir outputDir template indexName dir = do recipeDirOut <- joinPaths outputDir dir makeDir recipeDirOut dirContents <- listDirectory dir - areImageFilenames <- mapDepGenM (hasExtension $ inject ["jpg"]) dirContents - imageFilenames <- filterDepGenM areImageFilenames dirContents + imageFilenames <- filterDepGenM (hasExtension $ inject ["jpg"]) dirContents imagePaths <- mapDepGenM (joinPaths dir) imageFilenames imagePathsOut <- mapDepGenM (joinPaths recipeDirOut) imageFilenames mapDepGenM_ copyFile' $ zipDepGenM imagePaths imagePathsOut @@ -69,8 +68,7 @@ generateSite = do indexName <- inject "index.html" dirNames <- listDirectory recipesDir dirPaths <- mapDepGenM (joinPaths recipesDir) dirNames - dirPathsAreSubdirs <- mapDepGenM isDirectory dirPaths - dirPaths' <- filterDepGenM dirPathsAreSubdirs dirPaths + dirPaths' <- filterDepGenM isDirectory dirPaths mapDepGenM_ (handleRecipeDir outputDir template indexName) dirPaths' html <- applyTemplate template $ runPandoc $ readTextFile $ inject "om.md" aboutDir <- joinPaths outputDir $ inject "om" @@ -87,8 +85,7 @@ generateSite = do fontsDir <- inject "fonts" fontsNames <- listDirectory fontsDir fontsPaths <- mapDepGenM (joinPaths fontsDir) fontsNames - fontsPathsAreSubdirs <- mapDepGenM isDirectory fontsPaths - fontsPaths' <- filterDepGenM fontsPathsAreSubdirs fontsPaths + fontsPaths' <- filterDepGenM isDirectory fontsPaths makeDir (joinPaths outputDir fontsDir) mapDepGenM_ (handleFontDir outputDir) fontsPaths' @@ -97,6 +94,5 @@ handleFontDir outputDir fontPath = do makeDir (joinPaths outputDir fontPath) files <- listDirectory fontPath paths <- mapDepGenM (joinPaths fontPath) files - mask <- mapDepGenM (hasExtension $ inject ["woff2", "css"]) paths - paths' <- filterDepGenM mask paths + paths' <- filterDepGenM (hasExtension $ inject ["woff2", "css"]) paths mapDepGenM_ (\p -> copyFile p (joinPaths outputDir p)) paths'