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
, 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

View File

@ -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

View File

@ -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

View File

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