@@ -19,7 +19,7 @@
19module Hakyll.Core.Rules
19module Hakyll.Core.Rules
@@ -45,7 +45,7 @@ import Hakyll.Core.Identifier
45import Hakyll.Core.Identifier.Pattern
45import Hakyll.Core.Identifier.Pattern
46import Hakyll.Core.Item
46import Hakyll.Core.Item
47import Hakyll.Core.Item.SomeItem
47import Hakyll.Core.Item.SomeItem
48−import Hakyll.Core.Provider
48+import Hakyll.Core.Metadata
49import Hakyll.Core.Routes
49import Hakyll.Core.Routes
50import Hakyll.Core.Rules.Internal
50import Hakyll.Core.Rules.Internal
51import Hakyll.Core.Writable
51import Hakyll.Core.Writable
@@ -86,39 +86,10 @@ match pattern = Rules . local addPattern . unRules
88--------------------------------------------------------------------------------
88--------------------------------------------------------------------------------
89−-- | Greate a group of compilers
90−-- Imagine you have a page that you want to render, but you also want the raw
91−-- content available on your site.
93−-- > match "test.markdown" $ do
94−-- > route $ setExtension "html"
95−-- > compile pageCompiler
97−-- > match "test.markdown" $ do
99−-- > compile copyPageCompiler
101−-- Will of course conflict! In this case, Hakyll will pick the first matching
102−-- compiler (@pageCompiler@ in this case).
104−-- In case you want to have them both, you can use the 'group' function to
105−-- create a new group. For example,
107−-- > match "test.markdown" $ do
108−-- > route $ setExtension "html"
109−-- > compile pageCompiler
111−-- > group "raw" $ do
112−-- > match "test.markdown" $ do
114−-- > compile copyPageCompiler
116−-- This will put the compiler for the raw content in a separate group
117−-- (@\"raw\"@), which causes it to be compiled as well.
118−group :: String -> Rules a -> Rules a
89+version :: String -> Rules a -> Rules a
119−group g = Rules . local setVersion' . unRules
90+version v = Rules . local setVersion' . unRules
121− setVersion' env = env {rulesVersion = Just g}
92+ setVersion' env = env {rulesVersion = Just v}
124--------------------------------------------------------------------------------
95--------------------------------------------------------------------------------
@@ -130,15 +101,16 @@ group g = Rules . local setVersion' . unRules
130compile :: (Binary a, Typeable a, Writable a)
101compile :: (Binary a, Typeable a, Writable a)
131 => Compiler (Item a) -> Rules ()
102 => Compiler (Item a) -> Rules ()
132compile compiler = do
103compile compiler = do
133− pattern <- Rules $ rulesPattern <$> ask
104+ pattern <- Rules $ rulesPattern <$> ask
105+ version' <- Rules $ rulesVersion <$> ask
134− ids <- case fromLiteral pattern of
106+ ids <- case fromLiteral pattern of
135 Just id' -> return [id']
107 Just id' -> return [id']
136 Nothing -> do
108 Nothing -> do
137− ids <- resources
109+ ids <- getMatches pattern
138 tellResources ids
110 tellResources ids
139 return ids
111 return ids
141− tellCompilers [(id', compiler) | id' <- ids]
113+ tellCompilers [(setVersion version' id', compiler) | id' <- ids]
144--------------------------------------------------------------------------------
116--------------------------------------------------------------------------------
@@ -153,15 +125,3 @@ route route' = Rules $ do
153 version' <- rulesVersion <$> ask
125 version' <- rulesVersion <$> ask
154 unRules $ tellRoute $ matchRoute
126 unRules $ tellRoute $ matchRoute
155 (pattern `mappend` fromVersion version') route'
127 (pattern `mappend` fromVersion version') route'
158−--------------------------------------------------------------------------------
159−-- | Get a list of resources matching the current pattern. This will also set
160−-- the correct group to the identifiers.
161−-- TODO: Make this private?
162−resources :: Rules [Identifier]
163−resources = Rules $ do
164− pattern <- rulesPattern <$> ask
165− provider <- rulesProvider <$> ask
166− g <- rulesVersion <$> ask
167− return $ filterMatches pattern $ map (setVersion g) $ resourceList provider