hakyll 4.13.0.1 → 4.13.1.0
raw patch · 16 files changed
+112/−37 lines, 16 filesdep +cryptonitedep +memorydep −cryptohashdep ~basedep ~optparse-applicativedep ~pandoc
Dependencies added: cryptonite, memory
Dependencies removed: cryptohash
Dependency ranges changed: base, optparse-applicative, pandoc, regex-tdfa, template-haskell
Files
- CHANGELOG.md +14/−0
- data/example/site.hs +0/−1
- hakyll.cabal +8/−7
- lib/Hakyll/Core/Compiler/Internal.hs +7/−1
- lib/Hakyll/Core/Identifier.hs +5/−2
- lib/Hakyll/Core/Metadata.hs +1/−1
- lib/Hakyll/Core/Rules/Internal.hs +1/−1
- lib/Hakyll/Core/Store.hs +16/−2
- lib/Hakyll/Main.hs +27/−5
- lib/Hakyll/Preview/Server.hs +1/−0
- lib/Hakyll/Web/Feed.hs +9/−4
- lib/Hakyll/Web/Tags.hs +4/−2
- lib/Hakyll/Web/Template/Context.hs +5/−2
- lib/Hakyll/Web/Template/List.hs +4/−4
- src/Init.hs +1/−1
- web/site.hs +9/−4
CHANGELOG.md view
@@ -4,6 +4,20 @@ # Releases +## Hakyll 4.13.1.0 (2020-02-26)++- Fix timezone parsing bug with time-1.9+- Remove constant field for homepage title in example site (by Liang-Ting Chen)+- Clean up `stack.yaml` (by Hexirp)+- Use crytonite instead of cryptohash (by Hexirp)+- Expose CLI argument parser internals (by Jim McStanton)+- Support GHC-8.8. Add `MonadFail` instances and constraints (by Veronika+ Romashkina)+- Fix file path compatibility with Windows (by Hexirp)+- Fix logging output flushing in `site server` (by robx)+- Fix spacing of command line usage in `hakyll-init` (by robx)+- Add titles to tag fields by default+ ## Hakyll 4.13.0.1 (2019-09-18) - Add missing test files (contribution by Justin Humm)
data/example/site.hs view
@@ -49,7 +49,6 @@ posts <- recentFirst =<< loadAll "posts/*" let indexCtx = listField "posts" postCtx (return posts) `mappend`- constField "title" "Home" `mappend` defaultContext getResourceBody
hakyll.cabal view
@@ -1,5 +1,5 @@ Name: hakyll-Version: 4.13.0.1+Version: 4.13.1.0 Synopsis: A static website compiler library Description:@@ -170,24 +170,25 @@ blaze-markup >= 0.5.1 && < 0.9, bytestring >= 0.9 && < 0.11, containers >= 0.3 && < 0.7,- cryptohash >= 0.7 && < 0.12,+ cryptonite >= 0.25 && < 0.27, data-default >= 0.4 && < 0.8, deepseq >= 1.3 && < 1.5, directory >= 1.0 && < 1.4, file-embed >= 0.0.10.1 && < 0.0.12, filepath >= 1.0 && < 1.5, lrucache >= 1.1.1 && < 1.3,+ memory >= 0.14.18 && < 0.16, mtl >= 1 && < 2.3, network-uri >= 2.6 && < 2.7,- optparse-applicative >= 0.12 && < 0.15,+ optparse-applicative >= 0.12 && < 0.16, parsec >= 3.0 && < 3.2, process >= 1.6 && < 1.7, random >= 1.0 && < 1.2,- regex-tdfa >= 1.1 && < 1.3,+ regex-tdfa >= 1.1 && < 1.4, resourcet >= 1.1 && < 1.3, scientific >= 0.3.4 && < 0.4, tagsoup >= 0.13.1 && < 0.15,- template-haskell >= 2.14 && < 2.15,+ template-haskell >= 2.14 && < 2.16, text >= 0.11 && < 1.3, time >= 1.8 && < 1.10, time-locale-compat >= 0.1 && < 0.2,@@ -231,7 +232,7 @@ Other-Modules: Hakyll.Web.Pandoc.Binary Build-Depends:- pandoc >= 2.0.5 && < 2.8,+ pandoc >= 2.0.5 && < 2.10, pandoc-citeproc >= 0.14 && < 0.17 Cpp-options: -DUSE_PANDOC@@ -326,4 +327,4 @@ base >= 4 && < 5, directory >= 1.0 && < 1.4, filepath >= 1.0 && < 1.5,- pandoc >= 2.0.5 && < 2.8+ pandoc >= 2.0.5 && < 2.10
lib/Hakyll/Core/Compiler/Internal.hs view
@@ -40,6 +40,7 @@ import Control.Applicative (Alternative (..)) import Control.Exception (SomeException, handle) import Control.Monad (forM_)+import qualified Control.Monad.Fail as Fail import Control.Monad.Except (MonadError (..)) import Data.List.NonEmpty (NonEmpty (..)) import qualified Data.List.NonEmpty as NonEmpty@@ -183,9 +184,14 @@ CompilerError e -> return $ CompilerError e {-# INLINE (>>=) #-} - fail = compilerThrow . return+#if !(MIN_VERSION_base(4,13,0))+ fail = Fail.fail {-# INLINE fail #-}+#endif +instance Fail.MonadFail Compiler where+ fail = compilerThrow . return+ {-# INLINE fail #-} -------------------------------------------------------------------------------- instance Applicative Compiler where
lib/Hakyll/Core/Identifier.hs view
@@ -21,7 +21,8 @@ -------------------------------------------------------------------------------- import Control.DeepSeq (NFData (..)) import Data.List (intercalate)-import System.FilePath (dropTrailingPathSeparator, splitPath)+import System.FilePath (dropTrailingPathSeparator, splitPath,+ pathSeparator) --------------------------------------------------------------------------------@@ -72,7 +73,9 @@ -------------------------------------------------------------------------------- -- | Convert an identifier to a relative 'FilePath' toFilePath :: Identifier -> FilePath-toFilePath = identifierPath+toFilePath = intercalate [pathSeparator] . split' . identifierPath+ where+ split' = map dropTrailingPathSeparator . splitPath --------------------------------------------------------------------------------
lib/Hakyll/Core/Metadata.hs view
@@ -66,7 +66,7 @@ -------------------------------------------------------------------------------- -- | Version of 'getMetadataField' which throws an error if the field does not -- exist.-getMetadataField' :: MonadMetadata m => Identifier -> String -> m String+getMetadataField' :: (MonadFail m, MonadMetadata m) => Identifier -> String -> m String getMetadataField' identifier key = do field <- getMetadataField identifier key case field of
lib/Hakyll/Core/Rules/Internal.hs view
@@ -88,7 +88,7 @@ -- | The monad used to compose rules newtype Rules a = Rules { unRules :: RWST RulesRead RuleSet RulesState IO a- } deriving (Monad, Functor, Applicative)+ } deriving (Monad, MonadFail, Functor, Applicative) --------------------------------------------------------------------------------
lib/Hakyll/Core/Store.hs view
@@ -16,7 +16,8 @@ ---------------------------------------------------------------------------------import qualified Crypto.Hash.MD5 as MD5+import qualified Data.ByteArray as BA+import qualified Crypto.Hash as CH import Data.Binary (Binary, decode, encodeFile) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as BL@@ -193,8 +194,21 @@ -------------------------------------------------------------------------------- -- | Mostly meant for internal usage hash :: [String] -> String-hash = toHex . B.unpack . MD5.hash . T.encodeUtf8 . T.pack . intercalate "/"+hash = toHex . B.unpack . hashMD5 . T.encodeUtf8 . T.pack . intercalate "/" where toHex [] = "" toHex (x : xs) | x < 16 = '0' : showHex x (toHex xs) | otherwise = showHex x (toHex xs)+++--------------------------------------------------------------------------------+-- | Hash by MD5+hashMD5 :: B.ByteString -> B.ByteString+hashMD5 x =+ let+ digest :: CH.Digest CH.MD5+ digest = CH.hash x+ bytes :: B.ByteString+ bytes = BA.convert digest+ in+ bytes
lib/Hakyll/Main.hs view
@@ -3,13 +3,22 @@ {-# LANGUAGE CPP #-} module Hakyll.Main- ( hakyll+ ( -- * Entry points+ hakyll , hakyllWith , hakyllWithArgs , hakyllWithExitCode , hakyllWithExitCodeAndArgs++ -- * Command line argument parsers , Options(..) , Command(..)+ , optionParser+ , commandParser+ , defaultParser+ , defaultParserPure+ , defaultParserPrefs+ , defaultParserInfo ) where @@ -72,11 +81,24 @@ -------------------------------------------------------------------------------- defaultParser :: Config.Configuration -> IO Options defaultParser conf =- OA.customExecParser (OA.prefs OA.showHelpOnError)- (OA.info (OA.helper <*> optionParser conf)- (OA.fullDesc <> OA.progDesc- (progName ++ " - Static site compiler created with Hakyll")))+ OA.customExecParser defaultParserPrefs (defaultParserInfo conf) ++--------------------------------------------------------------------------------+defaultParserPure :: Config.Configuration -> [String] -> OA.ParserResult Options+defaultParserPure conf =+ OA.execParserPure defaultParserPrefs (defaultParserInfo conf)+++--------------------------------------------------------------------------------+defaultParserPrefs :: OA.ParserPrefs+defaultParserPrefs = OA.prefs OA.showHelpOnError++--------------------------------------------------------------------------------+defaultParserInfo :: Config.Configuration -> OA.ParserInfo Options+defaultParserInfo conf =+ OA.info (OA.helper <*> optionParser conf) (OA.fullDesc <> OA.progDesc (+ progName ++ " - Static site compiler created with Hakyll")) -------------------------------------------------------------------------------- invokeCommands :: Command -> Config.Configuration ->
lib/Hakyll/Preview/Server.hs view
@@ -24,6 +24,7 @@ -> IO () -- ^ Blocks forever staticServer logger directory host port = do Logger.header logger $ "Listening on http://" ++ host ++ ":" ++ show port+ Logger.flush logger -- ensure this line is logged before Warp errors Warp.runSettings warpSettings $ Static.staticApp (Static.defaultFileServerSettings directory) where
lib/Hakyll/Web/Feed.hs view
@@ -39,24 +39,29 @@ -------------------------------------------------------------------------------- import Data.FileEmbed (makeRelativeToProject)+import System.FilePath ((</>)) -------------------------------------------------------------------------------- rssTemplate :: Template rssTemplate =- $(makeRelativeToProject "data/templates/rss.xml" >>= embedTemplate)+ $(makeRelativeToProject ("data" </> "templates" </> "rss.xml")+ >>= embedTemplate) rssItemTemplate :: Template rssItemTemplate =- $(makeRelativeToProject "data/templates/rss-item.xml" >>= embedTemplate)+ $(makeRelativeToProject ("data" </> "templates" </> "rss-item.xml")+ >>= embedTemplate) atomTemplate :: Template atomTemplate =- $(makeRelativeToProject "data/templates/atom.xml" >>= embedTemplate)+ $(makeRelativeToProject ("data" </> "templates" </> "atom.xml")+ >>= embedTemplate) atomItemTemplate :: Template atomItemTemplate =- $(makeRelativeToProject "data/templates/atom-item.xml" >>= embedTemplate)+ $(makeRelativeToProject ("data" </> "templates" </> "atom-item.xml")+ >>= embedTemplate) --------------------------------------------------------------------------------
lib/Hakyll/Web/Tags.hs view
@@ -326,8 +326,10 @@ -- | Render one tag link simpleRenderLink :: String -> (Maybe FilePath) -> Maybe H.Html simpleRenderLink _ Nothing = Nothing-simpleRenderLink tag (Just filePath) =- Just $ H.a ! A.href (toValue $ toUrl filePath) $ toHtml tag+simpleRenderLink tag (Just filePath) = Just $+ H.a ! A.title (H.stringValue ("All pages tagged '"++tag++"'."))+ ! A.href (toValue $ toUrl filePath)+ $ toHtml tag --------------------------------------------------------------------------------
lib/Hakyll/Web/Template/Context.hs view
@@ -14,7 +14,7 @@ -- -- > $partial(concat("templates/categories/", category))$ ----- This will evaluate the @category@ field in the context, then prepend he path,+-- This will evaluate the @category@ field in the context, then prepend the path, -- and include the referenced file as a template. @@ -365,7 +365,7 @@ -- | Parser to try to extract and parse the time from the @published@ -- field or from the filename. See 'dateField' for more information. -- Exported for user convenience.-getItemUTC :: MonadMetadata m+getItemUTC :: (MonadMetadata m, MonadFail m) => TimeLocale -- ^ Output time locale -> Identifier -- ^ Input page -> m UTCTime -- ^ Parsed UTCTime@@ -385,8 +385,11 @@ parseTime' = parseTimeM True locale formats = [ "%a, %d %b %Y %H:%M:%S %Z"+ , "%a, %d %b %Y %H:%M:%S" , "%Y-%m-%dT%H:%M:%S%Z"+ , "%Y-%m-%dT%H:%M:%S" , "%Y-%m-%d %H:%M:%S%Z"+ , "%Y-%m-%d %H:%M:%S" , "%Y-%m-%d" , "%B %e, %Y %l:%M %p" , "%B %e, %Y"
lib/Hakyll/Web/Template/List.hs view
@@ -60,7 +60,7 @@ -------------------------------------------------------------------------------- -- | Sort pages chronologically. Uses the same method as 'dateField' for -- extracting the date.-chronological :: MonadMetadata m => [Item a] -> m [Item a]+chronological :: (MonadMetadata m, MonadFail m) => [Item a] -> m [Item a] chronological = sortByM $ getItemUTC defaultTimeLocale . itemIdentifier where@@ -71,14 +71,14 @@ -------------------------------------------------------------------------------- -- | The reverse of 'chronological'-recentFirst :: MonadMetadata m => [Item a] -> m [Item a]+recentFirst :: (MonadMetadata m, MonadFail m) => [Item a] -> m [Item a] recentFirst = liftM reverse . chronological -------------------------------------------------------------------------------- -- | Version of 'chronological' which doesn't need the actual items. sortChronological- :: MonadMetadata m => [Identifier] -> m [Identifier]+ :: (MonadMetadata m, MonadFail m) => [Identifier] -> m [Identifier] sortChronological ids = liftM (map itemIdentifier) $ chronological [Item i () | i <- ids] @@ -86,6 +86,6 @@ -------------------------------------------------------------------------------- -- | Version of 'recentFirst' which doesn't need the actual items. sortRecentFirst- :: MonadMetadata m => [Identifier] -> m [Identifier]+ :: (MonadMetadata m, MonadFail m) => [Identifier] -> m [Identifier] sortRecentFirst ids = liftM (map itemIdentifier) $ recentFirst [Item i () | i <- ids]
src/Init.hs view
@@ -46,7 +46,7 @@ ["-f", dstDir] -> createFiles True srcDir files dstDir _ -> do- putStrLn $ "Usage: " ++ progName ++ "[-f] <directory>"+ putStrLn $ "Usage: " ++ progName ++ " [-f] <directory>" exitFailure where
web/site.hs view
@@ -3,12 +3,11 @@ import Control.Arrow (second) import Control.Monad (filterM, forM_) import Data.List (isPrefixOf, sortBy)-import Data.Monoid ((<>)) import Data.Ord (comparing) import Hakyll import System.Directory (copyFile) import System.FilePath (dropTrailingPathSeparator, splitPath)-import Text.Pandoc+import qualified Text.Pandoc as Pandoc --------------------------------------------------------------------------------@@ -67,9 +66,15 @@ match "templates/*" $ compile templateCompiler where withToc = defaultHakyllWriterOptions- { writerTableOfContents = True- , writerTemplate = Just "$toc$\n$body$"+ { Pandoc.writerTableOfContents = True+ , Pandoc.writerTemplate = Just tocTemplate }++ -- When did it get so hard to compile a string to a Pandoc template?+ tocTemplate =+ either error id $ either (error . show) id $+ Pandoc.runPure $ Pandoc.runWithDefaultPartials $+ Pandoc.compileTemplate "" "$toc$\n$body$" --------------------------------------------------------------------------------