From 67bfa01b676c87e4e52d16ccd9cf831aa3b29e4c Mon Sep 17 00:00:00 2001 From: "Niels G. W. Serup" Date: Tue, 24 Sep 2024 22:38:52 +0200 Subject: [PATCH] MakeDir --- byg/src/DependencyGenerator.hs | 4 ++++ byg/src/Evaluation/FunctionIO.hs | 3 +++ byg/src/SiteGenerator.hs | 6 ++++++ byg/src/Types/FunctionIO.hs | 1 + 4 files changed, 14 insertions(+) diff --git a/byg/src/DependencyGenerator.hs b/byg/src/DependencyGenerator.hs index f32e38a..d29c429 100644 --- a/byg/src/DependencyGenerator.hs +++ b/byg/src/DependencyGenerator.hs @@ -14,6 +14,7 @@ module DependencyGenerator , readTemplate , convertImage , saveFile + , makeDir , runPandoc ) where @@ -110,5 +111,8 @@ convertImage = runFunctionIO ConvertImage saveFile :: Token (String, FilePath) -> DepGenM () saveFile = runFunctionIO SaveFile +makeDir :: Token FilePath -> DepGenM () +makeDir = runFunctionIO MakeDir + runPandoc :: Token (FilePath, FilePath) -> DepGenM () runPandoc = runFunctionIO RunPandoc diff --git a/byg/src/Evaluation/FunctionIO.hs b/byg/src/Evaluation/FunctionIO.hs index d285c58..2391cb7 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 + (MakeDir, String _) -> + pure $ Empty + (RunPandoc, Tuple (String _, String _)) -> pure $ Empty diff --git a/byg/src/SiteGenerator.hs b/byg/src/SiteGenerator.hs index 7a4962b..d4bf9ce 100644 --- a/byg/src/SiteGenerator.hs +++ b/byg/src/SiteGenerator.hs @@ -11,12 +11,18 @@ handleRecipeDir _template dir = do flip mapDepGenM_ (ZipToken imageFilenames convertedImageFilenames) $ \files -> do settings <- inject $ ResizeToWidth 800 convertImage $ TupleToken files settings + pure NoToken generateSite :: DepGenM () generateSite = do + outputDir <- inject "site" + makeDir outputDir templateFilename <- inject "template.html" template <- readTemplate templateFilename dir <- inject "retter" dirContents <- listDirectory dir mapDepGenM_ (handleRecipeDir template) dirContents + aboutFilenameIn <- inject "om.md" + aboutFilenameOut <- inject "om.html" + runPandoc $ TupleToken aboutFilenameIn aboutFilenameOut diff --git a/byg/src/Types/FunctionIO.hs b/byg/src/Types/FunctionIO.hs index ef4c051..ce6ab2e 100644 --- a/byg/src/Types/FunctionIO.hs +++ b/byg/src/Types/FunctionIO.hs @@ -8,5 +8,6 @@ data FunctionIO = ListDirectory | ReadTemplate | ConvertImage | SaveFile + | MakeDir | RunPandoc deriving (Show, Lift)