summaryrefslogtreecommitdiff
path: root/lib/Hakyll/Core/Provider.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2017-06-19 11:57:23 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2017-06-19 11:57:23 +0200
commit67ecff7ad383640bc73d64edc2506c7cc648a134 (patch)
tree6d328e43c3ab86c29a2d775fabaa23618c16fb51 /lib/Hakyll/Core/Provider.hs
parent2df3209bafa08e6b77ee4a8598fc503269513527 (diff)
downloadhakyll-67ecff7ad383640bc73d64edc2506c7cc648a134.tar.gz
Move src/ to lib/, put Init.hs in src/
Diffstat (limited to 'lib/Hakyll/Core/Provider.hs')
-rw-r--r--lib/Hakyll/Core/Provider.hs43
1 files changed, 43 insertions, 0 deletions
diff --git a/lib/Hakyll/Core/Provider.hs b/lib/Hakyll/Core/Provider.hs
new file mode 100644
index 0000000..384f5b1
--- /dev/null
+++ b/lib/Hakyll/Core/Provider.hs
@@ -0,0 +1,43 @@
+--------------------------------------------------------------------------------
+-- | This module provides an wrapper API around the file system which does some
+-- caching.
+module Hakyll.Core.Provider
+ ( -- * Constructing resource providers
+ Internal.Provider
+ , newProvider
+
+ -- * Querying resource properties
+ , Internal.resourceList
+ , Internal.resourceExists
+ , Internal.resourceFilePath
+ , Internal.resourceModified
+ , Internal.resourceModificationTime
+
+ -- * Access to raw resource content
+ , Internal.resourceString
+ , Internal.resourceLBS
+
+ -- * Access to metadata and body content
+ , Internal.resourceMetadata
+ , Internal.resourceBody
+ ) where
+
+
+--------------------------------------------------------------------------------
+import qualified Hakyll.Core.Provider.Internal as Internal
+import qualified Hakyll.Core.Provider.MetadataCache as Internal
+import Hakyll.Core.Store (Store)
+
+
+--------------------------------------------------------------------------------
+-- | Create a resource provider
+newProvider :: Store -- ^ Store to use
+ -> (FilePath -> IO Bool) -- ^ Should we ignore this file?
+ -> FilePath -- ^ Search directory
+ -> IO Internal.Provider -- ^ Resulting provider
+newProvider store ignore directory = do
+ -- Delete metadata cache where necessary
+ p <- Internal.newProvider store ignore directory
+ mapM_ (Internal.resourceInvalidateMetadataCache p) $
+ filter (Internal.resourceModified p) $ Internal.resourceList p
+ return p