summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core/Resource/Provider/File.hs
blob: 8365a5d41eedcbd24b61f222c1dde56a517370eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
-- | A concrete 'ResourceProvider' that gets it's resources from the filesystem
--
module Hakyll.Core.Resource.Provider.File
    ( fileResourceProvider
    ) where

import Control.Applicative ((<$>))

import qualified Data.ByteString.Lazy as LB

import Hakyll.Core.Resource
import Hakyll.Core.Resource.Provider
import Hakyll.Core.Util.File
import Hakyll.Core.Configuration

-- | Create a filesystem-based 'ResourceProvider'
--
fileResourceProvider :: HakyllConfiguration -> IO ResourceProvider
fileResourceProvider configuration = do
    -- Retrieve a list of paths
    list <- map Resource . filter (not . ignoreFile configuration) <$>
        getRecursiveContents False "."
    makeResourceProvider list (readFile . unResource)
                              (LB.readFile . unResource)