hakyll 4.3.3.0 → 4.4.0.0
raw patch · 10 files changed
+177/−96 lines, 10 filesdep +pandoc-citeprocdep −citeproc-hsdep ~QuickCheckdep ~cryptohashdep ~pandoc
Dependencies added: pandoc-citeproc
Dependencies removed: citeproc-hs
Dependency ranges changed: QuickCheck, cryptohash, pandoc, test-framework-hunit, test-framework-quickcheck2
Files
- hakyll.cabal +80/−58
- src/Hakyll/Commands.hs +45/−6
- src/Hakyll/Core/Configuration.hs +5/−0
- src/Hakyll/Core/Provider/Internal.hs +1/−1
- src/Hakyll/Core/Provider/Metadata.hs +3/−2
- src/Hakyll/Core/Store.hs +5/−0
- src/Hakyll/Main.hs +25/−15
- src/Hakyll/Web/Html.hs +1/−1
- src/Hakyll/Web/Pandoc/Biblio.hs +6/−9
- src/Hakyll/Web/Template/Context.hs +6/−4
hakyll.cabal view
@@ -1,5 +1,5 @@ Name: hakyll-Version: 4.3.3.0+Version: 4.4.0.0 Synopsis: A static website compiler library Description:@@ -78,6 +78,10 @@ Description: Include the preview server Default: True +Flag watchServer+ Description: Include the watch server+ Default: True+ Flag checkExternal Description: Include external link checking Default: True@@ -137,33 +141,33 @@ Paths_hakyll Build-Depends:- base >= 4 && < 5,- binary >= 0.5 && < 0.8,- blaze-html >= 0.5 && < 0.7,- blaze-markup >= 0.5.1 && < 0.6,- bytestring >= 0.9 && < 0.11,- citeproc-hs >= 0.3.2 && < 0.4,- cmdargs >= 0.10 && < 0.11,- containers >= 0.3 && < 0.6,- cryptohash >= 0.7 && < 0.10,- data-default >= 0.4 && < 0.6,- deepseq >= 1.3 && < 1.4,- directory >= 1.0 && < 1.3,- filepath >= 1.0 && < 1.4,- lrucache >= 1.1.1 && < 1.2,- mtl >= 1 && < 2.2,- network >= 2.4 && < 2.5,- old-locale >= 1.0 && < 1.1,- old-time >= 1.0 && < 1.2,- pandoc >= 1.10 && < 1.12,- parsec >= 3.0 && < 3.2,- process >= 1.0 && < 1.2,- random >= 1.0 && < 1.1,- regex-base >= 0.93 && < 0.94,- regex-tdfa >= 1.1 && < 1.2,- tagsoup >= 0.12.6 && < 0.13,- text >= 0.11 && < 1.12,- time >= 1.1 && < 1.5+ base >= 4 && < 5,+ binary >= 0.5 && < 0.8,+ blaze-html >= 0.5 && < 0.7,+ blaze-markup >= 0.5.1 && < 0.6,+ bytestring >= 0.9 && < 0.11,+ cmdargs >= 0.10 && < 0.11,+ containers >= 0.3 && < 0.6,+ cryptohash >= 0.7 && < 0.11,+ data-default >= 0.4 && < 0.6,+ deepseq >= 1.3 && < 1.4,+ directory >= 1.0 && < 1.3,+ filepath >= 1.0 && < 1.4,+ lrucache >= 1.1.1 && < 1.2,+ mtl >= 1 && < 2.2,+ network >= 2.4 && < 2.5,+ old-locale >= 1.0 && < 1.1,+ old-time >= 1.0 && < 1.2,+ pandoc >= 1.12 && < 1.13,+ pandoc-citeproc >= 0.1 && < 0.2,+ parsec >= 3.0 && < 3.2,+ process >= 1.0 && < 1.2,+ random >= 1.0 && < 1.1,+ regex-base >= 0.93 && < 0.94,+ regex-tdfa >= 1.1 && < 1.2,+ tagsoup >= 0.12.6 && < 0.13,+ text >= 0.11 && < 1.12,+ time >= 1.1 && < 1.5 If flag(previewServer) Build-depends:@@ -177,6 +181,15 @@ Hakyll.Preview.Poll Hakyll.Preview.Server + If flag(watchServer)+ Build-depends:+ fsnotify >= 0.0.6 && < 0.1,+ system-filepath >= 0.4.6 && <= 0.5+ Cpp-options:+ -DWATCH_SERVER+ Other-modules:+ Hakyll.Preview.Poll+ If flag(checkExternal) Build-depends: http-conduit >= 1.8 && < 1.10,@@ -209,38 +222,38 @@ Build-Depends: HUnit >= 1.2 && < 1.3,- QuickCheck >= 2.4 && < 2.6,+ QuickCheck >= 2.4 && < 2.7, test-framework >= 0.4 && < 0.9,- test-framework-hunit >= 0.2 && < 0.4,- test-framework-quickcheck2 >= 0.2 && < 0.4,+ 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,- bytestring >= 0.9 && < 0.11,- citeproc-hs >= 0.3.2 && < 0.4,- cmdargs >= 0.10 && < 0.11,- containers >= 0.3 && < 0.6,- cryptohash >= 0.7 && < 0.10,- data-default >= 0.4 && < 0.6,- deepseq >= 1.3 && < 1.4,- directory >= 1.0 && < 1.3,- filepath >= 1.0 && < 1.4,- lrucache >= 1.1.1 && < 1.2,- mtl >= 1 && < 2.2,- network >= 2.4 && < 2.5,- old-locale >= 1.0 && < 1.1,- old-time >= 1.0 && < 1.2,- pandoc >= 1.10 && < 1.12,- parsec >= 3.0 && < 3.2,- process >= 1.0 && < 1.2,- random >= 1.0 && < 1.1,- regex-base >= 0.93 && < 0.94,- regex-tdfa >= 1.1 && < 1.2,- tagsoup >= 0.12.6 && < 0.13,- text >= 0.11 && < 1.12,- time >= 1.1 && < 1.5+ base >= 4 && < 5,+ binary >= 0.5 && < 0.8,+ blaze-html >= 0.5 && < 0.7,+ blaze-markup >= 0.5.1 && < 0.6,+ bytestring >= 0.9 && < 0.11,+ cmdargs >= 0.10 && < 0.11,+ containers >= 0.3 && < 0.6,+ cryptohash >= 0.7 && < 0.11,+ data-default >= 0.4 && < 0.6,+ deepseq >= 1.3 && < 1.4,+ directory >= 1.0 && < 1.3,+ filepath >= 1.0 && < 1.4,+ lrucache >= 1.1.1 && < 1.2,+ mtl >= 1 && < 2.2,+ network >= 2.4 && < 2.5,+ old-locale >= 1.0 && < 1.1,+ old-time >= 1.0 && < 1.2,+ pandoc >= 1.12 && < 1.13,+ pandoc-citeproc >= 0.1 && < 0.2,+ parsec >= 3.0 && < 3.2,+ process >= 1.0 && < 1.2,+ random >= 1.0 && < 1.1,+ regex-base >= 0.93 && < 0.94,+ regex-tdfa >= 1.1 && < 1.2,+ tagsoup >= 0.12.6 && < 0.13,+ text >= 0.11 && < 1.12,+ time >= 1.1 && < 1.5 If flag(previewServer) Build-depends:@@ -253,6 +266,15 @@ Other-modules: Hakyll.Preview.Poll Hakyll.Preview.Server++ If flag(watchServer)+ Build-depends:+ fsnotify >= 0.0.6 && < 0.1,+ system-filepath >= 0.4.6 && <= 0.5+ Cpp-options:+ -DWATCH_SERVER+ Other-modules:+ Hakyll.Preview.Poll If flag(checkExternal) Build-depends:
src/Hakyll/Commands.hs view
@@ -1,4 +1,4 @@---------------------------------------------------------------------------------+ -------------------------------------------------------------------------------- -- | Implementation of Hakyll commands: build, preview... {-# LANGUAGE CPP #-} module Hakyll.Commands@@ -9,12 +9,14 @@ , rebuild , server , deploy+ , watch ) where -------------------------------------------------------------------------------- import System.Exit (exitWith, ExitCode) import Control.Applicative+import Control.Concurrent -------------------------------------------------------------------------------- import qualified Hakyll.Check as Check@@ -26,8 +28,11 @@ import Hakyll.Core.Util.File --------------------------------------------------------------------------------+#ifdef WATCH_SERVER+import Hakyll.Preview.Poll (watchUpdates)+#endif+ #ifdef PREVIEW_SERVER-import Hakyll.Preview.Poll import Hakyll.Preview.Server #endif @@ -60,18 +65,39 @@ -- | Preview the site preview :: Configuration -> Verbosity -> Rules a -> Int -> IO () #ifdef PREVIEW_SERVER-preview conf verbosity rules port = do+preview conf verbosity rules port = do+ deprecatedMessage+ watch conf verbosity port True rules+ where+ deprecatedMessage = mapM_ putStrLn [ "The preview command has been deprecated."+ , "Use the watch command for recompilation and serving."+ ]+#else+preview _ _ _ _ = previewServerDisabled+#endif+++--------------------------------------------------------------------------------+-- | Watch and recompile for changes++watch :: Configuration -> Verbosity -> Int -> Bool -> Rules a -> IO ()+#ifdef WATCH_SERVER+watch conf verbosity port runServer rules = do watchUpdates conf update- server conf port+ _ <- forkIO (server')+ loop where update = do (_, ruleSet) <- run conf verbosity rules return $ rulesPattern ruleSet++ loop = threadDelay 100000 >> loop++ server' = if runServer then server conf port else return () #else-preview _ _ _ _ = previewServerDisabled+watch _ _ _ _ _ = watchServerDisabled #endif - -------------------------------------------------------------------------------- -- | Rebuild the site rebuild :: Configuration -> Verbosity -> Rules a -> IO ExitCode@@ -111,3 +137,16 @@ , "Alternatively, use an external tool to serve your site directory." ] #endif++#ifndef WATCH_SERVER+watchServerDisabled :: IO ()+watchServerDisabled =+ mapM_ putStrLn+ [ "WATCH SERVER"+ , ""+ , "The watch server is not enabled in the version of Hakyll. To"+ , "enable it, set the flag to True and recompile Hakyll."+ , "Alternatively, use an external tool to serve your site directory."+ ]+#endif+
src/Hakyll/Core/Configuration.hs view
@@ -69,6 +69,10 @@ , -- | Use an in-memory cache for items. This is faster but uses more -- memory. inMemoryCache :: Bool+ , -- | Override default port for preview server. Default is 8000.+ -- One can also override the port as a command line argument:+ -- ./site preview -p 1234+ previewPort :: Int } --------------------------------------------------------------------------------@@ -87,6 +91,7 @@ , deployCommand = "echo 'No deploy command specified' && exit 1" , deploySite = system . deployCommand , inMemoryCache = True+ , previewPort = 8000 } where ignoreFile' path
src/Hakyll/Core/Provider/Internal.hs view
@@ -98,7 +98,7 @@ providerOldFiles :: Map Identifier ResourceInfo , -- | Underlying persistent store for caching providerStore :: Store- }+ } deriving (Show) --------------------------------------------------------------------------------
src/Hakyll/Core/Provider/Metadata.hs view
@@ -44,8 +44,9 @@ return (M.union md emd, body) where- fp = resourceFilePath p identifier- mi = M.lookup identifier (providerFiles p) >>= resourceInfoMetadata+ normal = setVersion Nothing identifier+ fp = resourceFilePath p identifier+ mi = M.lookup normal (providerFiles p) >>= resourceInfoMetadata --------------------------------------------------------------------------------
src/Hakyll/Core/Store.hs view
@@ -50,6 +50,11 @@ --------------------------------------------------------------------------------+instance Show Store where+ show _ = "<Store>"+++-------------------------------------------------------------------------------- -- | Result of a store query data Result a = Found a -- ^ Found, result
src/Hakyll/Main.hs view
@@ -34,27 +34,28 @@ -- configuration hakyllWith :: Config.Configuration -> Rules a -> IO () hakyllWith conf rules = do- args' <- cmdArgs hakyllArgs+ args' <- cmdArgs (hakyllArgs conf) let verbosity' = if verbose args' then Logger.Debug else Logger.Message check' = if internal_links args' then Check.InternalLinks else Check.All case args' of- Build _ -> Commands.build conf verbosity' rules >>= exitWith- Check _ _ -> Commands.check conf verbosity' check'- Clean _ -> Commands.clean conf- 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 (port args')+ Build _ -> Commands.build conf verbosity' rules >>= exitWith+ Check _ _ -> Commands.check conf verbosity' check'+ Clean _ -> Commands.clean conf+ 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 (port args')+ Watch _ p s -> Commands.watch conf verbosity' p (not s) rules -------------------------------------------------------------------------------- -- | Show usage information. showHelp :: IO ()-showHelp = print $ CA.helpText [] CA.HelpFormatOne $ cmdArgsMode hakyllArgs+showHelp = print $ CA.helpText [] CA.HelpFormatOne $ cmdArgsMode (hakyllArgs Config.defaultConfiguration) --------------------------------------------------------------------------------@@ -67,24 +68,28 @@ | Preview {verbose :: Bool, port :: Int} | Rebuild {verbose :: Bool} | Server {verbose :: Bool, port :: Int}+ | Watch {verbose :: Bool, port :: Int, no_server :: Bool } deriving (Data, Typeable, Show) ---------------------------------------------------------------------------------hakyllArgs :: HakyllArgs-hakyllArgs = modes+hakyllArgs :: Config.Configuration -> HakyllArgs+hakyllArgs conf = modes [ (Build $ verboseFlag def) &= help "Generate the site" , (Check (verboseFlag def) (False &= help "Check internal links only")) &= help "Validate the site output" , (Clean $ verboseFlag def) &= help "Clean up and remove cache" , (Deploy $ verboseFlag def) &= help "Upload/deploy your site" , (Help $ verboseFlag def) &= help "Show this message" &= auto- , (Preview (verboseFlag def) (portFlag 8000)) &=- help "Start a preview server and autocompile on changes"+ , (Preview (verboseFlag def) (portFlag defaultPort)) &=+ help "[Deprecated] Please use the watch command" , (Rebuild $ verboseFlag def) &= help "Clean and build again"- , (Server (verboseFlag def) (portFlag 8000)) &=+ , (Server (verboseFlag def) (portFlag defaultPort)) &= help "Start a preview server"+ , (Watch (verboseFlag def) (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 --------------------------------------------------------------------------------@@ -92,6 +97,11 @@ verboseFlag x = x &= help "Run in verbose mode" {-# INLINE verboseFlag #-} ++--------------------------------------------------------------------------------+noServerFlag :: Data a => a -> a+noServerFlag x = x &= help "Disable the built-in web server"+{-# INLINE noServerFlag #-} -------------------------------------------------------------------------------- portFlag :: Data a => a -> a
src/Hakyll/Web/Html.hs view
@@ -25,7 +25,7 @@ isDigit, toLower) import Data.List (isPrefixOf) import qualified Data.Set as S-import System.FilePath (joinPath, splitPath,+import System.FilePath.Posix (joinPath, splitPath, takeDirectory) import Text.Blaze.Html (toHtml) import Text.Blaze.Html.Renderer.String (renderHtml)
src/Hakyll/Web/Pandoc/Biblio.hs view
@@ -22,13 +22,11 @@ -------------------------------------------------------------------------------- import Control.Applicative ((<$>)) import Data.Binary (Binary (..))-import Data.Traversable (traverse) import Data.Typeable (Typeable) import qualified Text.CSL as CSL+import Text.CSL.Pandoc (processCites) import Text.Pandoc (Pandoc, ReaderOptions (..))-import Text.Pandoc.Biblio (processBiblio) - -------------------------------------------------------------------------------- import Hakyll.Core.Compiler import Hakyll.Core.Identifier@@ -86,21 +84,20 @@ -------------------------------------------------------------------------------- readPandocBiblio :: ReaderOptions- -> Maybe (Item CSL)+ -> Item CSL -> Item Biblio -> (Item String) -> Compiler (Item Pandoc) readPandocBiblio ropt csl biblio item = do -- Parse CSL file, if given- style <- unsafeCompiler $- traverse (CSL.readCSLFile . toFilePath . itemIdentifier) csl+ style <- unsafeCompiler $ CSL.readCSLFile . toFilePath . itemIdentifier $ csl -- We need to know the citation keys, add then *before* actually parsing the -- actual page. If we don't do this, pandoc won't even consider them -- citations! let Biblio refs = itemBody biblio- ropt' = ropt {readerReferences = readerReferences ropt ++ refs}- pandoc = itemBody $ readPandocWith ropt' item- pandoc' = processBiblio style refs pandoc+ pandoc = itemBody $ readPandocWith ropt item+ pandoc' = processCites style refs pandoc return $ fmap (const pandoc') item+
src/Hakyll/Web/Template/Context.hs view
@@ -100,9 +100,11 @@ mapContext :: (String -> String) -> Context a -> Context a mapContext f (Context c) = Context $ \k i -> do fld <- c k i- return $ case fld of- StringField str -> StringField (f str)- ListField ctx is -> ListField ctx is+ case fld of+ StringField str -> return $ StringField (f str)+ ListField _ _ -> fail $+ "Hakyll.Web.Template.Context.mapContext: " +++ "can't map over a ListField!" --------------------------------------------------------------------------------@@ -128,7 +130,7 @@ -------------------------------------------------------------------------------- -- | Map any field to its metadata value, if present-metadataField :: Context String+metadataField :: Context a metadataField = Context $ \k i -> do value <- getMetadataField (itemIdentifier i) k maybe empty (return . StringField) value