2024-09-11 22:32:14 +02:00
|
|
|
module Main where
|
|
|
|
|
2024-09-21 23:11:31 +02:00
|
|
|
import Types
|
2024-09-21 17:13:20 +02:00
|
|
|
import ComputationM
|
2024-09-21 20:00:59 +02:00
|
|
|
import Functions
|
2024-09-21 16:35:13 +02:00
|
|
|
|
2024-09-21 23:21:47 +02:00
|
|
|
handleRecipeDir :: Token Template -> Token FilePath -> ComputationM ()
|
|
|
|
handleRecipeDir template dir = do
|
2024-09-21 22:40:17 +02:00
|
|
|
dirContents <- listDirectory dir
|
|
|
|
imageFilenames <- filterComputationM isImageFilename dirContents
|
2024-09-21 23:11:31 +02:00
|
|
|
convertedImageFilenames <- mapComputationM convertedImageFilename imageFilenames
|
|
|
|
flip mapComputationM_ (zipTokens imageFilenames convertedImageFilenames) $ \files -> do
|
|
|
|
settings <- inject $ ResizeToWidth 800
|
|
|
|
convertImage $ tupleTokens files settings
|
2024-09-21 22:40:17 +02:00
|
|
|
|
2024-09-21 18:49:50 +02:00
|
|
|
test :: ComputationM ()
|
2024-09-21 16:35:13 +02:00
|
|
|
test = do
|
2024-09-21 23:21:47 +02:00
|
|
|
templateFilename <- inject "template.html"
|
|
|
|
template <- readTemplate templateFilename
|
2024-09-21 16:35:13 +02:00
|
|
|
dir <- inject "retter"
|
2024-09-21 17:41:04 +02:00
|
|
|
dirContents <- listDirectory dir
|
2024-09-21 23:21:47 +02:00
|
|
|
mapComputationM_ (handleRecipeDir template) dirContents
|
2024-09-21 16:35:13 +02:00
|
|
|
|
2024-09-11 22:32:14 +02:00
|
|
|
main :: IO ()
|
2024-09-21 17:13:20 +02:00
|
|
|
main = mapM_ print $ evalComputationM test
|