@@ -44,7 +44,7 @@ loadMetadata p identifier = do
4444 Nothing -> return M.empty
4545 Just mi' -> loadMetadataFile $ resourceFilePath p mi'
4646
47− gmd <- loadGlobalMetadata p identifier
47+ gmd <- loadGlobalMetadata p $ toFilePath identifier
4848
4949 return (M.unions [md, gmd], body)
5050 where
@@ -141,17 +141,21 @@ page = do
141141
142142--------------------------------------------------------------------------------
143143-- | Load directory-wise metadata
144−loadGlobalMetadata :: Provider -> Identifier -> IO Metadata
145−loadGlobalMetadata p fp = liftM M.fromList $ loadgm fp where
146− loadgm :: Identifier -> IO [(String, String)]
147− loadgm = liftM concat . mapM loadOne . reverse . filter (resourceExists p) . metadataFiles
148− loadOne mfp =
144+loadGlobalMetadata :: Provider -> FilePath -> IO (M.Map String String)
145+loadGlobalMetadata p fp = liftM M.fromList $ loadgm $ takeDirectory fp where
146+ loadgm :: FilePath -> IO [(String, String)]
147+ loadgm dir | dir == "." = return []
148+ | otherwise = do
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
153+ loadOne mfp dir =
149154 let path = resourceFilePath p mfp
150− dir = takeDirectory $ toFilePath mfp
151155 -- TODO: It might be better to print warning and continue
152156 in either (error.show) (findMetadata dir) . P.parse namedMetadata path <$> readFile path
153157 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)
155159
156160namedMetadata :: Parser [(String, [(String, String)])]
157161namedMetadata = liftA2 (:) (namedMetadataBlock False) $ P.many $ namedMetadataBlock True