Removed some deprecated functions.
This commit is contained in:
parent
0bbb99ed2f
commit
5d64ff7d5c
1 changed files with 3 additions and 12 deletions
|
@ -1,10 +1,8 @@
|
||||||
module Text.Hakyll.Page
|
module Text.Hakyll.Page
|
||||||
( Page,
|
( Page,
|
||||||
fromContext,
|
fromContext,
|
||||||
addContext,
|
|
||||||
getBody,
|
getBody,
|
||||||
readPage,
|
readPage
|
||||||
pageFromList
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
|
@ -28,10 +26,6 @@ data Page = Page (M.Map B.ByteString B.ByteString)
|
||||||
fromContext :: (M.Map B.ByteString B.ByteString) -> Page
|
fromContext :: (M.Map B.ByteString B.ByteString) -> Page
|
||||||
fromContext = Page
|
fromContext = Page
|
||||||
|
|
||||||
-- | Add a key-value mapping to the Page.
|
|
||||||
addContext :: String -> String -> Page -> Page
|
|
||||||
addContext key value (Page page) = Page $ M.insert (B.pack key) (B.pack value) page
|
|
||||||
|
|
||||||
-- | Auxiliary function to pack a pair.
|
-- | Auxiliary function to pack a pair.
|
||||||
packPair :: (String, String) -> (B.ByteString, B.ByteString)
|
packPair :: (String, String) -> (B.ByteString, B.ByteString)
|
||||||
packPair (a, b) = (B.pack a, B.pack b)
|
packPair (a, b) = (B.pack a, B.pack b)
|
||||||
|
@ -113,7 +107,8 @@ readPage pagePath = do
|
||||||
-- Render file
|
-- Render file
|
||||||
let rendered = B.pack $ (renderFunction $ takeExtension path) body
|
let rendered = B.pack $ (renderFunction $ takeExtension path) body
|
||||||
seq rendered $ hClose handle
|
seq rendered $ hClose handle
|
||||||
let page = addContext "url" url $ Page $ M.fromList $ (B.pack "body", rendered) : map packPair context
|
let page = fromContext $ M.fromList $
|
||||||
|
[(B.pack "body", rendered), packPair ("url", url)] ++ map packPair context
|
||||||
|
|
||||||
-- Cache if needed
|
-- Cache if needed
|
||||||
if getFromCache then return () else cachePage page
|
if getFromCache then return () else cachePage page
|
||||||
|
@ -121,10 +116,6 @@ readPage pagePath = do
|
||||||
where url = toURL pagePath
|
where url = toURL pagePath
|
||||||
cacheFile = toCache url
|
cacheFile = toCache url
|
||||||
|
|
||||||
-- | Create a key-value mapping page from an association list.
|
|
||||||
pageFromList :: [(String, String)] -> Page
|
|
||||||
pageFromList = Page . M.fromList . map packPair
|
|
||||||
|
|
||||||
-- Make pages renderable.
|
-- Make pages renderable.
|
||||||
instance Renderable Page where
|
instance Renderable Page where
|
||||||
getDependencies = (:[]) . flip addExtension ".html" . dropExtension . getPageURL
|
getDependencies = (:[]) . flip addExtension ".html" . dropExtension . getPageURL
|
||||||
|
|
Loading…
Reference in a new issue