2012-10-29 14:01:58 +00:00
|
|
|
--------------------------------------------------------------------------------
|
2012-11-08 11:45:26 +00:00
|
|
|
-- | This module provides an wrapper API around the file system which does some
|
|
|
|
-- caching.
|
2012-11-18 20:56:52 +00:00
|
|
|
module Hakyll.Core.Provider
|
2012-11-08 11:45:26 +00:00
|
|
|
( -- * Constructing resource providers
|
2013-02-09 14:11:40 +00:00
|
|
|
Internal.Provider
|
2012-11-18 20:56:52 +00:00
|
|
|
, newProvider
|
2012-11-08 11:45:26 +00:00
|
|
|
|
|
|
|
-- * Querying resource properties
|
2013-02-09 14:11:40 +00:00
|
|
|
, Internal.resourceList
|
|
|
|
, Internal.resourceExists
|
2013-03-07 17:48:11 +00:00
|
|
|
, Internal.resourceFilePath
|
2013-02-09 14:11:40 +00:00
|
|
|
, Internal.resourceModified
|
|
|
|
, Internal.resourceModificationTime
|
2012-10-29 14:01:58 +00:00
|
|
|
|
2012-11-08 11:45:26 +00:00
|
|
|
-- * Access to raw resource content
|
2013-02-09 14:11:40 +00:00
|
|
|
, Internal.resourceString
|
|
|
|
, Internal.resourceLBS
|
2011-02-11 16:52:19 +00:00
|
|
|
|
2012-11-08 11:45:26 +00:00
|
|
|
-- * Access to metadata and body content
|
2013-02-09 14:11:40 +00:00
|
|
|
, Internal.resourceMetadata
|
|
|
|
, Internal.resourceBody
|
2012-11-08 11:45:26 +00:00
|
|
|
) where
|
2010-12-31 12:28:31 +00:00
|
|
|
|
2012-10-29 14:01:58 +00:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2013-02-09 14:11:40 +00:00
|
|
|
import qualified Hakyll.Core.Provider.Internal as Internal
|
2012-11-18 20:56:52 +00:00
|
|
|
import qualified Hakyll.Core.Provider.MetadataCache as Internal
|
2013-02-09 14:11:40 +00:00
|
|
|
import Hakyll.Core.Store (Store)
|
2010-12-31 11:38:12 +00:00
|
|
|
|
2012-10-29 14:01:58 +00:00
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
2013-02-09 14:11:40 +00:00
|
|
|
-- | Create a resource provider
|
|
|
|
newProvider :: Store -- ^ Store to use
|
|
|
|
-> (FilePath -> Bool) -- ^ Should we ignore this file?
|
|
|
|
-> FilePath -- ^ Search directory
|
|
|
|
-> IO Internal.Provider -- ^ Resulting provider
|
|
|
|
newProvider store ignore directory = do
|
|
|
|
-- Delete metadata cache where necessary
|
2013-02-10 21:15:34 +00:00
|
|
|
p <- Internal.newProvider store ignore directory
|
|
|
|
mapM_ (Internal.resourceInvalidateMetadataCache p) $
|
|
|
|
filter (Internal.resourceModified p) $ Internal.resourceList p
|
|
|
|
return p
|