summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-02 14:34:50 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2009-12-02 14:34:50 +0100
commitf716440837521c192eeccdb95f210ff8b917db13 (patch)
tree8cb511db9575d2af5d5378143b2215628be5f0b3 /src
parent36e4bf881b707948835bbae284ac444c80c67cc2 (diff)
downloadhakyll-f716440837521c192eeccdb95f210ff8b917db13.tar.gz
Better module definitions.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Hakyll/Page.hs17
-rw-r--r--src/Text/Hakyll/Render.hs11
-rw-r--r--src/Text/Hakyll/Util.hs5
3 files changed, 27 insertions, 6 deletions
diff --git a/src/Text/Hakyll/Page.hs b/src/Text/Hakyll/Page.hs
index 6dc96aa..55e94c2 100644
--- a/src/Text/Hakyll/Page.hs
+++ b/src/Text/Hakyll/Page.hs
@@ -1,4 +1,12 @@
-module Text.Hakyll.Page where
+module Text.Hakyll.Page
+ ( Page,
+ addContext,
+ getURL,
+ getBody,
+ readPage,
+ pageFromList,
+ concatPages
+ ) where
import qualified Data.Map as M
import qualified Data.List as L
@@ -18,7 +26,7 @@ getBody :: Page -> String
getBody context = fromMaybe "" $ M.lookup "body" context
readConfig :: [String] -> Page
-readConfig lines = M.fromList $ map (trim . break (== ':')) lines
+readConfig = M.fromList . map (trim . break (== ':'))
where trim (key, value) = (key, dropWhile (`elem` ": ") value)
extractContext :: String -> Page
@@ -45,3 +53,8 @@ readPage path = do
url = addExtension (dropExtension path) ".html"
return $ addContext "url" url $ addContext "body" body $ context
+pageFromList :: [(String, String)] -> Page
+pageFromList = M.fromList
+
+concatPages :: [Page] -> String
+concatPages = concat . map getBody
diff --git a/src/Text/Hakyll/Render.hs b/src/Text/Hakyll/Render.hs
index 3e17659..89e6a7c 100644
--- a/src/Text/Hakyll/Render.hs
+++ b/src/Text/Hakyll/Render.hs
@@ -1,4 +1,9 @@
-module Text.Hakyll.Render where
+module Text.Hakyll.Render
+ ( renderPage,
+ renderAndWrite,
+ static,
+ staticDirectory
+ ) where
import Text.Template
import qualified Data.ByteString.Lazy.Char8 as B
@@ -20,8 +25,8 @@ createContext = M.fromList . map packPair . M.toList
renderPage :: FilePath -> Page -> IO Page
renderPage templatePath page = do
- template <- B.readFile templatePath
- let body = substitute template (createContext page)
+ templateString <- B.readFile templatePath
+ let body = substitute templateString (createContext page)
return $ addContext "body" (B.unpack body) page
renderAndWrite :: FilePath -> Page -> IO ()
diff --git a/src/Text/Hakyll/Util.hs b/src/Text/Hakyll/Util.hs
index 1b24d31..3f56a18 100644
--- a/src/Text/Hakyll/Util.hs
+++ b/src/Text/Hakyll/Util.hs
@@ -1,4 +1,7 @@
-module Text.Hakyll.Util where
+module Text.Hakyll.Util
+ ( touchDirectories,
+ getRecursiveContents
+ ) where
import System.Directory
import System.FilePath