packages feed

hakyll 4.4.3.2 → 4.5.0.0

raw patch · 8 files changed

+90/−43 lines, 8 filesdep ~QuickCheckdep ~blaze-htmldep ~blaze-markup

Dependency ranges changed: QuickCheck, blaze-html, blaze-markup, pandoc-citeproc, regex-tdfa

Files

hakyll.cabal view
@@ -1,5 +1,5 @@ Name:    hakyll-Version: 4.4.3.2+Version: 4.5.0.0  Synopsis: A static website compiler library Description:@@ -142,8 +142,8 @@   Build-Depends:     base            >= 4      && < 5,     binary          >= 0.5    && < 0.8,-    blaze-html      >= 0.5    && < 0.7,-    blaze-markup    >= 0.5.1  && < 0.6,+    blaze-html      >= 0.5    && < 0.8,+    blaze-markup    >= 0.5.1  && < 0.7,     bytestring      >= 0.9    && < 0.11,     cmdargs         >= 0.10   && < 0.11,     containers      >= 0.3    && < 0.6,@@ -158,12 +158,12 @@     old-locale      >= 1.0    && < 1.1,     old-time        >= 1.0    && < 1.2,     pandoc          >= 1.12   && < 1.13,-    pandoc-citeproc >= 0.1    && < 0.3,+    pandoc-citeproc >= 0.1    && < 0.4,     parsec          >= 3.0    && < 3.2,     process         >= 1.0    && < 1.3,     random          >= 1.0    && < 1.1,     regex-base      >= 0.93   && < 0.94,-    regex-tdfa      >= 1.1    && < 1.2,+    regex-tdfa      >= 1.1    && < 1.3,     tagsoup         >= 0.13.1 && < 0.14,     text            >= 0.11   && < 1.2,     time            >= 1.1    && < 1.5@@ -221,15 +221,15 @@    Build-Depends:     HUnit                      >= 1.2 && < 1.3,-    QuickCheck                 >= 2.4 && < 2.7,+    QuickCheck                 >= 2.4 && < 2.8,     test-framework             >= 0.4 && < 0.9,     test-framework-hunit       >= 0.3 && < 0.4,     test-framework-quickcheck2 >= 0.3 && < 0.4,     -- Copy pasted from hakyll dependencies:     base            >= 4      && < 5,     binary          >= 0.5    && < 0.8,-    blaze-html      >= 0.5    && < 0.7,-    blaze-markup    >= 0.5.1  && < 0.6,+    blaze-html      >= 0.5    && < 0.8,+    blaze-markup    >= 0.5.1  && < 0.7,     bytestring      >= 0.9    && < 0.11,     cmdargs         >= 0.10   && < 0.11,     containers      >= 0.3    && < 0.6,@@ -244,12 +244,12 @@     old-locale      >= 1.0    && < 1.1,     old-time        >= 1.0    && < 1.2,     pandoc          >= 1.12   && < 1.13,-    pandoc-citeproc >= 0.1    && < 0.3,+    pandoc-citeproc >= 0.1    && < 0.4,     parsec          >= 3.0    && < 3.2,     process         >= 1.0    && < 1.3,     random          >= 1.0    && < 1.1,     regex-base      >= 0.93   && < 0.94,-    regex-tdfa      >= 1.1    && < 1.2,+    regex-tdfa      >= 1.1    && < 1.3,     tagsoup         >= 0.13.1 && < 0.14,     text            >= 0.11   && < 1.2,     time            >= 1.1    && < 1.5
src/Hakyll/Check.hs view
@@ -57,7 +57,7 @@ check :: Configuration -> Verbosity -> Check -> IO ExitCode check config verbosity check' = do     ((), write) <- runChecker checkDestination config verbosity check'-    return $ if checkerFaulty write >= 0 then ExitFailure 1 else ExitSuccess+    return $ if checkerFaulty write > 0 then ExitFailure 1 else ExitSuccess   --------------------------------------------------------------------------------
src/Hakyll/Commands.hs view
@@ -9,7 +9,7 @@     , rebuild     , server     , deploy-    , watch +    , watch     ) where  @@ -67,7 +67,7 @@ #ifdef PREVIEW_SERVER preview conf verbosity rules port  = do     deprecatedMessage-    watch conf verbosity port True rules+    watch conf verbosity "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."@@ -80,22 +80,27 @@ -------------------------------------------------------------------------------- -- | Watch and recompile for changes -watch :: Configuration -> Verbosity -> Int -> Bool -> Rules a -> IO ()+watch :: Configuration -> Verbosity -> String -> Int -> Bool -> Rules a -> IO () #ifdef WATCH_SERVER-watch conf verbosity port runServer rules = do-    watchUpdates conf update-    _ <- forkIO (server')-    loop+watch conf verbosity host port runServer rules = do+#ifndef mingw32_HOST_OS+    _ <- forkIO $ watchUpdates conf update+#else+    -- Force windows users to compile with -threaded flag, as otherwise+    -- thread is blocked indefinitely.+    catchIOError (void $ forkOS $ watchUpdates conf update) $ do+        fail $ "Hakyll.Commands.watch: Could not start update watching " +++               "thread. Did you compile with -threaded flag?"+#endif+    server'   where     update = do         (_, ruleSet) <- run conf verbosity rules         return $ rulesPattern ruleSet-     loop = threadDelay 100000 >> loop--    server' = if runServer then server conf port else return ()+    server' = if runServer then server conf host port else loop #else-watch _ _ _ _ _ = watchServerDisabled+watch _ _ _ _ = watchServerDisabled #endif  --------------------------------------------------------------------------------@@ -106,15 +111,15 @@  -------------------------------------------------------------------------------- -- | Start a server-server :: Configuration -> Int -> IO ()+server :: Configuration -> String -> Int -> IO () #ifdef PREVIEW_SERVER-server conf port = do+server conf host port = do     let destination = destinationDirectory conf-    staticServer destination preServeHook port+    staticServer destination preServeHook host port   where     preServeHook _ = return () #else-server _ _ = previewServerDisabled+server _ _ _ = previewServerDisabled #endif  
src/Hakyll/Core/Configuration.hs view
@@ -69,6 +69,11 @@     , -- | Use an in-memory cache for items. This is faster but uses more       -- memory.       inMemoryCache        :: Bool+    , -- | Override default host for preview server. Default is "127.0.0.1",+      -- which binds only on the loopback address.+      -- One can also override the host as a command line argument:+      -- ./site preview -h "0.0.0.0"+      previewHost          :: String     , -- | Override default port for preview server. Default is 8000.       -- One can also override the port as a command line argument:       -- ./site preview -p 1234@@ -91,6 +96,7 @@     , deployCommand        = "echo 'No deploy command specified' && exit 1"     , deploySite           = system . deployCommand     , inMemoryCache        = True+    , previewHost          = "127.0.0.1"     , previewPort          = 8000     }   where
src/Hakyll/Core/UnixFilter.hs view
@@ -19,7 +19,7 @@ import           System.IO               (Handle, hClose, hFlush, hGetContents,                                           hPutStr, hSetEncoding, localeEncoding) import           System.Process-+import qualified System.Info             as System  -------------------------------------------------------------------------------- import           Hakyll.Core.Compiler@@ -105,8 +105,20 @@              -> i              -> IO (o, String, ExitCode) unixFilterIO writer reader programName args input = do+    -- The problem on Windows is that `proc` is that it is unable to execute+    -- batch stubs (eg. anything created using 'gem install ...') even if its in+    -- `$PATH`. A solution to this issue is to execute the batch file explicitly+    -- using `cmd /c batchfile` but there is no rational way to know where said+    -- batchfile is on the system. Hence, we detect windows using the+    -- `System.Info` module and then instead of using `proc` to create the+    -- process, use `shell` instead which will be able to execute everything+    -- `proc` can, and this can deal with batch files as well.+    let pr = if System.os == "mingw32"+                 then shell $ unwords (programName : args)+                 else proc programName args+     (Just inh, Just outh, Just errh, pid) <--        createProcess (proc programName args)+        createProcess pr                 { std_in  = CreatePipe                 , std_out = CreatePipe                 , std_err = CreatePipe
src/Hakyll/Main.hs view
@@ -48,8 +48,8 @@         Help    _     -> showHelp         Preview _ p   -> Commands.preview conf verbosity' rules p         Rebuild _     -> Commands.rebuild conf verbosity' rules >>= exitWith-        Server  _ _   -> Commands.server conf (port args')-        Watch   _ p s -> Commands.watch conf verbosity' p (not s) rules+        Server  _ _ _   -> Commands.server conf (host args') (port args')+        Watch   _ _ p s -> Commands.watch conf verbosity' (host args') p (not s) rules   --------------------------------------------------------------------------------@@ -67,8 +67,8 @@     | Help    {verbose :: Bool}     | Preview {verbose :: Bool, port :: Int}     | Rebuild {verbose :: Bool}-    | Server  {verbose :: Bool, port :: Int}-    | Watch   {verbose :: Bool, port :: Int, no_server :: Bool }+    | Server  {verbose :: Bool, host :: String, port :: Int}+    | Watch   {verbose :: Bool, host :: String, port :: Int, no_server :: Bool }     deriving (Data, Typeable, Show)  @@ -84,13 +84,14 @@     , (Preview (verboseFlag def) (portFlag defaultPort)) &=         help "[Deprecated] Please use the watch command"     , (Rebuild $ verboseFlag def) &= help "Clean and build again"-    , (Server (verboseFlag def) (portFlag defaultPort)) &=+    , (Server (verboseFlag def) (hostFlag defaultHost) (portFlag defaultPort)) &=         help "Start a preview server"-    , (Watch (verboseFlag def) (portFlag defaultPort) (noServerFlag False) &=+    , (Watch (verboseFlag def) (hostFlag defaultHost) (portFlag defaultPort) (noServerFlag False) &=        help "Autocompile on changes and start a preview server.  You can watch and recompile without running a server with --no-server.")     ] &= help "Hakyll static site compiler" &= program progName-    where defaultPort = Config.previewPort conf-+    where+        defaultHost = Config.previewHost conf+        defaultPort = Config.previewPort conf  -------------------------------------------------------------------------------- verboseFlag :: Data a => a -> a@@ -102,6 +103,11 @@ noServerFlag :: Data a => a -> a noServerFlag x = x &= help "Disable the built-in web server" {-# INLINE noServerFlag #-}++--------------------------------------------------------------------------------+hostFlag :: Data a => a -> a+hostFlag x = x &= help "Host to bind on"+{-# INLINE hostFlag #-}  -------------------------------------------------------------------------------- portFlag :: Data a => a -> a
src/Hakyll/Preview/Server.hs view
@@ -8,6 +8,7 @@  -------------------------------------------------------------------------------- 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@@ -31,13 +32,15 @@ -- | Main method, runs a static server in the given directory staticServer :: 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 port =+staticServer directory preServe host port =     Snap.httpServe config $ static directory preServe   where     -- Snap server config-    config = Snap.setPort      port+    config = Snap.setBind  (B.pack host)+           $ Snap.setPort      port            $ Snap.setAccessLog Snap.ConfigNoLog            $ Snap.setErrorLog  Snap.ConfigNoLog            $ Snap.emptyConfig
src/Hakyll/Web/Pandoc.hs view
@@ -13,6 +13,7 @@     , pandocCompiler     , pandocCompilerWith     , pandocCompilerWithTransform+    , pandocCompilerWithTransformM        -- * Default options     , defaultHakyllReaderOptions@@ -23,6 +24,7 @@ -------------------------------------------------------------------------------- import           Control.Applicative        ((<$>)) import qualified Data.Set                   as S+import           Data.Traversable           (traverse) import           Text.Pandoc  @@ -99,7 +101,9 @@ -- | A version of 'pandocCompiler' which allows you to specify your own pandoc -- options pandocCompilerWith :: ReaderOptions -> WriterOptions -> Compiler (Item String)-pandocCompilerWith ropt wopt = pandocCompilerWithTransform ropt wopt id+pandocCompilerWith ropt wopt =+    cached "Hakyll.Web.Pandoc.pandocCompilerWith" $+        pandocCompilerWithTransform ropt wopt id   --------------------------------------------------------------------------------@@ -108,10 +112,21 @@ pandocCompilerWithTransform :: ReaderOptions -> WriterOptions                             -> (Pandoc -> Pandoc)                             -> Compiler (Item String)-pandocCompilerWithTransform ropt wopt f = cached cacheName $-    writePandocWith wopt . fmap f . readPandocWith ropt <$> getResourceBody-  where-    cacheName = "Hakyll.Web.Page.pageCompilerWithPandoc"+pandocCompilerWithTransform ropt wopt f =+    pandocCompilerWithTransformM ropt wopt (return . f)+++--------------------------------------------------------------------------------+-- | Similar to 'pandocCompilerWithTransform', but the transformation+-- function is monadic. This is useful when you want the pandoc+-- transformation to use the 'Compiler' information such as routes,+-- metadata, etc+pandocCompilerWithTransformM :: ReaderOptions -> WriterOptions+                    -> (Pandoc -> Compiler Pandoc)+                    -> Compiler (Item String)+pandocCompilerWithTransformM ropt wopt f =+    writePandocWith wopt <$>+        (traverse f =<< readPandocWith ropt <$> getResourceBody)   --------------------------------------------------------------------------------