2024-09-23 22:11:54 +02:00
|
|
|
module SiteGenerator (generateSite) where
|
|
|
|
|
|
|
|
import Types
|
|
|
|
import DependencyGenerator
|
|
|
|
|
2024-09-25 19:37:49 +02:00
|
|
|
handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> DepGenM ()
|
|
|
|
handleRecipeDir outputDir template dir = do
|
2024-09-23 22:11:54 +02:00
|
|
|
dirContents <- listDirectory dir
|
2024-09-25 23:06:53 +02:00
|
|
|
(bases, exts) <- unzipDepGenM (mapDepGenM fileComponents dirContents)
|
2024-09-23 22:11:54 +02:00
|
|
|
imageFilenames <- filterDepGenM isImageFilename dirContents
|
|
|
|
convertedImageFilenames <- mapDepGenM convertedImageFilename imageFilenames
|
2024-09-25 22:09:26 +02:00
|
|
|
mapDepGenM_
|
|
|
|
(\files -> convertImage (files, inject $ ResizeToWidth 800))
|
|
|
|
(ZipToken (imageFilenames, convertedImageFilenames))
|
2024-09-25 19:48:45 +02:00
|
|
|
recipeDirOut <- joinPaths (outputDir, dir)
|
2024-09-25 19:37:49 +02:00
|
|
|
makeDir recipeDirOut
|
2024-09-25 22:09:26 +02:00
|
|
|
htmlBody <- runPandoc (joinPaths (dir, inject "ret.md"))
|
2024-09-25 19:48:45 +02:00
|
|
|
html <- applyTemplate (template, htmlBody)
|
2024-09-25 22:09:26 +02:00
|
|
|
saveFile (html, joinPaths (recipeDirOut, inject "index.html"))
|
2024-09-23 22:11:54 +02:00
|
|
|
|
2024-09-24 23:09:35 +02:00
|
|
|
generateSite :: DepGenM ()
|
2024-09-23 22:11:54 +02:00
|
|
|
generateSite = do
|
2024-09-24 22:38:52 +02:00
|
|
|
outputDir <- inject "site"
|
|
|
|
makeDir outputDir
|
2024-09-25 22:09:26 +02:00
|
|
|
template <- readTemplate (inject "template.html")
|
|
|
|
dirContents <- listDirectory (inject "retter")
|
2024-09-25 19:37:49 +02:00
|
|
|
mapDepGenM_ (handleRecipeDir outputDir template) dirContents
|
2024-09-25 22:09:26 +02:00
|
|
|
htmlBody <- runPandoc (inject "om.md")
|
|
|
|
html <- applyTemplate (template, htmlBody)
|
|
|
|
saveFile (html, joinPaths (outputDir, inject "om.html"))
|