12345678910111213141516171819202122232425262728 |
- module Read where
-
- import System.Directory ( listDirectory )
- import System.FilePath ( FilePath )
-
- import Build ( buildRawPost )
- import Post ( RawPost )
- import Utils ( makeFullFilePath )
-
- readPostTemplate :: FilePath -> IO String
- readPostTemplate root = readFile $ root ++ "/templates/_post.html"
-
- readIndexTemplate :: FilePath -> IO String
- readIndexTemplate root = readFile $ root ++ "/templates/_index.html"
-
- readRSSTemplate :: FilePath -> IO String
- readRSSTemplate root = readFile $ root ++ "/templates/_rss.xml"
-
- readPostContents :: String -> Bool -> IO [RawPost]
- readPostContents root drafts = do
- postsPath <- makeFullFilePath root "posts"
- draftsPath <- makeFullFilePath root "drafts"
- postPaths <- listDirectory postsPath
- draftPaths <- listDirectory draftsPath
- absoluteDraftPaths <- mapM (makeFullFilePath draftsPath) draftPaths
- absolutePostPaths <- mapM (makeFullFilePath postsPath) postPaths
- mapM buildRawPost
- (absolutePostPaths ++ if drafts then absoluteDraftPaths else [])
|