on master help sign in
Removed deprecated code.
commit45eb74655f60f9f5f13c6b6b52adada2265e80ee authorJasper Van der Jeugt <jaspervdj@gmail.com> dateFri 5 Mar 2010, 12:48 (17 years ago) parent664111c
2 files changed+1−59
src/Text/Hakyll/Internal/Page.hs+1−47 src/Text/Hakyll/Renderables.hs−12
src/Text/Hakyll/Internal/Page.hs+1−47
@@ -1,23 +1,15 @@
11-- | A module for dealing with @Page@s. This module is mostly internally used.
22module Text.Hakyll.Internal.Page
3− ( Page
4− , fromContext
5− , getValue
6− , getBody
7− , readPage
3+ ( readPage
84 ) where
95
106import qualified Data.Map as M
117import Data.List (isPrefixOf)
128import Data.Char (isSpace)
13−import Data.Maybe (fromMaybe)
14−import Control.Monad (liftM, replicateM)
159import Control.Monad.Reader (liftIO)
1610import System.FilePath
1711
18−import Test.QuickCheck
1912import Text.Pandoc
20−import Data.Binary
2113
2214import Text.Hakyll.Context (Context)
2315import Text.Hakyll.File
@@ -26,25 +18,6 @@ import Text.Hakyll.Regex (substituteRegex, matchesRegex)
2618import Text.Hakyll.Util (trim)
2719import Text.Hakyll.Internal.Cache
2820
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−
4821-- | The default reader options for pandoc parsing.
4922readerOptions :: ParserState
5023readerOptions = defaultParserState
@@ -143,22 +116,3 @@ readPage path = do
143116 return page
144117 where
145118 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
22 ( createCustomPage
33 , createListing
44 , createListingWith
5− , PagePath
65 , createPagePath
7− , CombinedRenderable
86 , combine
97 , combineWithUrl
108 ) where
@@ -80,11 +78,6 @@ createListingWith manipulation url template renderables additional =
8078 concatenation = renderAndConcatWith manipulation [template] renderables
8179 additional' = map (second Left) additional
8280
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−
8881-- | Create a PagePath from a FilePath.
8982createPagePath :: FilePath -> RenderAction () Context
9083createPagePath path = RenderAction
@@ -93,11 +86,6 @@ createPagePath path = RenderAction
9386 , actionFunction = const (readPage path)
9487 }
9588
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−
10189-- | Combine two renderables. The url will always be taken from the first
10290-- @Renderable@. Also, if a `$key` is present in both renderables, the
10391-- value from the first @Renderable@ will be taken as well.