1
0

Go a more direct route with the recipes dirs

Este cometimento está contido em:
Niels G. W. Serup 2024-10-05 20:35:34 +02:00
ascendente 9240d66c15
cometimento 90a968ea7d
Não foi encontrada uma chave conhecida para esta assinatura, na base de dados
ID da chave GPG: 38EEEBCE67324F19

Ver ficheiro

@ -29,10 +29,9 @@ hasExtension exts filename = do
ext <- lowerString $ untupleSndDepGenM $ fileComponents filename ext <- lowerString $ untupleSndDepGenM $ fileComponents filename
ext `elemOf` exts ext `elemOf` exts
handleRecipeDir :: Token FilePath -> Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM () handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM ()
handleRecipeDir inputDir outputDir template indexName name = do handleRecipeDir outputDir template indexName dir = do
dir <- joinPaths inputDir name recipeDirOut <- joinPaths outputDir dir
recipeDirOut <- joinPaths outputDir name
makeDir recipeDirOut makeDir recipeDirOut
dirContents <- listDirectory dir dirContents <- listDirectory dir
areImageFilenames <- mapDepGenM (hasExtension $ inject ["jpg"]) dirContents areImageFilenames <- mapDepGenM (hasExtension $ inject ["jpg"]) dirContents
@ -65,15 +64,14 @@ generateSite = do
outputDir <- inject "site" outputDir <- inject "site"
makeDir outputDir makeDir outputDir
recipesDir <- inject "retter" recipesDir <- inject "retter"
outputRecipesDir <- joinPaths outputDir recipesDir makeDir $ joinPaths outputDir recipesDir
makeDir outputRecipesDir
template <- makeTemplate (readTextFile (inject "template.html")) (inject "CONTENT") template <- makeTemplate (readTextFile (inject "template.html")) (inject "CONTENT")
indexName <- inject "index.html" indexName <- inject "index.html"
dirNames <- listDirectory recipesDir dirNames <- listDirectory recipesDir
dirPaths <- mapDepGenM (joinPaths recipesDir) dirNames dirPaths <- mapDepGenM (joinPaths recipesDir) dirNames
dirPathsAreSubdirs <- mapDepGenM isDirectory dirPaths dirPathsAreSubdirs <- mapDepGenM isDirectory dirPaths
dirNames' <- filterDepGenM dirPathsAreSubdirs dirNames dirPaths' <- filterDepGenM dirPathsAreSubdirs dirPaths
mapDepGenM_ (handleRecipeDir recipesDir outputRecipesDir template indexName) dirNames' mapDepGenM_ (handleRecipeDir outputDir template indexName) dirPaths'
html <- applyTemplate template $ runPandoc $ readTextFile $ inject "om.md" html <- applyTemplate template $ runPandoc $ readTextFile $ inject "om.md"
aboutDir <- joinPaths outputDir $ inject "om" aboutDir <- joinPaths outputDir $ inject "om"
makeDir aboutDir makeDir aboutDir