hakyll 4.9.6.0 → 4.9.7.0
raw patch · 5 files changed
+75/−38 lines, 5 filesdep ~optparse-applicative
Dependency ranges changed: optparse-applicative
Files
- CHANGELOG.md +5/−0
- hakyll.cabal +1/−1
- src/Hakyll/Main.hs +55/−28
- src/Hakyll/Web/CompressCss.hs +7/−6
- tests/Hakyll/Web/CompressCss/Tests.hs +7/−3
CHANGELOG.md view
@@ -4,6 +4,11 @@ # Releases +## Hakyll 4.9.7.0++- Fix compilation trouble with `Options.Applicative`+- Some small CSS compression improvements (contribution by Nicole Rauch)+ ## Hakyll 4.9.6.0 - Tighten dependency on `pandoc-citeproc` (contribution by Mikhail Glushenkov)
hakyll.cabal view
@@ -1,5 +1,5 @@ Name: hakyll-Version: 4.9.6.0+Version: 4.9.7.0 Synopsis: A static website compiler library Description:
src/Hakyll/Main.hs view
@@ -1,6 +1,6 @@ -------------------------------------------------------------------------------- -- | Module providing the main hakyll function and command-line argument parsing-{-# LANGUAGE CPP #-}+{-# LANGUAGE CPP #-} module Hakyll.Main ( hakyll@@ -11,20 +11,21 @@ ---------------------------------------------------------------------------------import System.Environment (getProgName)-import System.IO.Unsafe (unsafePerformIO)-import System.Exit (ExitCode(ExitSuccess), exitWith)+import System.Environment (getProgName)+import System.Exit (ExitCode (ExitSuccess), exitWith)+import System.IO.Unsafe (unsafePerformIO) ---------------------------------------------------------------------------------import Options.Applicative+import Data.Monoid ((<>))+import qualified Options.Applicative as OA ---------------------------------------------------------------------------------import qualified Hakyll.Check as Check-import qualified Hakyll.Commands as Commands-import qualified Hakyll.Core.Configuration as Config-import qualified Hakyll.Core.Logger as Logger+import qualified Hakyll.Check as Check+import qualified Hakyll.Commands as Commands+import qualified Hakyll.Core.Configuration as Config+import qualified Hakyll.Core.Logger as Logger import Hakyll.Core.Rules @@ -68,9 +69,9 @@ -------------------------------------------------------------------------------- defaultParser :: Config.Configuration -> IO Options defaultParser conf =- customExecParser (prefs showHelpOnError)- (info (helper <*> optionParser conf)- (fullDesc <> progDesc+ OA.customExecParser (OA.prefs OA.showHelpOnError)+ (OA.info (OA.helper <*> optionParser conf)+ (OA.fullDesc <> OA.progDesc (progName ++ " - Static site compiler created with Hakyll"))) @@ -107,27 +108,53 @@ | Watch {host :: String, port :: Int, no_server :: Bool } deriving (Show) -optionParser :: Config.Configuration -> Parser Options+optionParser :: Config.Configuration -> OA.Parser Options optionParser conf = Options <$> verboseParser <*> commandParser conf where- verboseParser = switch (long "verbose" <> short 'v' <> help "Run in verbose mode")+ verboseParser = OA.switch (OA.long "verbose" <> OA.short 'v' <> OA.help "Run in verbose mode") -commandParser :: Config.Configuration -> Parser Command-commandParser conf = subparser $ foldr ((<>) . produceCommand) mempty commands+commandParser :: Config.Configuration -> OA.Parser Command+commandParser conf = OA.subparser $ foldr ((<>) . produceCommand) mempty commands where- produceCommand (a,b) = command a (info (helper <*> fst b) (snd b))- portParser = option auto (long "port" <> help "Port to listen on" <> value (Config.previewPort conf))- hostParser = strOption (long "host" <> help "Host to bind on" <> value (Config.previewHost conf))- commands = [- ("build", (pure Build,fullDesc <> progDesc "Generate the site")),- ("check", (pure Check <*> switch (long "internal-links" <> help "Check internal links only"), fullDesc <> progDesc "Validate the site output")),- ("clean", (pure Clean,fullDesc <> progDesc "Clean up and remove cache")),- ("deploy", (pure Deploy,fullDesc <> progDesc "Upload/deploy your site")),- ("preview", (pure Preview <*> portParser,fullDesc <> progDesc "[DEPRECATED] Please use the watch command")),- ("rebuild", (pure Rebuild,fullDesc <> progDesc "Clean and build again")),- ("server", (pure Server <*> hostParser <*> portParser,fullDesc <> progDesc "Start a preview server")),- ("watch", (pure Watch <*> hostParser <*> portParser <*> switch (long "no-server" <> help "Disable the built-in web server"),fullDesc <> progDesc "Autocompile on changes and start a preview server. You can watch and recompile without running a server with --no-server."))+ portParser = OA.option OA.auto (OA.long "port" <> OA.help "Port to listen on" <> OA.value (Config.previewPort conf))+ hostParser = OA.strOption (OA.long "host" <> OA.help "Host to bind on" <> OA.value (Config.previewHost conf))++ produceCommand (c,a,b) = OA.command c (OA.info (OA.helper <*> a) (b))++ commands =+ [ ( "build"+ , pure Build+ , OA.fullDesc <> OA.progDesc "Generate the site"+ )+ , ( "check"+ , pure Check <*> OA.switch (OA.long "internal-links" <> OA.help "Check internal links only")+ , OA.fullDesc <> OA.progDesc "Validate the site output"+ )+ , ( "clean"+ , pure Clean+ , OA.fullDesc <> OA.progDesc "Clean up and remove cache"+ )+ , ( "deploy"+ , pure Deploy+ , OA.fullDesc <> OA.progDesc "Upload/deploy your site"+ )+ , ( "preview"+ , pure Preview <*> portParser+ , OA.fullDesc <> OA.progDesc "[DEPRECATED] Please use the watch command"+ )+ , ( "rebuild"+ , pure Rebuild+ , OA.fullDesc <> OA.progDesc "Clean and build again"+ )+ , ( "server"+ , pure Server <*> hostParser <*> portParser+ , OA.fullDesc <> OA.progDesc "Start a preview server"+ )+ , ( "watch"+ , pure Watch <*> hostParser <*> portParser <*> OA.switch (OA.long "no-server" <> OA.help "Disable the built-in web server")+ , OA.fullDesc <> OA.progDesc "Autocompile on changes and start a preview server. You can watch and recompile without running a server with --no-server."+ ) ]
src/Hakyll/Web/CompressCss.hs view
@@ -33,14 +33,15 @@ compressSeparators :: String -> String compressSeparators [] = [] compressSeparators str- | isConstant = head str : retainConstants compressSeparators (head str) (drop 1 str)+ | isConstant = head str : retainConstants compressSeparators (head str) (drop 1 str) | stripFirst = compressSeparators (drop 1 str) | stripSecond = compressSeparators (head str : (drop 2 str)) | otherwise = head str : compressSeparators (drop 1 str) where isConstant = or $ map (isOfPrefix str) ["\"", "'"]- stripFirst = or $ map (isOfPrefix str) [" ", " {", " }", " :", ";;", ";}"]- stripSecond = or $ map (isOfPrefix str) ["{ ", "} ", ": ", "; "]+ stripFirst = or $ map (isOfPrefix str) $ [";;", ";}"] ++ (map (\c -> " " ++ c) separators)+ stripSecond = or $ map (isOfPrefix str) $ map (\c -> c ++ " ") separators+ separators = [" ", "{", "}", ":", ";", ",", ">", "+", "!"] -------------------------------------------------------------------------------- -- | Compresses all whitespace.@@ -50,7 +51,7 @@ | isConstant = head str : retainConstants compressWhitespace (head str) (drop 1 str) | replaceOne = compressWhitespace (' ' : (drop 1 str)) | replaceTwo = compressWhitespace (' ' : (drop 2 str))- | otherwise = head str : compressWhitespace (drop 1 str)+ | otherwise = head str : compressWhitespace (drop 1 str) where isConstant = or $ map (isOfPrefix str) ["\"", "'"] replaceOne = or $ map (isOfPrefix str) ["\t", "\n", "\r"]@@ -61,9 +62,9 @@ stripComments :: String -> String stripComments [] = [] stripComments str- | isConstant = head str : retainConstants stripComments (head str) (drop 1 str)+ | isConstant = head str : retainConstants stripComments (head str) (drop 1 str) | isPrefixOf "/*" str = stripComments $ eatComments $ drop 2 str- | otherwise = head str : stripComments (drop 1 str)+ | otherwise = head str : stripComments (drop 1 str) where isConstant = or $ map (isOfPrefix str) ["\"", "'"] eatComments str'
tests/Hakyll/Web/CompressCss/Tests.hs view
@@ -37,11 +37,15 @@ -- compress separators , "}" @=? compressCss "; }"- , "{};" @=? compressCss " { } ; "+ , ";{};" @=? compressCss " ; { } ; "+ , "text," @=? compressCss "text , "+ , "a>b" @=? compressCss "a > b"+ , "a+b" @=? compressCss "a + b"+ , "a!b" @=? compressCss "a ! b" -- compress whitespace even after this curly brace , "}" @=? compressCss "; } " -- but do not compress separators inside of constants- , "\" { } ; \"" @=? compressCss "\" { } ; \""+ , "\" { } ; , \"" @=? compressCss "\" { } ; , \"" -- don't compress separators at the start or end of constants , "\" }\"" @=? compressCss "\" }\"" , "\"{ \"" @=? compressCss "\"{ \""@@ -51,7 +55,7 @@ -- don't compress whitespace around separators in constants in the middle of a string , "abc '{ '" @=? compressCss "abc '{ '" , "abc \"{ \"" @=? compressCss "abc \"{ \""- -- compress whitespace after colons+ -- compress whitespace around colons , "abc:xyz" @=? compressCss "abc : xyz" -- compress multiple semicolons , ";" @=? compressCss ";;;;;;;"