summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll/Internal
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-04 22:09:41 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2010-03-04 22:09:41 +0100
commit11996929aae640c9cd3737fdb2736e6562c705de (patch)
treeafd6bcd7fe1aaf364a05100e851dd28a1cb3f273 /src/Text/Hakyll/Internal
parent192c4a16ea01c9398a55f61025425d8e0e87e0f8 (diff)
downloadhakyll-11996929aae640c9cd3737fdb2736e6562c705de.tar.gz
Got it to compile again, disabled Tags for now.
Diffstat (limited to 'src/Text/Hakyll/Internal')
-rw-r--r--src/Text/Hakyll/Internal/Page.hs19
-rw-r--r--src/Text/Hakyll/Internal/Render.hs16
2 files changed, 8 insertions, 27 deletions
diff --git a/src/Text/Hakyll/Internal/Page.hs b/src/Text/Hakyll/Internal/Page.hs
index 92e7249..4adddc5 100644
--- a/src/Text/Hakyll/Internal/Page.hs
+++ b/src/Text/Hakyll/Internal/Page.hs
@@ -21,11 +21,8 @@ import Data.Binary
import Text.Hakyll.Internal.Cache
import Text.Hakyll.Hakyll
-import Text.Hakyll.File
import Text.Hakyll.Util (trim)
import Text.Hakyll.Context (Context)
-import Text.Hakyll.Renderable
-import Text.Hakyll.RenderAction
import Text.Hakyll.Regex (substituteRegex, matchesRegex)
-- | A Page is basically key-value mapping. Certain keys have special
@@ -42,16 +39,6 @@ fromContext = Page
getValue :: String -> Page -> String
getValue str (Page page) = fromMaybe [] $ M.lookup str page
--- | Get the URL for a certain page. This should always be defined. If
--- not, it will error.
-getPageUrl :: Page -> String
-getPageUrl (Page page) = fromMaybe (error "No page url") $ M.lookup "url" page
-
--- | Get the original page path.
-getPagePath :: Page -> String
-getPagePath (Page page) =
- fromMaybe (error "No page path") $ M.lookup "path" page
-
-- | Get the body for a certain page. When not defined, the body will be
-- empty.
getBody :: Page -> String
@@ -155,12 +142,6 @@ readPage path = do
where
fileName = "pages" </> path
--- Make pages renderable.
-instance Renderable Page where
- getDependencies = (:[]) . getPagePath
- getUrl = return . getPageUrl
- toContext (Page page) = return page
-
-- Make pages serializable.
instance Binary Page where
put (Page context) = put $ M.toAscList context
diff --git a/src/Text/Hakyll/Internal/Render.hs b/src/Text/Hakyll/Internal/Render.hs
index 00b74a7..0fae8a7 100644
--- a/src/Text/Hakyll/Internal/Render.hs
+++ b/src/Text/Hakyll/Internal/Render.hs
@@ -15,10 +15,9 @@ import Data.List (foldl')
import Data.Maybe (fromMaybe)
import Text.Hakyll.Context (Context, ContextManipulation)
-import Text.Hakyll.Renderable
import Text.Hakyll.File
import Text.Hakyll.Hakyll
-import Text.Hakyll.Internal.Page
+import Text.Hakyll.RenderAction
import Text.Hakyll.Internal.Template
-- | A pure render function.
@@ -55,13 +54,14 @@ pureRenderChainWith manipulation templates context =
-- | Write a page to the site destination. Final action after render
-- chains and such.
-writePage :: Page -> Hakyll ()
-writePage page = do
+writePage :: RenderAction Context ()
+writePage = createRenderAction $ \initialContext -> do
additionalContext' <- askHakyll additionalContext
- url <- getUrl page
- destination <- toDestination url
+ let url = fromMaybe (error "No url defined at write time.")
+ (M.lookup "url" initialContext)
+ body = fromMaybe "" (M.lookup "body" initialContext)
let context = additionalContext' `M.union` M.singleton "root" (toRoot url)
+ destination <- toDestination url
makeDirectories destination
    -- Substitute $root here, just before writing.
- liftIO $ writeFile destination $ finalSubstitute (fromString $ getBody page)
- context
+ liftIO $ writeFile destination $ finalSubstitute (fromString body) context