@@ -19,6 +19,7 @@
1919module Hakyll.Core.Rules
2020 ( Rules
2121 , match
22+ , create
2223 , version
2324 , compile
2425 , route
@@ -34,7 +35,7 @@ import Control.Monad.Reader (ask, local)
3435import Control.Monad.State (get, modify, put)
3536import Control.Monad.Writer (censor, tell)
3637import Data.Maybe (fromMaybe)
37−import Data.Monoid (mappend, mempty)
38+import Data.Monoid (mempty)
3839import qualified Data.Set as S
3940
4041
@@ -82,15 +83,21 @@ flush = Rules $ do
8283 case mcompiler of
8384 Nothing -> return ()
8485 Just compiler -> do
85− pattern <- rulesPattern <$> ask
86+ matches' <- rulesMatches <$> ask
8687 version' <- rulesVersion <$> ask
8788 route' <- fromMaybe mempty . rulesRoute <$> get
89+
90+ -- The version is possibly not set correctly at this point (yet)
91+ let ids = map (setVersion version') matches'
92+
93+ {-
8894 ids <- case fromLiteral pattern of
8995 Just id' -> return [setVersion version' id']
9096 Nothing -> do
9197 ids <- unRules $ getMatches pattern
9298 unRules $ tellResources ids
9399 return $ map (setVersion version') ids
100+ -}
94101
95102 -- Create a fast pattern for routing that matches exactly the
96103 -- compilers created in the block given to match
@@ -107,11 +114,21 @@ flush = Rules $ do
107114match :: Pattern -> Rules () -> Rules ()
108115match pattern rules = do
109116 flush
110− Rules $ local addPattern $ unRules $ rules >> flush
117+ ids <- getMatches pattern
118+ tellResources ids
119+ Rules $ local (setMatches ids) $ unRules $ rules >> flush
111120 where
112− addPattern env = env
113− { rulesPattern = rulesPattern env `mappend` pattern
114− }
121+ setMatches ids env = env {rulesMatches = ids}
122+
123+
124+--------------------------------------------------------------------------------
125+create :: [Identifier] -> Rules () -> Rules ()
126+create ids rules = do
127+ flush
128+ -- TODO Maybe check if the resources exist and call tellResources on that
129+ Rules $ local setMatches $ unRules $ rules >> flush
130+ where
131+ setMatches env = env {rulesMatches = ids}
115132
116133
117134--------------------------------------------------------------------------------