Clean up paths
This commit is contained in:
parent
992edea3ee
commit
fa2e3c144a
|
@ -3,34 +3,42 @@ module SiteGenerator (generateSite) where
|
||||||
import Types
|
import Types
|
||||||
import DependencyGenerator
|
import DependencyGenerator
|
||||||
|
|
||||||
thumbnailImageFilename :: Token FilePath -> DepGenM' FilePath
|
thumbnailImagePath :: Token FilePath -> Token FilePath -> DepGenM' FilePath
|
||||||
thumbnailImageFilename filename = do
|
thumbnailImagePath outputDir filename = do
|
||||||
(base, ext) <- untupleDepGenM (fileComponents filename)
|
(base, ext) <- untupleDepGenM (fileComponents filename)
|
||||||
appendStrings (appendStrings (base, inject "-thumbnail."), ext)
|
name <- appendStrings (appendStrings (base, inject "-thumbnail."), ext)
|
||||||
|
joinPaths (outputDir, name)
|
||||||
|
|
||||||
handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> DepGenM ()
|
handleRecipeDir :: Token FilePath -> Token Template -> Token FilePath -> Token FilePath -> DepGenM ()
|
||||||
handleRecipeDir outputDir template dir = do
|
handleRecipeDir outputDir template indexName dir = do
|
||||||
dirContents <- listDirectory dir
|
dirContents <- listDirectory dir
|
||||||
exts <- unzipSndDepGenM (mapDepGenM fileComponents dirContents)
|
exts <- unzipSndDepGenM (mapDepGenM fileComponents dirContents)
|
||||||
areImageFilenames <- mapDepGenM isImageExtension exts
|
areImageFilenames <- mapDepGenM isImageExtension exts
|
||||||
imageFilenames <- filterDepGenM areImageFilenames dirContents
|
imageFilenames <- filterDepGenM areImageFilenames dirContents
|
||||||
thumbnailImageFilenames <- mapDepGenM thumbnailImageFilename imageFilenames
|
imagePaths <- mapDepGenM (curry joinPaths outputDir) imageFilenames
|
||||||
|
thumbnailImagePaths <- mapDepGenM (thumbnailImagePath outputDir) imageFilenames
|
||||||
mapDepGenM_
|
mapDepGenM_
|
||||||
(\files -> convertImage (files, inject $ ResizeToWidth 800))
|
(\files -> convertImage (files, inject $ ResizeToWidth 800))
|
||||||
(ZipToken (imageFilenames, thumbnailImageFilenames))
|
(ZipToken (imagePaths, thumbnailImagePaths))
|
||||||
recipeDirOut <- joinPaths (outputDir, dir)
|
recipeDirOut <- joinPaths (outputDir, dir)
|
||||||
makeDir recipeDirOut
|
makeDir recipeDirOut
|
||||||
htmlBody <- runPandoc (joinPaths (dir, inject "ret.md"))
|
htmlBody <- runPandoc (joinPaths (dir, inject "ret.md"))
|
||||||
html <- applyTemplate (template, htmlBody)
|
html <- applyTemplate (template, htmlBody)
|
||||||
saveFile (html, joinPaths (recipeDirOut, inject "index.html"))
|
saveFile (html, joinPaths (recipeDirOut, indexName))
|
||||||
|
|
||||||
generateSite :: DepGenM ()
|
generateSite :: DepGenM ()
|
||||||
generateSite = do
|
generateSite = do
|
||||||
outputDir <- inject "site"
|
outputDir <- inject "site"
|
||||||
makeDir outputDir
|
makeDir outputDir
|
||||||
|
recipesDir <- inject "retter"
|
||||||
|
outputRecipesDir <- joinPaths (outputDir, recipesDir)
|
||||||
|
makeDir outputRecipesDir
|
||||||
template <- readTemplate (inject "template.html")
|
template <- readTemplate (inject "template.html")
|
||||||
dirContents <- listDirectory (inject "retter")
|
indexName <- inject "index.html"
|
||||||
mapDepGenM_ (handleRecipeDir outputDir template) dirContents
|
dirContents <- listDirectory recipesDir
|
||||||
|
mapDepGenM_ (handleRecipeDir outputRecipesDir template indexName) dirContents
|
||||||
htmlBody <- runPandoc (inject "om.md")
|
htmlBody <- runPandoc (inject "om.md")
|
||||||
html <- applyTemplate (template, htmlBody)
|
html <- applyTemplate (template, htmlBody)
|
||||||
saveFile (html, joinPaths (outputDir, inject "om.html"))
|
aboutDir <- joinPaths (outputDir, inject "om")
|
||||||
|
makeDir aboutDir
|
||||||
|
saveFile (html, joinPaths (aboutDir, indexName))
|
||||||
|
|
Loading…
Reference in New Issue