1module Text.Hakyll.Render
11import Text.Template hiding (render)
12import qualified Data.ByteString.Lazy.Char8 as B
13import qualified Data.Map as M
16import System.Directory
19import Text.Hakyll.Page
20import Text.Hakyll.Renderable
21import Text.Hakyll.Util
23depends :: FilePath -> [FilePath] -> IO () -> IO ()
24depends file dependencies action = do
25 valid <- isCacheValid (toDestination file) dependencies
28render :: Renderable a => FilePath -> a -> IO Page
29render templatePath renderable = do
30 handle <- openFile templatePath ReadMode
31 templateString <- liftM B.pack $ hGetContents handle
32 seq templateString $ hClose handle
33 context <- toContext renderable
34 let body = substitute templateString context
35 return $ fromContext (M.insert (B.pack "body") body context)
37writePage :: Page -> IO ()
39 let destination = toDestination $ getURL page
40 makeDirectories destination
41 B.writeFile destination (getBody page)
43renderAndConcat :: Renderable a => FilePath -> [a] -> IO B.ByteString
44renderAndConcat templatePath renderables = foldM concatRender' B.empty renderables
45 where concatRender' :: Renderable a => B.ByteString -> a -> IO B.ByteString
46 concatRender' chunk renderable = do
47 rendered <- render templatePath renderable
48 let body = getBody rendered
49 return $ B.append chunk $ body
51renderChain :: Renderable a => [FilePath] -> a -> IO ()
52renderChain templates renderable =
53 depends (getURL renderable) (getDependencies renderable ++ templates) $
54 do initialPage <- toContext renderable
55 result <- foldM (flip render) (fromContext initialPage) templates
58static :: FilePath -> IO ()
60 makeDirectories destination
61 copyFile source destination
62 where destination = toDestination source
64staticDirectory :: FilePath -> IO ()
66 getRecursiveContents dir >>= mapM_ static
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list