diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2014-03-26 11:30:08 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2014-03-26 12:05:38 +0100 |
commit | 6552dd5bc01e122d550e9ce664646a4c719145f7 (patch) | |
tree | 8ce6745c3b643cd183afd4db7e5cd7d5e967d786 /src/Hakyll/Core/Provider | |
parent | e5446fd4017949e1735251abed8644d90983eb3a (diff) | |
download | hakyll-6552dd5bc01e122d550e9ce664646a4c719145f7.tar.gz |
Revert "Track metadata dependencies"
This reverts commit 712ffa39b5857fdc5cdae1db38a177267a430b11.
Conflicts:
src/Hakyll/Core/Metadata.hs
src/Hakyll/Core/Rules/Default.hs
Diffstat (limited to 'src/Hakyll/Core/Provider')
-rw-r--r-- | src/Hakyll/Core/Provider/Metadata.hs | 20 |
1 files changed, 12 insertions, 8 deletions
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 |