A static site generator written in Haskell
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

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 [])