diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-22 13:38:28 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2012-11-22 13:38:28 +0100 |
commit | 82d5210f25d560e9488ab14f243a2cad9ad906a9 (patch) | |
tree | f9b32638301aed53f4c4ec546203b88ba04bbba4 /src/Hakyll/Core/Rules | |
parent | aa1762f78ee5d0c5700d43a1e0363f96c4cfe617 (diff) | |
download | hakyll-82d5210f25d560e9488ab14f243a2cad9ad906a9.tar.gz |
Add MonadMetadata and instances
Diffstat (limited to 'src/Hakyll/Core/Rules')
-rw-r--r-- | src/Hakyll/Core/Rules/Internal.hs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/Hakyll/Core/Rules/Internal.hs b/src/Hakyll/Core/Rules/Internal.hs index a067b02..249ae3b 100644 --- a/src/Hakyll/Core/Rules/Internal.hs +++ b/src/Hakyll/Core/Rules/Internal.hs @@ -12,8 +12,10 @@ module Hakyll.Core.Rules.Internal -------------------------------------------------------------------------------- -import Control.Applicative (Applicative) +import Control.Applicative (Applicative, (<$>)) +import Control.Monad.Reader (ask) import Control.Monad.RWS (RWST, runRWST) +import Control.Monad.Trans (liftIO) import qualified Data.Map as M import Data.Monoid (Monoid, mappend, mempty) import Data.Set (Set) @@ -24,6 +26,7 @@ import Hakyll.Core.Compiler.Internal import Hakyll.Core.Identifier import Hakyll.Core.Identifier.Pattern import Hakyll.Core.Item.SomeItem +import Hakyll.Core.Metadata import Hakyll.Core.Provider import Hakyll.Core.Routes @@ -71,6 +74,17 @@ newtype Rules a = Rules -------------------------------------------------------------------------------- +instance MonadMetadata Rules where + getMetadata identifier = Rules $ do + provider <- rulesProvider <$> ask + liftIO $ resourceMetadata provider identifier + + getMatches pattern = Rules $ do + provider <- rulesProvider <$> ask + return $ filterMatches pattern $ resourceList provider + + +-------------------------------------------------------------------------------- -- | Run a Rules monad, resulting in a 'RuleSet' runRules :: Rules a -> Provider -> IO RuleSet runRules rules provider = do |