hakyll 3.2.0.6 → 3.2.0.7
raw patch · 5 files changed
+46/−6 lines, 5 files
Files
- hakyll.cabal +1/−1
- src/Hakyll/Core/Compiler.hs +1/−0
- src/Hakyll/Core/Resource/Provider.hs +9/−5
- src/Hakyll/Core/Resource/Provider/File.hs +10/−0
- src/Hakyll/Web/Page/Metadata.hs +25/−0
hakyll.cabal view
@@ -1,5 +1,5 @@ Name: hakyll-Version: 3.2.0.6+Version: 3.2.0.7 Synopsis: A static website compiler library Description:
src/Hakyll/Core/Compiler.hs view
@@ -98,6 +98,7 @@ , getRouteFor , getResourceString , getResourceLBS+ , getResourceWith , fromDependency , require_ , require
src/Hakyll/Core/Resource/Provider.hs view
@@ -23,6 +23,7 @@ import Data.Map (Map) import qualified Data.Map as M +import Data.Time (UTCTime) import qualified Crypto.Hash.MD5 as MD5 import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as LB@@ -34,13 +35,15 @@ -- data ResourceProvider = ResourceProvider { -- | A list of all resources this provider is able to provide- resourceList :: [Resource]+ resourceList :: [Resource] , -- | Retrieve a certain resource as string- resourceString :: Resource -> IO String+ resourceString :: Resource -> IO String , -- | Retrieve a certain resource as lazy bytestring- resourceLBS :: Resource -> IO LB.ByteString+ resourceLBS :: Resource -> IO LB.ByteString+ , -- | Check when a resource was last modified+ resourceModificationTime :: Resource -> IO UTCTime , -- | Cache keeping track of modified items- resourceModifiedCache :: MVar (Map Resource Bool)+ resourceModifiedCache :: MVar (Map Resource Bool) } -- | Create a resource provider@@ -48,8 +51,9 @@ makeResourceProvider :: [Resource] -- ^ Resource list -> (Resource -> IO String) -- ^ String reader -> (Resource -> IO LB.ByteString) -- ^ ByteString reader+ -> (Resource -> IO UTCTime) -- ^ Time checker -> IO ResourceProvider -- ^ Resulting provider-makeResourceProvider l s b = ResourceProvider l s b <$> newMVar M.empty+makeResourceProvider l s b t = ResourceProvider l s b t <$> newMVar M.empty -- | Check if a given identifier has a resource --
src/Hakyll/Core/Resource/Provider/File.hs view
@@ -6,6 +6,10 @@ import Control.Applicative ((<$>)) +import Data.Time (readTime)+import System.Directory (getModificationTime)+import System.Locale (defaultTimeLocale)+import System.Time (formatCalendarTime, toCalendarTime) import qualified Data.ByteString.Lazy as LB import Hakyll.Core.Resource@@ -22,3 +26,9 @@ getRecursiveContents False "." makeResourceProvider list (readFile . unResource) (LB.readFile . unResource)+ mtime+ where+ mtime (Resource r) = do+ ct <- toCalendarTime =<< getModificationTime r+ let str = formatCalendarTime defaultTimeLocale "%s" ct+ return $ readTime defaultTimeLocale "%s" str
src/Hakyll/Web/Page/Metadata.hs view
@@ -12,6 +12,8 @@ , copyField , renderDateField , renderDateFieldWith+ , renderModificationTime+ , renderModificationTimeWith , copyBodyToField , copyBodyFromField ) where@@ -31,6 +33,7 @@ import Hakyll.Core.Util.String import Hakyll.Core.Identifier import Hakyll.Core.Compiler+import Hakyll.Core.Resource.Provider -- | Get a metadata field. If the field does not exist, the empty string is -- returned.@@ -150,6 +153,28 @@ "%Y-%m-%d" dateString :: Maybe UTCTime return $ formatTime locale format time++-- | Set the modification time as a field in the page+--+renderModificationTime :: String+ -- ^ Destination key+ -> String+ -- ^ Format to use on the time+ -> Compiler (Page String) (Page String)+ -- ^ Resulting compiler+renderModificationTime = renderModificationTimeWith defaultTimeLocale++renderModificationTimeWith :: TimeLocale+ -- ^ Output time locale+ -> String+ -- ^ Destination key+ -> String+ -- ^ Format to use on the time+ -> Compiler (Page String) (Page String)+ -- ^ Resulting compiler+renderModificationTimeWith locale key format =+ id &&& (getResource >>> getResourceWith resourceModificationTime) >>>+ setFieldA key (arr (formatTime locale format)) -- | Copy the body of a page to a metadata field --