diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-02 14:34:50 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2009-12-02 14:34:50 +0100 |
commit | f716440837521c192eeccdb95f210ff8b917db13 (patch) | |
tree | 8cb511db9575d2af5d5378143b2215628be5f0b3 | |
parent | 36e4bf881b707948835bbae284ac444c80c67cc2 (diff) | |
download | hakyll-f716440837521c192eeccdb95f210ff8b917db13.tar.gz |
Better module definitions.
-rw-r--r-- | hakyll.cabal | 4 | ||||
-rw-r--r-- | src/Text/Hakyll/Page.hs | 17 | ||||
-rw-r--r-- | src/Text/Hakyll/Render.hs | 11 | ||||
-rw-r--r-- | src/Text/Hakyll/Util.hs | 5 |
4 files changed, 30 insertions, 7 deletions
diff --git a/hakyll.cabal b/hakyll.cabal index 8dd2f19..522e3c3 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -12,8 +12,10 @@ Cabal-Version: >= 1.2 build-type: Simple library + ghc-options: -Wall hs-source-dirs: src/ - build-depends: base > 4, template, filepath, directory, containers, bytestring, + build-depends: base >= 4 && < 5, template, filepath, directory, containers, bytestring, pandoc >= 1 exposed-modules: Text.Hakyll.Render Text.Hakyll.Page + Text.Hakyll.Util 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 |