summaryrefslogtreecommitdiff
path: root/src/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-11-26 16:11:37 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-11-26 16:11:37 +0100
commit1bcce776e786eb6688bace653ecafa1a5a4fb563 (patch)
treefc889c8e4af23c32dec6637d5c4e2de1fe383830 /src/Hakyll
parent25b8c8b199082ebbc41d1af03fc19202b798f156 (diff)
downloadhakyll-1bcce776e786eb6688bace653ecafa1a5a4fb563.tar.gz
Re-add some tests, cleanup...
Diffstat (limited to 'src/Hakyll')
-rw-r--r--src/Hakyll/Web/Page/List.hs83
1 files changed, 0 insertions, 83 deletions
diff --git a/src/Hakyll/Web/Page/List.hs b/src/Hakyll/Web/Page/List.hs
deleted file mode 100644
index 20c178c..0000000
--- a/src/Hakyll/Web/Page/List.hs
+++ /dev/null
@@ -1,83 +0,0 @@
--- TODO: Port
--- | Provides an easy way to combine several pages in a list. The applications
--- are obvious:
---
--- * A post list on a blog
---
--- * An image list in a gallery
---
--- * A sitemap
---
-module Hakyll.Web.Page.List
- ( setFieldPageList
- , pageListCompiler
- , chronological
- , recentFirst
- , sortByBaseName
- ) where
-
-import Control.Arrow ((>>>), arr)
-import Data.List (sortBy)
-import Data.Monoid (Monoid, mconcat)
-import Data.Ord (comparing)
-import System.FilePath (takeBaseName)
-
-import Hakyll.Core.Compiler
-import Hakyll.Core.Identifier
-import Hakyll.Core.Identifier.Pattern
-import Hakyll.Web.Page
-import Hakyll.Web.Page.Metadata
-import Hakyll.Web.Template
-
--- | Set a field of a page to a listing of pages
---
-setFieldPageList :: ([Page String] -> [Page String])
- -- ^ Determines list order
- -> Identifier Template
- -- ^ Applied to every page
- -> String
- -- ^ Key indicating which field should be set
- -> Pattern (Page String)
- -- ^ Selects pages to include in the list
- -> Compiler (Page String) (Page String)
- -- ^ Compiler that sets the page list in a field
-setFieldPageList sort template key pattern =
- requireAllA pattern $ setFieldA key $ pageListCompiler sort template
-
--- | Create a list of pages
---
-pageListCompiler :: ([Page String] -> [Page String]) -- ^ Determine list order
- -> Identifier Template -- ^ Applied to pages
- -> Compiler [Page String] String -- ^ Compiles page list
-pageListCompiler sort template =
- arr sort >>> applyTemplateToList template >>> arr concatPages
-
--- | Apply a template to every page in a list
---
-applyTemplateToList :: Identifier Template
- -> Compiler [Page String] [Page String]
-applyTemplateToList identifier = require identifier $
- \posts template -> map (applyTemplateToPage template) posts
-
--- | Concatenate the bodies of a page list
---
-concatPages :: Monoid m => [Page m] -> m
-concatPages = mconcat . map pageBody
-
--- | Sort pages chronologically. This function assumes that the pages have a
--- @year-month-day-title.extension@ naming scheme -- as is the convention in
--- Hakyll.
---
-chronological :: [Page a] -> [Page a]
-chronological = sortBy $ comparing $ takeBaseName . getField "path"
-
--- | The reverse of 'chronological'
---
-recentFirst :: [Page a] -> [Page a]
-recentFirst = reverse . chronological
-
--- | Deprecated, see 'chronological'
---
-sortByBaseName :: [Page a] -> [Page a]
-sortByBaseName = chronological
-{-# DEPRECATED sortByBaseName "Use chronological" #-}