on master help sign in
createCustomPage can automatically infer dependencies.
commit7cbeb1739f7a01df0853ae8e339646320b86fa9d authorJasper Van der Jeugt <jaspervdj@gmail.com> dateSun 7 Mar 2010, 23:18 (17 years ago) parent89d6cb2
3 files changed+31−19
src/Text/Hakyll/Paginate.hs+6−1 src/Text/Hakyll/Renderables.hs+14−16 src/Text/Hakyll/Rss.hs+11−2
src/Text/Hakyll/Paginate.hs+6−1
@@ -39,10 +39,15 @@ defaultPaginateConfiguration = PaginateConfiguration
3939-- The following metadata fields will be added:
4040--
4141-- - @$previous@: A link to the previous page.
42+--
4243-- - @$next@: A link to the next page.
44+--
4345-- - @$first@: A link to the first page.
46+--
4447-- - @$last@: A link to the last page.
48+--
4549-- - @$index@: 1-based index of the current page.
50+--
4651-- - @$length@: Total number of pages.
4752--
4853-- When @$previous@ or @$next@ are not available, they will be just a label
@@ -72,7 +77,7 @@ paginate configuration renderables = paginate' Nothing renderables (1 :: Int)
7277 , linkWithLabel lastLabel (last renderables) )
7378 [] -> ( Left $ nextLabel configuration
7479 , Left $ lastLabel configuration )
75− customPage = createCustomPage "" []
80+ customPage = createCustomPage ""
7681 [ ("previous", previous)
7782 , ("next", next)
7883 , ("first", first)
src/Text/Hakyll/Renderables.hs+14−16
@@ -26,11 +26,10 @@ import Text.Hakyll.Internal.Page
2626-- dependency checking. A @String@ is obviously more simple to use in some
2727-- cases.
2828createCustomPage :: String
29− -> [FilePath]
3029 -> [(String, Either String (RenderAction () String))]
3130 -> Renderable
32−createCustomPage url dependencies association = RenderAction
33− { actionDependencies = dependencies ++ dataDependencies
31+createCustomPage url association = RenderAction
32+ { actionDependencies = dataDependencies
3433 , actionUrl = Just $ return url
3534 , actionFunction = \_ -> M.fromList <$> assoc'
3635 }
@@ -50,13 +49,13 @@ createCustomPage url dependencies association = RenderAction
5049-- @CustomPage@.
5150--
5251-- > let customPage = createListingWith
53−-- > "index.html" -- Destination of the page.
54−-- > "templates/postitem.html" -- Path to template to
55−-- > -- render the items with.
56−-- > posts -- ^ Renderables to create the list with.
57−-- > [("title", "Home")] -- ^ Additional context
58−createListing :: String -- ^ Destination of the page.
59− -> FilePath -- ^ Template to render all items with.
52+-- > "index.html" -- Destination of the page.
53+-- > ["templates/postitem.html"] -- Paths to templates to render the
54+-- > -- items with.
55+-- > posts -- Renderables to create the list with.
56+-- > [("title", Left "Home")] -- Additional context
57+createListing :: String -- ^ Destination of the page.
58+ -> [FilePath] -- ^ Templates to render all items with.
6059 -> [Renderable] -- ^ Renderables in the list.
6160 -> [(String, Either String (RenderAction () String))]
6261 -> Renderable
@@ -67,17 +66,16 @@ createListing = createListingWith id
6766-- In addition to @createListing@, this function allows you to specify an
6867-- extra @ContextManipulation@ for all @Renderable@s given.
6968createListingWith :: ContextManipulation -- ^ Manipulation for the renderables.
70− -> String -- ^ Destination of the page.
71− -> FilePath -- ^ Template to render all items with.
69+ -> String -- ^ Destination of the page.
70+ -> [FilePath] -- ^ Templates to render all items with.
7271 -> [Renderable] -- ^ Renderables in the list.
7372 -> [(String, Either String (RenderAction () String))]
7473 -> Renderable
75−createListingWith manipulation url template renderables additional =
76− createCustomPage url dependencies context
74+createListingWith manipulation url templates renderables additional =
75+ createCustomPage url context
7776 where
78− dependencies = template : concatMap actionDependencies renderables
7977 context = ("body", Right concatenation) : additional
80− concatenation = renderAndConcatWith manipulation [template] renderables
78+ concatenation = renderAndConcatWith manipulation templates renderables
8179
8280-- | Create a PagePath from a FilePath.
8381createPagePath :: FilePath -> Renderable
src/Text/Hakyll/Rss.hs+11−2
@@ -39,8 +39,8 @@ createRssWith :: ContextManipulation -- ^ Manipulation to apply on the items.
3939createRssWith manipulation configuration renderables template itemTemplate =
4040 listing >>> render template
4141 where
42− listing = createListingWith manipulation (rssUrl configuration) itemTemplate
43− renderables additional
42+ listing = createListingWith manipulation (rssUrl configuration)
43+ [itemTemplate] renderables additional
4444
4545 additional = map (second $ Left . ($ configuration))
4646 [ ("title", rssTitle)
@@ -48,6 +48,15 @@ createRssWith manipulation configuration renderables template itemTemplate =
4848 ]
4949
5050-- | Render an RSS feed with a number of items.
51+--
52+-- Note that the @Renderable@s should have the following fields:
53+--
54+-- - @$title@: Title of the item.
55+--
56+-- - @$description@: Description to appear in the feed.
57+--
58+-- - @$url@: URL to the item - this is usually set automatically.
59+--
5160renderRss :: RssConfiguration -- ^ Feed configuration.
5261 -> [Renderable] -- ^ Items to include in the feed.
5362 -> Hakyll ()