@@ -21,10 +21,7 @@ module Hakyll.Core.Rules
2121 , match
2222 , group
2323 , compile
24− , create
2524 , route
26− , resources
27− , freshIdentifier
2825 ) where
2926
3027
@@ -32,7 +29,6 @@ module Hakyll.Core.Rules
3229import Control.Applicative ((<$>))
3330import Control.Arrow (second)
3431import Control.Monad.Reader (ask, local)
35−import Control.Monad.State (get, put)
3632import Control.Monad.Writer (tell)
3733import Data.Monoid (mappend, mempty)
3834import qualified Data.Set as S
@@ -81,11 +77,10 @@ tellResources resources' = Rules $ tell $
8177
8278
8379--------------------------------------------------------------------------------
84−-- | Only compile/route items satisfying the given predicate
8580match :: Pattern -> Rules b -> Rules b
86−match pattern = Rules . local addPredicate . unRules
81+match pattern = Rules . local addPattern . unRules
8782 where
88− addPredicate env = env
83+ addPattern env = env
8984 { rulesPattern = rulesPattern env `mappend` pattern
9085 }
9186
@@ -135,26 +130,15 @@ group g = Rules . local setVersion' . unRules
135130compile :: (Binary a, Typeable a, Writable a)
136131 => Compiler (Item a) -> Rules ()
137132compile compiler = do
138− ids <- resources
139− tellCompilers [(id', compiler) | id' <- ids]
140− tellResources ids
141−
133+ pattern <- Rules $ rulesPattern <$> ask
134+ ids <- case fromLiteral pattern of
135+ Just id' -> return [id']
136+ Nothing -> do
137+ ids <- resources
138+ tellResources ids
139+ return ids
142140
143−--------------------------------------------------------------------------------
144−-- | Add a compilation rule
145−--
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
151−-- used).
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]
158142
159143
160144--------------------------------------------------------------------------------
@@ -181,16 +165,3 @@ resources = Rules $ do
181165 provider <- rulesProvider <$> ask
182166 g <- rulesVersion <$> ask
183167 return $ filterMatches pattern $ map (setVersion g) $ resourceList provider
184−
185−
186−--------------------------------------------------------------------------------
187−-- | Generate a fresh Identifier with a given prefix
188−-- TODO: remove?
189−freshIdentifier :: String -- ^ Prefix
190− -> Rules Identifier -- ^ Fresh identifier
191−freshIdentifier prefix = Rules $ do
192− state <- get
193− let index = rulesNextIdentifier state
194− id' = fromFilePath $ prefix ++ "/" ++ show index
195− put $ state {rulesNextIdentifier = index + 1}
196− return id'