From 89f324f81b40d6818e6307794fe06b60053adbc0 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 8 Nov 2012 12:45:26 +0100 Subject: Pick metadata parsing from old develop --- src/Hakyll/Core/Resource.hs | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) (limited to 'src/Hakyll/Core/Resource.hs') diff --git a/src/Hakyll/Core/Resource.hs b/src/Hakyll/Core/Resource.hs index 566bb26..0a43fc2 100644 --- a/src/Hakyll/Core/Resource.hs +++ b/src/Hakyll/Core/Resource.hs @@ -1,31 +1,51 @@ +-------------------------------------------------------------------------------- -- | Module exporting the simple 'Resource' type --- module Hakyll.Core.Resource - ( Resource - , unResource + ( -- * Constructing and deconstructing resources + Resource , resource + , unResource + + -- * Conversions to and from identifiers , fromIdentifier , toIdentifier + + -- * TODO: Move me + , Metadata ) where -import Hakyll.Core.Identifier +-------------------------------------------------------------------------------- +import Data.Map (Map) + + +-------------------------------------------------------------------------------- +import Hakyll.Core.Identifier + + +-------------------------------------------------------------------------------- -- | A resource --- newtype Resource = Resource {unResource :: FilePath} deriving (Eq, Show, Ord) + +-------------------------------------------------------------------------------- -- | Smart constructor to ensure we have @/@ as path separator --- resource :: FilePath -> Resource resource = fromIdentifier . parseIdentifier --- | Create a resource from an identifier --- + +-------------------------------------------------------------------------------- +-- | Find the resource for an identifier fromIdentifier :: Identifier a -> Resource fromIdentifier = Resource . toFilePath --- | Map the resource to an identifier. Note that the group will not be set! --- + +-------------------------------------------------------------------------------- +-- | Convert a resource to an identifier toIdentifier :: Resource -> Identifier a toIdentifier = parseIdentifier . unResource + + +-------------------------------------------------------------------------------- +type Metadata = Map String String -- cgit v1.2.3