@@ -44,7 +44,7 @@ loadMetadata p identifier = do
44 Nothing -> return M.empty
44 Nothing -> return M.empty
45 Just mi' -> loadMetadataFile $ resourceFilePath p mi'
45 Just mi' -> loadMetadataFile $ resourceFilePath p mi'
47− gmd <- loadGlobalMetadata p identifier
47+ gmd <- loadGlobalMetadata p $ toFilePath identifier
49 return (M.unions [md, gmd], body)
49 return (M.unions [md, gmd], body)
@@ -141,17 +141,21 @@ page = do
142--------------------------------------------------------------------------------
142--------------------------------------------------------------------------------
143-- | Load directory-wise metadata
143-- | Load directory-wise metadata
144−loadGlobalMetadata :: Provider -> Identifier -> IO Metadata
144+loadGlobalMetadata :: Provider -> FilePath -> IO (M.Map String String)
145−loadGlobalMetadata p fp = liftM M.fromList $ loadgm fp where
145+loadGlobalMetadata p fp = liftM M.fromList $ loadgm $ takeDirectory fp where
146− loadgm :: Identifier -> IO [(String, String)]
146+ loadgm :: FilePath -> IO [(String, String)]
147− loadgm = liftM concat . mapM loadOne . reverse . filter (resourceExists p) . metadataFiles
147+ loadgm dir | dir == "." = return []
149+ let mfp = fromFilePath $ combine dir "metadata"
150+ md <- if resourceExists p mfp then loadOne mfp dir else return []
151+ others <- loadgm (takeDirectory dir)
152+ return $ others ++ md
148− loadOne mfp =
153+ loadOne mfp dir =
149 let path = resourceFilePath p mfp
154 let path = resourceFilePath p mfp
150− dir = takeDirectory $ toFilePath mfp
151 -- TODO: It might be better to print warning and continue
155 -- TODO: It might be better to print warning and continue
152 in either (error.show) (findMetadata dir) . P.parse namedMetadata path <$> readFile path
156 in either (error.show) (findMetadata dir) . P.parse namedMetadata path <$> readFile path
153 findMetadata dir =
157 findMetadata dir =
154− concatMap snd . filter (flip matches fp . fromGlob . combine dir . fst)
158+ concatMap snd . filter (flip matches (fromFilePath fp) . fromGlob . combine dir . fst)
156namedMetadata :: Parser [(String, [(String, String)])]
160namedMetadata :: Parser [(String, [(String, String)])]
157namedMetadata = liftA2 (:) (namedMetadataBlock False) $ P.many $ namedMetadataBlock True
161namedMetadata = liftA2 (:) (namedMetadataBlock False) $ P.many $ namedMetadataBlock True