diff options
-rw-r--r-- | hakyll.cabal | 123 | ||||
-rw-r--r-- | src/Hakyll/Check.hs | 37 | ||||
-rw-r--r-- | src/Hakyll/Core/File.hs | 19 | ||||
-rw-r--r-- | src/Hakyll/Core/Provider.hs | 1 | ||||
-rw-r--r-- | tests/Hakyll/Core/Runtime/Tests.hs | 11 | ||||
-rw-r--r-- | web/releases.markdown | 14 | ||||
-rw-r--r-- | web/tutorials/faq.markdown | 21 |
7 files changed, 156 insertions, 70 deletions
diff --git a/hakyll.cabal b/hakyll.cabal index a5c4d37..798625b 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -1,5 +1,5 @@ Name: hakyll -Version: 4.2.0.0 +Version: 4.2.1.2 Synopsis: A static website compiler library Description: @@ -78,41 +78,15 @@ Flag previewServer Description: Include the preview server Default: True +Flag checkExternal + Description: Include external link checking + Default: True + Library Ghc-Options: -Wall Ghc-Prof-Options: -auto-all -caf-all Hs-Source-Dirs: src - 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, - containers >= 0.3 && < 0.6, - cryptohash >= 0.7 && < 0.9, - data-default >= 0.4 && < 0.6, - deepseq >= 1.3 && < 1.4, - directory >= 1.0 && < 1.3, - filepath >= 1.0 && < 1.4, - http-conduit >= 1.8 && < 1.10, - http-types >= 0.7 && < 0.9, - lrucache >= 1.1.1 && < 1.2, - mtl >= 1 && < 2.2, - old-locale >= 1.0 && < 1.1, - old-time >= 1.0 && < 1.2, - cmdargs >= 0.10 && < 0.11, - pandoc >= 1.10 && < 1.11, - 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 - Exposed-Modules: Hakyll Hakyll.Core.Compiler @@ -160,6 +134,34 @@ Library Hakyll.Web.Template.Internal 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, + containers >= 0.3 && < 0.6, + cryptohash >= 0.7 && < 0.9, + 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, + old-locale >= 1.0 && < 1.1, + old-time >= 1.0 && < 1.2, + cmdargs >= 0.10 && < 0.11, + 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 + If flag(previewServer) Build-depends: snap-core >= 0.6 && < 0.10, @@ -170,11 +172,35 @@ Library Hakyll.Preview.Poll Hakyll.Preview.Server + If flag(checkExternal) + Build-depends: + http-conduit >= 1.8 && < 1.10, + http-types >= 0.7 && < 0.9 + Cpp-options: + -DCHECK_EXTERNAL + Test-suite hakyll-tests Type: exitcode-stdio-1.0 Hs-source-dirs: src tests Main-is: TestSuite.hs Ghc-options: -Wall + Other-modules: + Hakyll.Core.Dependencies.Tests + Hakyll.Core.Identifier.Tests + Hakyll.Core.Provider.Metadata.Tests + Hakyll.Core.Provider.Tests + Hakyll.Core.Routes.Tests + Hakyll.Core.Rules.Tests + Hakyll.Core.Runtime.Tests + Hakyll.Core.Store.Tests + Hakyll.Core.UnixFilter.Tests + Hakyll.Core.Util.String.Tests + Hakyll.Web.Html.RelativizeUrls.Tests + Hakyll.Web.Html.Tests + Hakyll.Web.Pandoc.FileType.Tests + Hakyll.Web.Template.Context.Tests + Hakyll.Web.Template.Tests + TestSuite.Util Build-Depends: HUnit >= 1.2 && < 1.3, @@ -195,14 +221,12 @@ Test-suite hakyll-tests deepseq >= 1.3 && < 1.4, directory >= 1.0 && < 1.3, filepath >= 1.0 && < 1.4, - http-conduit >= 1.8 && < 1.10, - http-types >= 0.7 && < 0.9, lrucache >= 1.1.1 && < 1.2, mtl >= 1 && < 2.2, old-locale >= 1.0 && < 1.1, old-time >= 1.0 && < 1.2, cmdargs >= 0.10 && < 0.11, - pandoc >= 1.0 && < 1.11, + pandoc >= 1.10 && < 1.12, parsec >= 3.0 && < 3.2, process >= 1.0 && < 1.2, random >= 1.0 && < 1.1, @@ -212,21 +236,22 @@ Test-suite hakyll-tests text >= 0.11 && < 1.12, time >= 1.1 && < 1.5 - Other-modules: - Hakyll.Core.Dependencies.Tests - Hakyll.Core.Identifier.Tests - Hakyll.Core.Provider.Tests - Hakyll.Core.Routes.Tests - Hakyll.Core.Rules.Tests - Hakyll.Core.Runtime.Tests - Hakyll.Core.Store.Tests - Hakyll.Core.UnixFilter.Tests - Hakyll.Core.Util.String.Tests - Hakyll.Web.Template.Context.Tests - Hakyll.Web.Template.Tests - Hakyll.Web.Html.Tests - Hakyll.Web.Html.RelativizeUrls.Tests - TestSuite.Util + If flag(previewServer) + Build-depends: + snap-core >= 0.6 && < 0.10, + snap-server >= 0.6 && < 0.10 + Cpp-options: + -DPREVIEW_SERVER + Other-modules: + Hakyll.Preview.Poll + Hakyll.Preview.Server + + If flag(checkExternal) + Build-depends: + http-conduit >= 1.8 && < 1.10, + http-types >= 0.7 && < 0.9 + Cpp-options: + -DCHECK_EXTERNAL Executable hakyll-init Ghc-options: -Wall diff --git a/src/Hakyll/Check.hs b/src/Hakyll/Check.hs index a426f87..73606b3 100644 --- a/src/Hakyll/Check.hs +++ b/src/Hakyll/Check.hs @@ -1,4 +1,5 @@ -------------------------------------------------------------------------------- +{-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} module Hakyll.Check ( Check (..) @@ -8,22 +9,15 @@ module Hakyll.Check -------------------------------------------------------------------------------- import Control.Applicative ((<$>)) -import Control.Exception (AsyncException (..), - SomeException (..), handle, throw) import Control.Monad (forM_) import Control.Monad.Reader (ask) import Control.Monad.RWS (RWST, runRWST) -import Control.Monad.State (get, modify) import Control.Monad.Trans (liftIO) import Control.Monad.Writer (tell) -import Data.List (intercalate, isPrefixOf) +import Data.List (isPrefixOf) import Data.Monoid (Monoid (..)) import Data.Set (Set) import qualified Data.Set as S -import Data.Typeable (cast) -import GHC.Exts (fromString) -import qualified Network.HTTP.Conduit as Http -import qualified Network.HTTP.Types as Http import System.Directory (doesDirectoryExist, doesFileExist) import System.Exit (ExitCode (..)) import System.FilePath (takeDirectory, takeExtension, (</>)) @@ -31,13 +25,26 @@ import qualified Text.HTML.TagSoup as TS -------------------------------------------------------------------------------- +#ifdef CHECK_EXTERNAL +import Control.Exception (AsyncException (..), + SomeException (..), handle, throw) +import Control.Monad.State (get, modify) +import Data.List (intercalate) +import Data.Typeable (cast) import Data.Version (versionBranch) +import GHC.Exts (fromString) +import qualified Network.HTTP.Conduit as Http +import qualified Network.HTTP.Types as Http +import qualified Paths_hakyll as Paths_hakyll +#endif + + +-------------------------------------------------------------------------------- import Hakyll.Core.Configuration import Hakyll.Core.Logger (Logger, Verbosity) import qualified Hakyll.Core.Logger as Logger import Hakyll.Core.Util.File import Hakyll.Web.Html -import qualified Paths_hakyll as Paths_hakyll -------------------------------------------------------------------------------- @@ -87,7 +94,12 @@ runChecker :: Checker a -> Configuration -> Verbosity -> Check -> IO (a, CheckerWrite) runChecker checker config verbosity check' = do logger <- Logger.new verbosity - let read' = CheckerRead config logger check' + let read' = CheckerRead + { checkerConfig = config + , checkerLogger = logger + , checkerCheck = check' + } + (x, _, write) <- runRWST checker read' S.empty Logger.flush logger return (x, write) @@ -157,6 +169,7 @@ checkInternalUrl base url = case url' of -------------------------------------------------------------------------------- checkExternalUrl :: String -> Checker () +#ifdef CHECK_EXTERNAL checkExternalUrl url = do logger <- checkerLogger <$> ask needsCheck <- (== All) . checkerCheck <$> ask @@ -190,6 +203,10 @@ checkExternalUrl url = do failure logger (SomeException e) = case cast e of Just UserInterrupt -> throw UserInterrupt _ -> Logger.error logger (show e) >> return False +#else +checkExternalUrl _ = return () +#endif + -------------------------------------------------------------------------------- diff --git a/src/Hakyll/Core/File.hs b/src/Hakyll/Core/File.hs index a7b4a35..26724e1 100644 --- a/src/Hakyll/Core/File.hs +++ b/src/Hakyll/Core/File.hs @@ -24,8 +24,8 @@ import System.Random (randomIO) import Hakyll.Core.Compiler import Hakyll.Core.Compiler.Internal import Hakyll.Core.Configuration -import Hakyll.Core.Identifier import Hakyll.Core.Item +import Hakyll.Core.Provider import qualified Hakyll.Core.Store as Store import Hakyll.Core.Util.File import Hakyll.Core.Writable @@ -33,24 +33,21 @@ import Hakyll.Core.Writable -------------------------------------------------------------------------------- -- | This will copy any file directly by using a system call -data CopyFile = CopyFile - deriving (Show, Eq, Ord, Typeable) - - --------------------------------------------------------------------------------- -instance Binary CopyFile where - put CopyFile = return () - get = return CopyFile +newtype CopyFile = CopyFile FilePath + deriving (Binary, Eq, Ord, Show, Typeable) -------------------------------------------------------------------------------- instance Writable CopyFile where - write dst item = copyFile (toFilePath $ itemIdentifier item) dst + write dst (Item _ (CopyFile src)) = copyFile src dst -------------------------------------------------------------------------------- copyFileCompiler :: Compiler (Item CopyFile) -copyFileCompiler = makeItem CopyFile +copyFileCompiler = do + identifier <- getUnderlying + provider <- compilerProvider <$> compilerAsk + makeItem $ CopyFile $ resourceFilePath provider identifier -------------------------------------------------------------------------------- diff --git a/src/Hakyll/Core/Provider.hs b/src/Hakyll/Core/Provider.hs index 00b694d..400f044 100644 --- a/src/Hakyll/Core/Provider.hs +++ b/src/Hakyll/Core/Provider.hs @@ -9,6 +9,7 @@ module Hakyll.Core.Provider -- * Querying resource properties , Internal.resourceList , Internal.resourceExists + , Internal.resourceFilePath , Internal.resourceModified , Internal.resourceModificationTime diff --git a/tests/Hakyll/Core/Runtime/Tests.hs b/tests/Hakyll/Core/Runtime/Tests.hs index 8a05824..1ca8dc1 100644 --- a/tests/Hakyll/Core/Runtime/Tests.hs +++ b/tests/Hakyll/Core/Runtime/Tests.hs @@ -6,6 +6,7 @@ module Hakyll.Core.Runtime.Tests -------------------------------------------------------------------------------- +import qualified Data.ByteString as B import System.FilePath ((</>)) import Test.Framework (Test, testGroup) import Test.HUnit (Assertion, (@?=)) @@ -28,6 +29,10 @@ tests = testGroup "Hakyll.Core.Runtime.Tests" $ case01 :: Assertion case01 = do _ <- run testConfiguration Logger.Error $ do + match "images/*" $ do + route idRoute + compile copyFileCompiler + match "*.md" $ do route $ setExtension "html" compile $ do @@ -41,6 +46,12 @@ case01 = do items <- loadAllSnapshots "*.md" "raw" makeItem $ concat $ map itemBody (items :: [Item String]) + favicon <- B.readFile $ + providerDirectory testConfiguration </> "images/favicon.ico" + favicon' <- B.readFile $ + destinationDirectory testConfiguration </> "images/favicon.ico" + favicon @?= favicon' + example <- readFile $ destinationDirectory testConfiguration </> "example.html" lines example @?= ["<p>This is an example.</p>"] diff --git a/web/releases.markdown b/web/releases.markdown index 4b5f443..d95f539 100644 --- a/web/releases.markdown +++ b/web/releases.markdown @@ -4,8 +4,22 @@ title: Releases # Releases +## Hakyll 4.2.1.1 + +*March 9, 2013* + +- Make `http-conduit` dependency optional by adding a `checkExternal` cabal flag + +## Hakyll 4.2.1.0 + +*March 7, 2013* + +- Fix issue where `copyFileCompiler` ignored `providerDirectory` + ## Hakyll 4.2.0.0 +*March 7, 2013* + - Read second extension for `.lhs`, e.g. `.md.lhs` or `.tex.lhs` (contribution by Alexander Vershilov) diff --git a/web/tutorials/faq.markdown b/web/tutorials/faq.markdown index 63f310f..66dd4e6 100644 --- a/web/tutorials/faq.markdown +++ b/web/tutorials/faq.markdown @@ -3,6 +3,27 @@ title: FAQ author: Jasper Van der Jeugt --- +## "hGetContents: invalid argument" or "commitBuffer: invalid argument" + +If you get any of the errors: + + commitBuffer: invalid argument (invalid character) + +or: + + hGetContents: invalid argument (Invalid or incomplete multibyte or wide + character) + +It means that your Hakyll executable couldn't write to (in the former case) or +read (in the latter) from an UTF-8 encoded file. + +On most linux distros, you can solve this by setting your `LANG` to use UTF-8, +using something like: + + LANG=nl_BE.UTF-8 ./site build + +You should also add this to your `.profile`, or whatever config file you use. + ## "File name does not match module name" on Mac OS Hakyll.hs:1:1: |