summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2014-03-26 11:30:08 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2014-03-26 12:05:38 +0100
commit6552dd5bc01e122d550e9ce664646a4c719145f7 (patch)
tree8ce6745c3b643cd183afd4db7e5cd7d5e967d786
parente5446fd4017949e1735251abed8644d90983eb3a (diff)
downloadhakyll-6552dd5bc01e122d550e9ce664646a4c719145f7.tar.gz
Revert "Track metadata dependencies"
This reverts commit 712ffa39b5857fdc5cdae1db38a177267a430b11. Conflicts: src/Hakyll/Core/Metadata.hs src/Hakyll/Core/Rules/Default.hs
-rw-r--r--hakyll.cabal1
-rw-r--r--src/Hakyll/Core/Metadata.hs11
-rw-r--r--src/Hakyll/Core/Provider/Metadata.hs20
-rw-r--r--src/Hakyll/Core/Rules/Default.hs24
-rw-r--r--src/Hakyll/Core/Runtime.hs5
5 files changed, 14 insertions, 47 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 9173bac..cb8e8ed 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -132,7 +132,6 @@ Library
Hakyll.Core.Provider.Metadata
Hakyll.Core.Provider.MetadataCache
Hakyll.Core.Rules.Internal
- Hakyll.Core.Rules.Default
Hakyll.Core.Runtime
Hakyll.Core.Store
Hakyll.Core.Util.File
diff --git a/src/Hakyll/Core/Metadata.hs b/src/Hakyll/Core/Metadata.hs
index a123c18..7902b94 100644
--- a/src/Hakyll/Core/Metadata.hs
+++ b/src/Hakyll/Core/Metadata.hs
@@ -5,7 +5,6 @@ module Hakyll.Core.Metadata
, getMetadataField
, getMetadataField'
, makePatternDependency
- , metadataFiles
) where
@@ -13,7 +12,6 @@ module Hakyll.Core.Metadata
import Control.Monad (forM)
import Data.Map (Map)
import qualified Data.Map as M
-import System.FilePath.Posix ((</>), takeDirectory)
--------------------------------------------------------------------------------
@@ -63,12 +61,3 @@ makePatternDependency :: MonadMetadata m => Pattern -> m Dependency
makePatternDependency pattern = do
matches' <- getMatches pattern
return $ PatternDependency pattern matches'
-
---------------------------------------------------------------------------------
--- | Returns a list of all directory-wise metadata files, subdir first, global last
-metadataFiles :: Identifier -> [Identifier]
-metadataFiles identifier = local : go (takeDirectory $ toFilePath identifier) where
- go "." = [fromFilePath "metadata"]
- go dir = fromFilePath (dir </> "metadata") : go (takeDirectory dir)
- local = fromFilePath $ toFilePath identifier ++ ".metadata"
-
diff --git a/src/Hakyll/Core/Provider/Metadata.hs b/src/Hakyll/Core/Provider/Metadata.hs
index af2dd43..0101d25 100644
--- a/src/Hakyll/Core/Provider/Metadata.hs
+++ b/src/Hakyll/Core/Provider/Metadata.hs
@@ -44,7 +44,7 @@ loadMetadata p identifier = do
Nothing -> return M.empty
Just mi' -> loadMetadataFile $ resourceFilePath p mi'
- gmd <- loadGlobalMetadata p identifier
+ gmd <- loadGlobalMetadata p $ toFilePath identifier
return (M.unions [md, gmd], body)
where
@@ -141,17 +141,21 @@ page = do
--------------------------------------------------------------------------------
-- | Load directory-wise metadata
-loadGlobalMetadata :: Provider -> Identifier -> IO Metadata
-loadGlobalMetadata p fp = liftM M.fromList $ loadgm fp where
- loadgm :: Identifier -> IO [(String, String)]
- loadgm = liftM concat . mapM loadOne . reverse . filter (resourceExists p) . metadataFiles
- loadOne mfp =
+loadGlobalMetadata :: Provider -> FilePath -> IO (M.Map String String)
+loadGlobalMetadata p fp = liftM M.fromList $ loadgm $ takeDirectory fp where
+ loadgm :: FilePath -> IO [(String, String)]
+ loadgm dir | dir == "." = return []
+ | otherwise = do
+ let mfp = fromFilePath $ combine dir "metadata"
+ md <- if resourceExists p mfp then loadOne mfp dir else return []
+ others <- loadgm (takeDirectory dir)
+ return $ others ++ md
+ loadOne mfp dir =
let path = resourceFilePath p mfp
- dir = takeDirectory $ toFilePath mfp
-- TODO: It might be better to print warning and continue
in either (error.show) (findMetadata dir) . P.parse namedMetadata path <$> readFile path
findMetadata dir =
- concatMap snd . filter (flip matches fp . fromGlob . combine dir . fst)
+ concatMap snd . filter (flip matches (fromFilePath fp) . fromGlob . combine dir . fst)
namedMetadata :: Parser [(String, [(String, String)])]
namedMetadata = liftA2 (:) (namedMetadataBlock False) $ P.many $ namedMetadataBlock True
diff --git a/src/Hakyll/Core/Rules/Default.hs b/src/Hakyll/Core/Rules/Default.hs
deleted file mode 100644
index fee78c5..0000000
--- a/src/Hakyll/Core/Rules/Default.hs
+++ /dev/null
@@ -1,24 +0,0 @@
-{-# LANGUAGE OverloadedStrings #-}
-module Hakyll.Core.Rules.Default
- ( internalRules
- , addMetadataDependencies
- )
-where
-import Hakyll.Core.Rules
-import Hakyll.Core.Compiler
-import Hakyll.Core.Compiler.Internal (compilerTellDependencies)
-import Hakyll.Core.Metadata (getMatches, metadataFiles)
-import Hakyll.Core.Identifier.Pattern(fromList)
-
-internalRules :: Rules ()
-internalRules = do
- match "metadata" $ compile $ makeItem ()
- match "**/metadata" $ compile $ makeItem ()
- match "**.metadata" $ compile $ makeItem ()
-
---------------------------------------------------------------------------------
-addMetadataDependencies :: Compiler ()
-addMetadataDependencies =
- compilerTellDependencies . map IdentifierDependency =<< getMatches . fromList =<< fmap metadataFiles getUnderlying
-
-
diff --git a/src/Hakyll/Core/Runtime.hs b/src/Hakyll/Core/Runtime.hs
index 4ef30df..824d11b 100644
--- a/src/Hakyll/Core/Runtime.hs
+++ b/src/Hakyll/Core/Runtime.hs
@@ -35,7 +35,6 @@ import qualified Hakyll.Core.Logger as Logger
import Hakyll.Core.Provider
import Hakyll.Core.Routes
import Hakyll.Core.Rules.Internal
-import Hakyll.Core.Rules.Default
import Hakyll.Core.Store (Store)
import qualified Hakyll.Core.Store as Store
import Hakyll.Core.Util.File
@@ -54,7 +53,7 @@ run config verbosity rules = do
provider <- newProvider store (shouldIgnoreFile config) $
providerDirectory config
Logger.message logger "Running rules..."
- ruleSet <- runRules (internalRules >> rules) provider
+ ruleSet <- runRules rules provider
-- Get old facts
mOldFacts <- Store.get store factsKey
@@ -187,7 +186,7 @@ chase trail id'
config <- runtimeConfiguration <$> ask
Logger.debug logger $ "Processing " ++ show id'
- let compiler = addMetadataDependencies >> todo M.! id'
+ let compiler = todo M.! id'
read' = CompilerRead
{ compilerConfig = config
, compilerUnderlying = id'