hakyll 4.6.4.0 → 4.6.5.0
raw patch · 9 files changed
+82/−63 lines, 9 filesdep ~basedep ~deepseqdep ~lrucachePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, deepseq, lrucache, time
API changes (from Hackage documentation)
+ Hakyll.Web.Template.Context: boolField :: String -> (Item a -> Bool) -> Context a
Files
- hakyll.cabal +7/−8
- src/Hakyll/Check.hs +6/−7
- src/Hakyll/Commands.hs +27/−26
- src/Hakyll/Core/Runtime.hs +3/−4
- src/Hakyll/Main.hs +8/−7
- src/Hakyll/Preview/Server.hs +14/−6
- src/Hakyll/Web/Template/Context.hs +13/−1
- tests/Hakyll/Core/Runtime/Tests.hs +4/−2
- tests/Hakyll/Web/Template/Tests.hs +0/−2
hakyll.cabal view
@@ -1,5 +1,5 @@ Name: hakyll-Version: 4.6.4.0+Version: 4.6.5.0 Synopsis: A static website compiler library Description:@@ -88,7 +88,6 @@ Library Ghc-Options: -Wall- Ghc-Prof-Options: -auto-all -caf-all Hs-Source-Dirs: src Exposed-Modules:@@ -150,10 +149,10 @@ containers >= 0.3 && < 0.6, cryptohash >= 0.7 && < 0.12, data-default >= 0.4 && < 0.6,- deepseq >= 1.3 && < 1.4,+ deepseq >= 1.3 && < 1.5, directory >= 1.0 && < 1.3, filepath >= 1.0 && < 1.4,- lrucache >= 1.1.1 && < 1.2,+ lrucache >= 1.1.1 && < 1.3, mtl >= 1 && < 2.3, network >= 2.6 && < 2.7, network-uri >= 2.6 && < 2.7,@@ -168,7 +167,7 @@ regex-tdfa >= 1.1 && < 1.3, tagsoup >= 0.13.1 && < 0.14, text >= 0.11 && < 1.3,- time >= 1.1 && < 1.5+ time >= 1.1 && < 1.6 If flag(previewServer) Build-depends:@@ -237,10 +236,10 @@ containers >= 0.3 && < 0.6, cryptohash >= 0.7 && < 0.12, data-default >= 0.4 && < 0.6,- deepseq >= 1.3 && < 1.4,+ deepseq >= 1.3 && < 1.5, directory >= 1.0 && < 1.3, filepath >= 1.0 && < 1.4,- lrucache >= 1.1.1 && < 1.2,+ lrucache >= 1.1.1 && < 1.3, mtl >= 1 && < 2.3, network >= 2.6 && < 2.7, network-uri >= 2.6 && < 2.7,@@ -255,7 +254,7 @@ regex-tdfa >= 1.1 && < 1.3, tagsoup >= 0.13.1 && < 0.14, text >= 0.11 && < 1.3,- time >= 1.1 && < 1.5+ time >= 1.1 && < 1.6 If flag(previewServer) Build-depends:
src/Hakyll/Check.hs view
@@ -42,7 +42,7 @@ -------------------------------------------------------------------------------- import Hakyll.Core.Configuration-import Hakyll.Core.Logger (Logger, Verbosity)+import Hakyll.Core.Logger (Logger) import qualified Hakyll.Core.Logger as Logger import Hakyll.Core.Util.File import Hakyll.Web.Html@@ -54,9 +54,9 @@ ---------------------------------------------------------------------------------check :: Configuration -> Verbosity -> Check -> IO ExitCode-check config verbosity check' = do- ((), write) <- runChecker checkDestination config verbosity check'+check :: Configuration -> Logger -> Check -> IO ExitCode+check config logger check' = do+ ((), write) <- runChecker checkDestination config logger check' return $ if checkerFaulty write > 0 then ExitFailure 1 else ExitSuccess @@ -91,10 +91,9 @@ ---------------------------------------------------------------------------------runChecker :: Checker a -> Configuration -> Verbosity -> Check+runChecker :: Checker a -> Configuration -> Logger -> Check -> IO (a, CheckerWrite)-runChecker checker config verbosity check' = do- logger <- Logger.new verbosity+runChecker checker config logger check' = do let read' = CheckerRead { checkerConfig = config , checkerLogger = logger
src/Hakyll/Commands.hs view
@@ -14,16 +14,17 @@ ---------------------------------------------------------------------------------import System.Exit (exitWith, ExitCode)-import System.IO.Error (catchIOError) import Control.Applicative-import Control.Monad (void) import Control.Concurrent+import Control.Monad (void)+import System.Exit (ExitCode, exitWith)+import System.IO.Error (catchIOError) -------------------------------------------------------------------------------- import qualified Hakyll.Check as Check import Hakyll.Core.Configuration-import Hakyll.Core.Logger (Verbosity)+import Hakyll.Core.Logger (Logger)+import qualified Hakyll.Core.Logger as Logger import Hakyll.Core.Rules import Hakyll.Core.Rules.Internal import Hakyll.Core.Runtime@@ -31,7 +32,7 @@ -------------------------------------------------------------------------------- #ifdef WATCH_SERVER-import Hakyll.Preview.Poll (watchUpdates)+import Hakyll.Preview.Poll (watchUpdates) #endif #ifdef PREVIEW_SERVER@@ -41,35 +42,36 @@ -------------------------------------------------------------------------------- -- | Build the site-build :: Configuration -> Verbosity -> Rules a -> IO ExitCode-build conf verbosity rules = fst <$> run conf verbosity rules+build :: Configuration -> Logger -> Rules a -> IO ExitCode+build conf logger rules = fst <$> run conf logger rules + -------------------------------------------------------------------------------- -- | Run the checker and exit-check :: Configuration -> Verbosity -> Check.Check -> IO ()-check config verbosity check' = Check.check config verbosity check' >>= exitWith+check :: Configuration -> Logger -> Check.Check -> IO ()+check config logger check' = Check.check config logger check' >>= exitWith -------------------------------------------------------------------------------- -- | Remove the output directories-clean :: Configuration -> IO ()-clean conf = do+clean :: Configuration -> Logger -> IO ()+clean conf logger = do remove $ destinationDirectory conf remove $ storeDirectory conf remove $ tmpDirectory conf where remove dir = do- putStrLn $ "Removing " ++ dir ++ "..."+ Logger.header logger $ "Removing " ++ dir ++ "..." removeDirectory dir -------------------------------------------------------------------------------- -- | Preview the site-preview :: Configuration -> Verbosity -> Rules a -> Int -> IO ()+preview :: Configuration -> Logger -> Rules a -> Int -> IO () #ifdef PREVIEW_SERVER-preview conf verbosity rules port = do+preview conf logger rules port = do deprecatedMessage- watch conf verbosity "0.0.0.0" port True rules+ watch conf logger "0.0.0.0" port True rules where deprecatedMessage = mapM_ putStrLn [ "The preview command has been deprecated." , "Use the watch command for recompilation and serving."@@ -82,9 +84,9 @@ -------------------------------------------------------------------------------- -- | Watch and recompile for changes -watch :: Configuration -> Verbosity -> String -> Int -> Bool -> Rules a -> IO ()+watch :: Configuration -> Logger -> String -> Int -> Bool -> Rules a -> IO () #ifdef WATCH_SERVER-watch conf verbosity host port runServer rules = do+watch conf logger host port runServer rules = do #ifndef mingw32_HOST_OS _ <- forkIO $ watchUpdates conf update #else@@ -97,27 +99,27 @@ server' where update = do- (_, ruleSet) <- run conf verbosity rules+ (_, ruleSet) <- run conf logger rules return $ rulesPattern ruleSet loop = threadDelay 100000 >> loop- server' = if runServer then server conf host port else loop+ server' = if runServer then server conf logger host port else loop #else watch _ _ _ _ _ _ = watchServerDisabled #endif -------------------------------------------------------------------------------- -- | Rebuild the site-rebuild :: Configuration -> Verbosity -> Rules a -> IO ExitCode-rebuild conf verbosity rules =- clean conf >> build conf verbosity rules+rebuild :: Configuration -> Logger -> Rules a -> IO ExitCode+rebuild conf logger rules =+ clean conf logger >> build conf logger rules -------------------------------------------------------------------------------- -- | Start a server-server :: Configuration -> String -> Int -> IO ()+server :: Configuration -> Logger -> String -> Int -> IO () #ifdef PREVIEW_SERVER-server conf host port = do+server conf logger host port = do let destination = destinationDirectory conf- staticServer destination preServeHook host port+ staticServer logger destination preServeHook host port where preServeHook _ = return () #else@@ -156,4 +158,3 @@ , "Alternatively, use an external tool to serve your site directory." ] #endif-
src/Hakyll/Core/Runtime.hs view
@@ -30,7 +30,7 @@ import Hakyll.Core.Identifier import Hakyll.Core.Item import Hakyll.Core.Item.SomeItem-import Hakyll.Core.Logger (Logger, Verbosity)+import Hakyll.Core.Logger (Logger) import qualified Hakyll.Core.Logger as Logger import Hakyll.Core.Provider import Hakyll.Core.Routes@@ -42,10 +42,9 @@ ---------------------------------------------------------------------------------run :: Configuration -> Verbosity -> Rules a -> IO (ExitCode, RuleSet)-run config verbosity rules = do+run :: Configuration -> Logger -> Rules a -> IO (ExitCode, RuleSet)+run config logger rules = do -- Initialization- logger <- Logger.new verbosity Logger.header logger "Initialising..." Logger.message logger "Creating store..." store <- Store.new (inMemoryCache config) $ storeDirectory config
src/Hakyll/Main.hs view
@@ -40,16 +40,17 @@ check' = if internal_links args' then Check.InternalLinks else Check.All + logger <- Logger.new verbosity' case args' of- Build _ -> Commands.build conf verbosity' rules >>= exitWith- Check _ _ -> Commands.check conf verbosity' check'- Clean _ -> Commands.clean conf+ Build _ -> Commands.build conf logger rules >>= exitWith+ Check _ _ -> Commands.check conf logger check'+ Clean _ -> Commands.clean conf logger Deploy _ -> Commands.deploy conf >>= exitWith Help _ -> showHelp- Preview _ p -> Commands.preview conf verbosity' rules p- Rebuild _ -> Commands.rebuild conf verbosity' rules >>= exitWith- Server _ _ _ -> Commands.server conf (host args') (port args')- Watch _ _ p s -> Commands.watch conf verbosity' (host args') p (not s) rules+ Preview _ p -> Commands.preview conf logger rules p+ Rebuild _ -> Commands.rebuild conf logger rules >>= exitWith+ Server _ _ _ -> Commands.server conf logger (host args') (port args')+ Watch _ _ p s -> Commands.watch conf logger (host args') p (not s) rules --------------------------------------------------------------------------------
src/Hakyll/Preview/Server.hs view
@@ -7,14 +7,19 @@ ---------------------------------------------------------------------------------import Control.Monad.Trans (liftIO)+import Control.Monad.Trans (liftIO) import qualified Data.ByteString.Char8 as B-import qualified Snap.Core as Snap-import qualified Snap.Http.Server as Snap-import qualified Snap.Util.FileServe as Snap+import qualified Snap.Core as Snap+import qualified Snap.Http.Server as Snap+import qualified Snap.Util.FileServe as Snap --------------------------------------------------------------------------------+import Hakyll.Core.Logger (Logger)+import qualified Hakyll.Core.Logger as Logger+++-------------------------------------------------------------------------------- -- | Serve a given directory static :: FilePath -- ^ Directory to serve -> (FilePath -> IO ()) -- ^ Pre-serve hook@@ -30,12 +35,14 @@ -------------------------------------------------------------------------------- -- | Main method, runs a static server in the given directory-staticServer :: FilePath -- ^ Directory to serve+staticServer :: Logger -- ^ Logger+ -> FilePath -- ^ Directory to serve -> (FilePath -> IO ()) -- ^ Pre-serve hook -> String -- ^ Host to bind on -> Int -- ^ Port to listen on -> IO () -- ^ Blocks forever-staticServer directory preServe host port =+staticServer logger directory preServe host port = do+ Logger.header logger $ "Listening on http://" ++ host ++ ":" ++ show port Snap.httpServe config $ static directory preServe where -- Snap server config@@ -43,4 +50,5 @@ $ Snap.setPort port $ Snap.setAccessLog Snap.ConfigNoLog $ Snap.setErrorLog Snap.ConfigNoLog+ $ Snap.setVerbose False $ Snap.emptyConfig
src/Hakyll/Web/Template/Context.hs view
@@ -4,6 +4,7 @@ ( ContextField (..) , Context (..) , field+ , boolField , constField , listField , listFieldWith@@ -27,7 +28,7 @@ ---------------------------------------------------------------------------------import Control.Applicative (Alternative (..), (<$>))+import Control.Applicative (Alternative (..), (<$>), pure) import Control.Monad (msum) import Data.List (intercalate) import qualified Data.Map as M@@ -95,6 +96,17 @@ -- on the item -> Context a field key value = field' key (fmap StringField . value)+++--------------------------------------------------------------------------------+-- | Creates a 'field' to use with the @$if()$@ template macro.+boolField+ :: String+ -> (Item a -> Bool)+ -> Context a+boolField name f = field name (\i -> if f i+ then pure (error $ unwords ["no string value for bool field:",name])+ else empty) --------------------------------------------------------------------------------
tests/Hakyll/Core/Runtime/Tests.hs view
@@ -28,7 +28,8 @@ -------------------------------------------------------------------------------- case01 :: Assertion case01 = do- _ <- run testConfiguration Logger.Error $ do+ logger <- Logger.new Logger.Error+ _ <- run testConfiguration logger $ do match "images/*" $ do route idRoute compile copyFileCompiler@@ -65,7 +66,8 @@ -------------------------------------------------------------------------------- case02 :: Assertion case02 = do- _ <- run testConfiguration Logger.Error $ do+ logger <- Logger.new Logger.Error+ _ <- run testConfiguration logger $ do match "images/favicon.ico" $ do route $ gsubRoute "images/" (const "") compile $ makeItem ("Test" :: String)
tests/Hakyll/Web/Template/Tests.hs view
@@ -55,8 +55,6 @@ item <- testCompilerDone store provider "example.md" $ pandocCompiler >>= applyTemplate (itemBody tpl) testContext - writeFile "foo" (itemBody item)- out @=? itemBody item cleanTestEnv