diff options
author | Alexey Kreshchuk <akrsch@gmail.com> | 2014-01-22 00:11:51 +0400 |
---|---|---|
committer | Alexey Kreshchuk <akrsch@gmail.com> | 2014-01-22 00:11:51 +0400 |
commit | dbabe0325b9d7bca3b14c2b33e686b8151fa79aa (patch) | |
tree | 797c4edad131143455f86f7d0226a7a040b1c02e /src/Hakyll | |
parent | d406db44e39d310a72ca6bb014ed882f0e883995 (diff) | |
download | hakyll-dbabe0325b9d7bca3b14c2b33e686b8151fa79aa.tar.gz |
Unified code for global and external metadata
Didn't clean up unused code though
Diffstat (limited to 'src/Hakyll')
-rw-r--r-- | src/Hakyll/Core/Metadata.hs | 3 | ||||
-rw-r--r-- | src/Hakyll/Core/Provider/Metadata.hs | 12 | ||||
-rw-r--r-- | src/Hakyll/Core/Rules/Default.hs | 1 |
3 files changed, 10 insertions, 6 deletions
diff --git a/src/Hakyll/Core/Metadata.hs b/src/Hakyll/Core/Metadata.hs index a330636..a123c18 100644 --- a/src/Hakyll/Core/Metadata.hs +++ b/src/Hakyll/Core/Metadata.hs @@ -67,7 +67,8 @@ makePatternDependency pattern = do -------------------------------------------------------------------------------- -- | Returns a list of all directory-wise metadata files, subdir first, global last metadataFiles :: Identifier -> [Identifier] -metadataFiles = go . takeDirectory . toFilePath where +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 a54b84a..889291f 100644 --- a/src/Hakyll/Core/Provider/Metadata.hs +++ b/src/Hakyll/Core/Provider/Metadata.hs @@ -46,7 +46,7 @@ loadMetadata p identifier = do gmd <- loadGlobalMetadata p identifier - return (M.unions [md, emd, gmd], body) + return (M.unions [md, gmd], body) where normal = setVersion Nothing identifier fp = resourceFilePath p identifier @@ -154,11 +154,13 @@ loadGlobalMetadata p fp = liftM M.fromList $ loadgm fp where concatMap snd . filter (flip matches fp . fromGlob . normalise . combine dir . fst) namedMetadata :: Parser [(String, [(String, String)])] -namedMetadata = P.many namedMetadataBlock +namedMetadata = liftA2 (:) (namedMetadataBlock False) $ P.many $ namedMetadataBlock True -namedMetadataBlock :: Parser (String, [(String, String)]) -namedMetadataBlock = do - name <- P.many1 (P.char '-') *> P.many inlineSpace *> P.manyTill P.anyChar newline +namedMetadataBlock :: Bool -> Parser (String, [(String, String)]) +namedMetadataBlock isNamed = do + name <- if isNamed + then P.many1 (P.char '-') *> P.many inlineSpace *> P.manyTill P.anyChar newline + else pure "**" metadata' <- metadata P.skipMany P.space return (name, metadata') diff --git a/src/Hakyll/Core/Rules/Default.hs b/src/Hakyll/Core/Rules/Default.hs index ccca1bd..fee78c5 100644 --- a/src/Hakyll/Core/Rules/Default.hs +++ b/src/Hakyll/Core/Rules/Default.hs @@ -14,6 +14,7 @@ internalRules :: Rules () internalRules = do match "metadata" $ compile $ makeItem () match "**/metadata" $ compile $ makeItem () + match "**.metadata" $ compile $ makeItem () -------------------------------------------------------------------------------- addMetadataDependencies :: Compiler () |