summaryrefslogtreecommitdiff
path: root/src/Text/Hakyll
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Hakyll')
-rw-r--r--src/Text/Hakyll/Internal/Page.hs48
-rw-r--r--src/Text/Hakyll/Renderables.hs12
2 files changed, 1 insertions, 59 deletions
diff --git a/src/Text/Hakyll/Internal/Page.hs b/src/Text/Hakyll/Internal/Page.hs
index ceabb02..c91d7ae 100644
--- a/src/Text/Hakyll/Internal/Page.hs
+++ b/src/Text/Hakyll/Internal/Page.hs
@@ -1,23 +1,15 @@
-- | A module for dealing with @Page@s. This module is mostly internally used.
module Text.Hakyll.Internal.Page
- ( Page
- , fromContext
- , getValue
- , getBody
- , readPage
+ ( readPage
) where
import qualified Data.Map as M
import Data.List (isPrefixOf)
import Data.Char (isSpace)
-import Data.Maybe (fromMaybe)
-import Control.Monad (liftM, replicateM)
import Control.Monad.Reader (liftIO)
import System.FilePath
-import Test.QuickCheck
import Text.Pandoc
-import Data.Binary
import Text.Hakyll.Context (Context)
import Text.Hakyll.File
@@ -26,25 +18,6 @@ import Text.Hakyll.Regex (substituteRegex, matchesRegex)
import Text.Hakyll.Util (trim)
import Text.Hakyll.Internal.Cache
--- | A Page is basically key-value mapping. Certain keys have special
--- meanings, like for example url, body and title.
-data Page = Page Context
- deriving (Ord, Eq, Show, Read)
-
--- | Create a Page from a key-value mapping.
-fromContext :: Context -> Page
-fromContext = Page
-
--- | Obtain a value from a page. Will resturn an empty string when nothing is
--- found.
-getValue :: String -> Page -> String
-getValue str (Page page) = fromMaybe [] $ M.lookup str page
-
--- | Get the body for a certain page. When not defined, the body will be
--- empty.
-getBody :: Page -> String
-getBody (Page page) = fromMaybe [] $ M.lookup "body" page
-
-- | The default reader options for pandoc parsing.
readerOptions :: ParserState
readerOptions = defaultParserState
@@ -143,22 +116,3 @@ readPage path = do
return page
where
fileName = "pages" </> path
-
--- Make pages serializable.
-instance Binary Page where
- put (Page context) = put $ M.toAscList context
- get = liftM (Page . M.fromAscList) get
-
--- | Generate an arbitrary page.
-arbitraryPage :: Gen Page
-arbitraryPage = do keys <- listOf key'
- values <- arbitrary
- return $ Page $ M.fromList $ zip keys values
- where
- key' = do l <- choose (5, 10)
- replicateM l $ choose ('a', 'z')
-
--- Make pages testable
-instance Arbitrary Page where
- arbitrary = arbitraryPage
- shrink (Page context) = map (Page . flip M.delete context) $ M.keys context
diff --git a/src/Text/Hakyll/Renderables.hs b/src/Text/Hakyll/Renderables.hs
index b540d4b..00e11ca 100644
--- a/src/Text/Hakyll/Renderables.hs
+++ b/src/Text/Hakyll/Renderables.hs
@@ -2,9 +2,7 @@ module Text.Hakyll.Renderables
( createCustomPage
, createListing
, createListingWith
- , PagePath
, createPagePath
- , CombinedRenderable
, combine
, combineWithUrl
) where
@@ -80,11 +78,6 @@ createListingWith manipulation url template renderables additional =
concatenation = renderAndConcatWith manipulation [template] renderables
additional' = map (second Left) additional
--- | PagePath is a class that wraps a FilePath. This is used to render Pages
--- without reading them first through use of caching.
-newtype PagePath = PagePath FilePath
- deriving (Ord, Eq, Read, Show)
-
-- | Create a PagePath from a FilePath.
createPagePath :: FilePath -> RenderAction () Context
createPagePath path = RenderAction
@@ -93,11 +86,6 @@ createPagePath path = RenderAction
, actionFunction = const (readPage path)
}
--- | A combination of two other renderables.
-data CombinedRenderable a b = CombinedRenderable a b
- | CombinedRenderableWithUrl FilePath a b
- deriving (Ord, Eq, Read, Show)
-
-- | Combine two renderables. The url will always be taken from the first
-- @Renderable@. Also, if a `$key` is present in both renderables, the
-- value from the first @Renderable@ will be taken as well.