on master help sign in
Removed deprecated code.
45eb746Jasper Van der Jeugt
src/Text/Hakyll/Internal/Page.hs+1−47
@@ -1,23 +1,15 @@
1-- | A module for dealing with @Page@s. This module is mostly internally used.
1-- | A module for dealing with @Page@s. This module is mostly internally used.
2module Text.Hakyll.Internal.Page
2module Text.Hakyll.Internal.Page
3− ( Page
4− , fromContext
5− , getValue
6− , getBody
7− , readPage
3+ ( readPage
8 ) where
4 ) where
9
5
10import qualified Data.Map as M
6import qualified Data.Map as M
11import Data.List (isPrefixOf)
7import Data.List (isPrefixOf)
12import Data.Char (isSpace)
8import Data.Char (isSpace)
13−import Data.Maybe (fromMaybe)
14−import Control.Monad (liftM, replicateM)
15import Control.Monad.Reader (liftIO)
9import Control.Monad.Reader (liftIO)
16import System.FilePath
10import System.FilePath
17
11
18−import Test.QuickCheck
19import Text.Pandoc
12import Text.Pandoc
20−import Data.Binary
21
13
22import Text.Hakyll.Context (Context)
14import Text.Hakyll.Context (Context)
23import Text.Hakyll.File
15import Text.Hakyll.File
@@ -26,25 +18,6 @@ import Text.Hakyll.Regex (substituteRegex, matchesRegex)
26import Text.Hakyll.Util (trim)
18import Text.Hakyll.Util (trim)
27import Text.Hakyll.Internal.Cache
19import Text.Hakyll.Internal.Cache
28
20
29−-- | A Page is basically key-value mapping. Certain keys have special
30−-- meanings, like for example url, body and title.
31−data Page = Page Context
32− deriving (Ord, Eq, Show, Read)
33−
34−-- | Create a Page from a key-value mapping.
35−fromContext :: Context -> Page
36−fromContext = Page
37−
38−-- | Obtain a value from a page. Will resturn an empty string when nothing is
39−-- found.
40−getValue :: String -> Page -> String
41−getValue str (Page page) = fromMaybe [] $ M.lookup str page
42−
43−-- | Get the body for a certain page. When not defined, the body will be
44−-- empty.
45−getBody :: Page -> String
46−getBody (Page page) = fromMaybe [] $ M.lookup "body" page
47−
48-- | The default reader options for pandoc parsing.
21-- | The default reader options for pandoc parsing.
49readerOptions :: ParserState
22readerOptions :: ParserState
50readerOptions = defaultParserState
23readerOptions = defaultParserState
@@ -143,22 +116,3 @@ readPage path = do
143 return page
116 return page
144 where
117 where
145 fileName = "pages" </> path
118 fileName = "pages" </> path
146−
147−-- Make pages serializable.
148−instance Binary Page where
149− put (Page context) = put $ M.toAscList context
150− get = liftM (Page . M.fromAscList) get
151−
152−-- | Generate an arbitrary page.
153−arbitraryPage :: Gen Page
154−arbitraryPage = do keys <- listOf key'
155− values <- arbitrary
156− return $ Page $ M.fromList $ zip keys values
157− where
158− key' = do l <- choose (5, 10)
159− replicateM l $ choose ('a', 'z')
160−
161−-- Make pages testable
162−instance Arbitrary Page where
163− arbitrary = arbitraryPage
164− shrink (Page context) = map (Page . flip M.delete context) $ M.keys context
src/Text/Hakyll/Renderables.hs−12
@@ -2,9 +2,7 @@ module Text.Hakyll.Renderables
2 ( createCustomPage
2 ( createCustomPage
3 , createListing
3 , createListing
4 , createListingWith
4 , createListingWith
5− , PagePath
6 , createPagePath
5 , createPagePath
7− , CombinedRenderable
8 , combine
6 , combine
9 , combineWithUrl
7 , combineWithUrl
10 ) where
8 ) where
@@ -80,11 +78,6 @@ createListingWith manipulation url template renderables additional =
80 concatenation = renderAndConcatWith manipulation [template] renderables
78 concatenation = renderAndConcatWith manipulation [template] renderables
81 additional' = map (second Left) additional
79 additional' = map (second Left) additional
82
80
83−-- | PagePath is a class that wraps a FilePath. This is used to render Pages
84−-- without reading them first through use of caching.
85−newtype PagePath = PagePath FilePath
86− deriving (Ord, Eq, Read, Show)
87−
88-- | Create a PagePath from a FilePath.
81-- | Create a PagePath from a FilePath.
89createPagePath :: FilePath -> RenderAction () Context
82createPagePath :: FilePath -> RenderAction () Context
90createPagePath path = RenderAction
83createPagePath path = RenderAction
@@ -93,11 +86,6 @@ createPagePath path = RenderAction
93 , actionFunction = const (readPage path)
86 , actionFunction = const (readPage path)
94 }
87 }
95
88
96−-- | A combination of two other renderables.
97−data CombinedRenderable a b = CombinedRenderable a b
98− | CombinedRenderableWithUrl FilePath a b
99− deriving (Ord, Eq, Read, Show)
100−
101-- | Combine two renderables. The url will always be taken from the first
89-- | Combine two renderables. The url will always be taken from the first
102-- @Renderable@. Also, if a `$key` is present in both renderables, the
90-- @Renderable@. Also, if a `$key` is present in both renderables, the
103-- value from the first @Renderable@ will be taken as well.
91-- value from the first @Renderable@ will be taken as well.