A static site generator written in Haskell
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

Read.hs 1.2KB

12345678910111213141516171819202122232425262728
  1. module Read where
  2. import System.Directory ( listDirectory )
  3. import System.FilePath ( FilePath )
  4. import Build ( buildRawPost )
  5. import Post ( RawPost )
  6. import Utils ( makeFullFilePath )
  7. readPostTemplate :: FilePath -> IO String
  8. readPostTemplate root = readFile $ root ++ "/templates/_post.html"
  9. readIndexTemplate :: FilePath -> IO String
  10. readIndexTemplate root = readFile $ root ++ "/templates/_index.html"
  11. readRSSTemplate :: FilePath -> IO String
  12. readRSSTemplate root = readFile $ root ++ "/templates/_rss.xml"
  13. readPostContents :: String -> Bool -> IO [RawPost]
  14. readPostContents root drafts = do
  15. postsPath <- makeFullFilePath root "posts"
  16. draftsPath <- makeFullFilePath root "drafts"
  17. postPaths <- listDirectory postsPath
  18. draftPaths <- listDirectory draftsPath
  19. absoluteDraftPaths <- mapM (makeFullFilePath draftsPath) draftPaths
  20. absolutePostPaths <- mapM (makeFullFilePath postsPath) postPaths
  21. mapM buildRawPost
  22. (absolutePostPaths ++ if drafts then absoluteDraftPaths else [])