packages feed

hakyll 3.2.5.1 → 3.2.6.0

raw patch · 3 files changed

+71/−34 lines, 3 filesdep ~binarydep ~bytestringdep ~containers

Dependency ranges changed: binary, bytestring, containers, directory, filepath, mtl, old-locale, old-time, pandoc, process, regex-base, regex-pcre, time

Files

hakyll.cabal view
@@ -1,5 +1,5 @@ Name:    hakyll-Version: 3.2.5.1+Version: 3.2.6.0  Synopsis: A static website compiler library Description:@@ -60,25 +60,25 @@    Build-Depends:     base        >= 4      && < 5,-    binary      >= 0.5    && < 1.0,+    binary      >= 0.5    && < 0.6,     blaze-html  >= 0.4    && < 0.6,-    bytestring  >= 0.9    && < 1.0,+    bytestring  >= 0.9    && < 0.10,     citeproc-hs >= 0.3.2  && < 0.4,-    containers  >= 0.3    && < 1.0,+    containers  >= 0.3    && < 0.5,     cryptohash  >= 0.7    && < 0.8,-    directory   >= 1.0    && < 1.3,-    filepath    >= 1.0    && < 2.0,+    directory   >= 1.0    && < 1.2,+    filepath    >= 1.0    && < 1.4,     hamlet      >= 0.10.3 && < 0.11,-    mtl         >= 1      && < 3.0,-    old-locale  >= 1.0    && < 2.0,-    old-time    >= 1.0    && < 1.3,-    pandoc      >= 1.6    && < 2.0,+    mtl         >= 1      && < 2.1,+    old-locale  >= 1.0    && < 1.1,+    old-time    >= 1.0    && < 1.2,+    pandoc      >= 1.9    && < 1.10,     parsec      >= 3.0    && < 3.2,-    process     >= 1.0    && < 1.4,-    regex-base  >= 0.93   && < 1.0,-    regex-pcre  >= 0.93   && < 1.0,+    process     >= 1.0    && < 1.2,+    regex-base  >= 0.93   && < 0.94,+    regex-pcre  >= 0.93   && < 0.95,     tagsoup     >= 0.12.6 && < 0.13,-    time        >= 1.1    && < 1.3,+    time        >= 1.1    && < 1.5,     unix        >= 2.4    && < 2.6    Exposed-Modules:
src/Hakyll/Web/Page/Metadata.hs view
@@ -16,19 +16,24 @@     , renderModificationTimeWith     , copyBodyToField     , copyBodyFromField+    , comparePagesByDate     ) where -import Prelude hiding (id)-import Control.Category (id) import Control.Arrow (Arrow, arr, (>>>), (***), (&&&))+import Control.Category (id)+import Control.Monad (msum) import Data.List (intercalate) import Data.Maybe (fromMaybe)-import Data.Time.Clock (UTCTime)-import Data.Time.Format (parseTime, formatTime)-import qualified Data.Map as M+import Data.Ord (comparing)+import Prelude hiding (id) import System.FilePath (takeFileName) import System.Locale (TimeLocale, defaultTimeLocale)+import qualified Data.Map as M +import Data.Time.Calendar (Day (..))+import Data.Time.Clock (UTCTime (..))+import Data.Time.Format (parseTime, formatTime)+ import Hakyll.Web.Page.Internal import Hakyll.Core.Util.String import Hakyll.Core.Identifier@@ -118,12 +123,24 @@           -> Page a  -- ^ Resulting page copyField src dst = renderField src dst id --- | When the metadata has a field called @path@ in a--- @folder/yyyy-mm-dd-title.extension@ format (the convention for pages),--- this function can render the date.+-- | When the metadata has a field called @published@ in one of the+-- following formats then this function can render the date. ----- > renderDate "date" "%B %e, %Y" "Date unknown"+--   * @Sun, 01 Feb 2000 13:00:00 UT@ (RSS date format) --+--   * @2000-02-01T13:00:00Z@ (Atom date format)+--+--   * @February 1, 2000 1:00 PM@ (PM is usually uppercase)+--+--   * @February 1, 2000@ (assumes 12:00 AM for the time)+--+-- Alternatively, when the metadata has a field called @path@ in a+-- @folder/yyyy-mm-dd-title.extension@ format (the convention for pages)+-- and no @published@ metadata field set, this function can render+-- the date.+--+-- > renderDateField "date" "%B %e, %Y" "Date unknown"+-- -- Will render something like @January 32, 2010@. -- renderDateField :: String  -- ^ Key in which the rendered date should be placed@@ -143,19 +160,31 @@                     -> String      -- ^ Default value                     -> Page a      -- ^ Target page                     -> Page a      -- ^ Resulting page-renderDateFieldWith locale key format defaultValue =-    renderField "path" key renderDate'+renderDateFieldWith locale key format defaultValue page =+    setField key renderTimeString page   where-    renderDate' filePath = fromMaybe defaultValue $ do-        let dateString = intercalate "-" $ take 3-                       $ splitAll "-" $ takeFileName filePath-        time <- parseTime defaultTimeLocale-                          "%Y-%m-%d"-                          dateString :: Maybe UTCTime+    renderTimeString = fromMaybe defaultValue $ do+        time <- getUTCMaybe locale page         return $ formatTime locale format time +-- | Parser to try to extract and parse the time from the @published@+-- field or from the filename. See 'renderDateField' for more information.+getUTCMaybe :: TimeLocale     -- ^ Output time locale+            -> Page a         -- ^ Input page+            -> Maybe UTCTime  -- ^ Parsed UTCTime+getUTCMaybe locale page = msum+    [ fromPublished "%a, %d %b %Y %H:%M:%S UT"+    , fromPublished "%Y-%m-%dT%H:%M:%SZ"+    , fromPublished "%B %e, %Y %l:%M %p"+    , fromPublished "%B %e, %Y"+    , getFieldMaybe "path" page >>= parseTime' "%Y-%m-%d" .+        intercalate "-" . take 3 . splitAll "-" . takeFileName+    ]+  where+    fromPublished f  = getFieldMaybe "published" page >>= parseTime' f+    parseTime' f str = parseTime locale f str+ -- | Set the modification time as a field in the page--- renderModificationTime :: String                        -- ^ Destination key                        -> String@@ -189,3 +218,11 @@                   -> Page String  -- ^ Target page                   -> Page String  -- ^ Resulting page copyBodyFromField key page = fmap (const $ getField key page) page++-- | Compare pages by the date and time parsed as in 'renderDateField',+-- where 'LT' implies earlier, and 'GT' implies later. For more details,+-- see 'renderDateField'.+comparePagesByDate :: Page a -> Page a -> Ordering+comparePagesByDate = comparing $ fromMaybe zero . getUTCMaybe defaultTimeLocale+  where+    zero = UTCTime (ModifiedJulianDay 0) 0
src/Hakyll/Web/Pandoc/Biblio.hs view
@@ -67,7 +67,7 @@         state' = state {stateCitations = stateCitations state ++ cits}     pandocPage <- pageReadPandocWithA -< (state', page)     let pandoc = pageBody pandocPage-    pandoc' <- unsafeCompiler (tuc processBiblio) -< (csl', refs', pandoc)+    pandoc' <- unsafeCompiler processBiblio' -< (csl', refs', pandoc)     returnA -< pandocPage {pageBody = pandoc'}   where-    tuc f (x, y, z) = f x y z+    processBiblio' (c, r, p) = processBiblio c Nothing r p