@@ -21,10 +21,7 @@ module Hakyll.Core.Rules
@@ -32,7 +29,6 @@ module Hakyll.Core.Rules
32import Control.Applicative ((<$>))
29import Control.Applicative ((<$>))
33import Control.Arrow (second)
30import Control.Arrow (second)
34import Control.Monad.Reader (ask, local)
31import Control.Monad.Reader (ask, local)
35−import Control.Monad.State (get, put)
36import Control.Monad.Writer (tell)
32import Control.Monad.Writer (tell)
37import Data.Monoid (mappend, mempty)
33import Data.Monoid (mappend, mempty)
38import qualified Data.Set as S
34import qualified Data.Set as S
@@ -81,11 +77,10 @@ tellResources resources' = Rules $ tell $
83--------------------------------------------------------------------------------
79--------------------------------------------------------------------------------
84−-- | Only compile/route items satisfying the given predicate
85match :: Pattern -> Rules b -> Rules b
80match :: Pattern -> Rules b -> Rules b
86−match pattern = Rules . local addPredicate . unRules
81+match pattern = Rules . local addPattern . unRules
88− addPredicate env = env
83+ addPattern env = env
89 { rulesPattern = rulesPattern env `mappend` pattern
84 { rulesPattern = rulesPattern env `mappend` pattern
@@ -135,26 +130,15 @@ group g = Rules . local setVersion' . unRules
135compile :: (Binary a, Typeable a, Writable a)
130compile :: (Binary a, Typeable a, Writable a)
136 => Compiler (Item a) -> Rules ()
131 => Compiler (Item a) -> Rules ()
137compile compiler = do
132compile compiler = do
138− ids <- resources
133+ pattern <- Rules $ rulesPattern <$> ask
139− tellCompilers [(id', compiler) | id' <- ids]
134+ ids <- case fromLiteral pattern of
135+ Just id' -> return [id']
140− tellResources ids
138+ tellResources ids
143−--------------------------------------------------------------------------------
144−-- | Add a compilation rule
146−-- This sets a compiler for the given identifier. No resource is needed, since
147−-- we are creating the item from scratch. This is useful if you want to create a
148−-- page on your site that just takes content from other items -- but has no
149−-- actual content itself. Note that the group of the given identifier is
150−-- replaced by the group set via 'group' (or 'Nothing', if 'group' has not been
152−create :: (Binary a, Typeable a, Writable a)
153− => Identifier -> Compiler (Item a) -> Rules ()
154−create id' compiler = Rules $ do
155− version' <- rulesVersion <$> ask
156− let id'' = setVersion version' id'
157− unRules $ tellCompilers [(id'', compiler)]
141+ tellCompilers [(id', compiler) | id' <- ids]
160--------------------------------------------------------------------------------
144--------------------------------------------------------------------------------
@@ -181,16 +165,3 @@ resources = Rules $ do
181 provider <- rulesProvider <$> ask
165 provider <- rulesProvider <$> ask
182 g <- rulesVersion <$> ask
166 g <- rulesVersion <$> ask
183 return $ filterMatches pattern $ map (setVersion g) $ resourceList provider
167 return $ filterMatches pattern $ map (setVersion g) $ resourceList provider
186−--------------------------------------------------------------------------------
187−-- | Generate a fresh Identifier with a given prefix
189−freshIdentifier :: String -- ^ Prefix
190− -> Rules Identifier -- ^ Fresh identifier
191−freshIdentifier prefix = Rules $ do
193− let index = rulesNextIdentifier state
194− id' = fromFilePath $ prefix ++ "/" ++ show index
195− put $ state {rulesNextIdentifier = index + 1}