From 6552dd5bc01e122d550e9ce664646a4c719145f7 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Wed, 26 Mar 2014 11:30:08 +0100 Subject: Revert "Track metadata dependencies" This reverts commit 712ffa39b5857fdc5cdae1db38a177267a430b11. Conflicts: src/Hakyll/Core/Metadata.hs src/Hakyll/Core/Rules/Default.hs --- src/Hakyll/Core/Metadata.hs | 11 ----------- src/Hakyll/Core/Provider/Metadata.hs | 20 ++++++++++++-------- src/Hakyll/Core/Rules/Default.hs | 24 ------------------------ src/Hakyll/Core/Runtime.hs | 5 ++--- 4 files changed, 14 insertions(+), 46 deletions(-) delete mode 100644 src/Hakyll/Core/Rules/Default.hs (limited to 'src/Hakyll') 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' -- cgit v1.2.3