summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-03-09 17:54:08 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-03-09 17:54:08 +0100
commit5241e87f1692e488207b9a7ca2e5a592412f1583 (patch)
tree3f40fd30b6e208e4ee84b2a5c1fc8493a4e363b1
parentdf1fb668881d7293405396fecaa45620bdf56ecc (diff)
downloadhakyll-5241e87f1692e488207b9a7ca2e5a592412f1583.tar.gz
Make http-conduit dependency optional
-rw-r--r--hakyll.cabal117
-rw-r--r--src/Hakyll/Check.hs37
2 files changed, 97 insertions, 57 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index 4921fda..0e0e43d 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -78,40 +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,
- 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
@@ -159,6 +134,33 @@ 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,
+ 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.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
+
If flag(previewServer)
Build-depends:
snap-core >= 0.6 && < 0.10,
@@ -169,11 +171,33 @@ 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.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
Build-Depends:
HUnit >= 1.2 && < 1.3,
@@ -193,14 +217,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.11,
parsec >= 3.0 && < 3.2,
process >= 1.0 && < 1.2,
random >= 1.0 && < 1.1,
@@ -210,21 +232,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
+
--------------------------------------------------------------------------------