This commit is contained in:
Niels G. W. Serup 2024-09-24 22:38:52 +02:00
parent 6ebc3f5e3a
commit 67bfa01b67
No known key found for this signature in database
GPG Key ID: 38EEEBCE67324F19
4 changed files with 14 additions and 0 deletions

View File

@ -14,6 +14,7 @@ module DependencyGenerator
, readTemplate , readTemplate
, convertImage , convertImage
, saveFile , saveFile
, makeDir
, runPandoc , runPandoc
) where ) where
@ -110,5 +111,8 @@ convertImage = runFunctionIO ConvertImage
saveFile :: Token (String, FilePath) -> DepGenM () saveFile :: Token (String, FilePath) -> DepGenM ()
saveFile = runFunctionIO SaveFile saveFile = runFunctionIO SaveFile
makeDir :: Token FilePath -> DepGenM ()
makeDir = runFunctionIO MakeDir
runPandoc :: Token (FilePath, FilePath) -> DepGenM () runPandoc :: Token (FilePath, FilePath) -> DepGenM ()
runPandoc = runFunctionIO RunPandoc runPandoc = runFunctionIO RunPandoc

View File

@ -18,6 +18,9 @@ evalFunctionIO f x = case (f, x) of
(SaveFile, Tuple (String _, String _)) -> (SaveFile, Tuple (String _, String _)) ->
pure $ Empty pure $ Empty
(MakeDir, String _) ->
pure $ Empty
(RunPandoc, Tuple (String _, String _)) -> (RunPandoc, Tuple (String _, String _)) ->
pure $ Empty pure $ Empty

View File

@ -11,12 +11,18 @@ handleRecipeDir _template dir = do
flip mapDepGenM_ (ZipToken imageFilenames convertedImageFilenames) $ \files -> do flip mapDepGenM_ (ZipToken imageFilenames convertedImageFilenames) $ \files -> do
settings <- inject $ ResizeToWidth 800 settings <- inject $ ResizeToWidth 800
convertImage $ TupleToken files settings convertImage $ TupleToken files settings
pure NoToken
generateSite :: DepGenM () generateSite :: DepGenM ()
generateSite = do generateSite = do
outputDir <- inject "site"
makeDir outputDir
templateFilename <- inject "template.html" templateFilename <- inject "template.html"
template <- readTemplate templateFilename template <- readTemplate templateFilename
dir <- inject "retter" dir <- inject "retter"
dirContents <- listDirectory dir dirContents <- listDirectory dir
mapDepGenM_ (handleRecipeDir template) dirContents mapDepGenM_ (handleRecipeDir template) dirContents
aboutFilenameIn <- inject "om.md"
aboutFilenameOut <- inject "om.html"
runPandoc $ TupleToken aboutFilenameIn aboutFilenameOut

View File

@ -8,5 +8,6 @@ data FunctionIO = ListDirectory
| ReadTemplate | ReadTemplate
| ConvertImage | ConvertImage
| SaveFile | SaveFile
| MakeDir
| RunPandoc | RunPandoc
deriving (Show, Lift) deriving (Show, Lift)