on master help sign in
Make http-conduit dependency optional
commit5241e87f1692e488207b9a7ca2e5a592412f1583 authorJasper Van der Jeugt <m@jaspervdj.be> dateSat 9 Mar 2013, 17:54 (14 years ago) parentdf1fb66
2 files changed+97−57
hakyll.cabal+70−47 src/Hakyll/Check.hs+27−10
hakyll.cabal+70−47
@@ -78,40 +78,15 @@ Flag previewServer
7878 Description: Include the preview server
7979 Default: True
8080
81+Flag checkExternal
82+ Description: Include external link checking
83+ Default: True
84+
8185Library
8286 Ghc-Options: -Wall
8387 Ghc-Prof-Options: -auto-all -caf-all
8488 Hs-Source-Dirs: src
8589
86− Build-Depends:
87− base >= 4 && < 5,
88− binary >= 0.5 && < 0.8,
89− blaze-html >= 0.5 && < 0.7,
90− blaze-markup >= 0.5.1 && < 0.6,
91− bytestring >= 0.9 && < 0.11,
92− citeproc-hs >= 0.3.2 && < 0.4,
93− containers >= 0.3 && < 0.6,
94− cryptohash >= 0.7 && < 0.9,
95− deepseq >= 1.3 && < 1.4,
96− directory >= 1.0 && < 1.3,
97− filepath >= 1.0 && < 1.4,
98− http-conduit >= 1.8 && < 1.10,
99− http-types >= 0.7 && < 0.9,
100− lrucache >= 1.1.1 && < 1.2,
101− mtl >= 1 && < 2.2,
102− old-locale >= 1.0 && < 1.1,
103− old-time >= 1.0 && < 1.2,
104− cmdargs >= 0.10 && < 0.11,
105− pandoc >= 1.10 && < 1.11,
106− parsec >= 3.0 && < 3.2,
107− process >= 1.0 && < 1.2,
108− random >= 1.0 && < 1.1,
109− regex-base >= 0.93 && < 0.94,
110− regex-tdfa >= 1.1 && < 1.2,
111− tagsoup >= 0.12.6 && < 0.13,
112− text >= 0.11 && < 1.12,
113− time >= 1.1 && < 1.5
114−
11590 Exposed-Modules:
11691 Hakyll
11792 Hakyll.Core.Compiler
@@ -159,6 +134,33 @@ Library
159134 Hakyll.Web.Template.Internal
160135 Paths_hakyll
161136
137+ Build-Depends:
138+ base >= 4 && < 5,
139+ binary >= 0.5 && < 0.8,
140+ blaze-html >= 0.5 && < 0.7,
141+ blaze-markup >= 0.5.1 && < 0.6,
142+ bytestring >= 0.9 && < 0.11,
143+ citeproc-hs >= 0.3.2 && < 0.4,
144+ containers >= 0.3 && < 0.6,
145+ cryptohash >= 0.7 && < 0.9,
146+ deepseq >= 1.3 && < 1.4,
147+ directory >= 1.0 && < 1.3,
148+ filepath >= 1.0 && < 1.4,
149+ lrucache >= 1.1.1 && < 1.2,
150+ mtl >= 1 && < 2.2,
151+ old-locale >= 1.0 && < 1.1,
152+ old-time >= 1.0 && < 1.2,
153+ cmdargs >= 0.10 && < 0.11,
154+ pandoc >= 1.10 && < 1.11,
155+ parsec >= 3.0 && < 3.2,
156+ process >= 1.0 && < 1.2,
157+ random >= 1.0 && < 1.1,
158+ regex-base >= 0.93 && < 0.94,
159+ regex-tdfa >= 1.1 && < 1.2,
160+ tagsoup >= 0.12.6 && < 0.13,
161+ text >= 0.11 && < 1.12,
162+ time >= 1.1 && < 1.5
163+
162164 If flag(previewServer)
163165 Build-depends:
164166 snap-core >= 0.6 && < 0.10,
@@ -169,11 +171,33 @@ Library
169171 Hakyll.Preview.Poll
170172 Hakyll.Preview.Server
171173
174+ If flag(checkExternal)
175+ Build-depends:
176+ http-conduit >= 1.8 && < 1.10,
177+ http-types >= 0.7 && < 0.9
178+ Cpp-options:
179+ -DCHECK_EXTERNAL
180+
172181Test-suite hakyll-tests
173182 Type: exitcode-stdio-1.0
174183 Hs-source-dirs: src tests
175184 Main-is: TestSuite.hs
176185 Ghc-options: -Wall
186+ Other-modules:
187+ Hakyll.Core.Dependencies.Tests
188+ Hakyll.Core.Identifier.Tests
189+ Hakyll.Core.Provider.Tests
190+ Hakyll.Core.Routes.Tests
191+ Hakyll.Core.Rules.Tests
192+ Hakyll.Core.Runtime.Tests
193+ Hakyll.Core.Store.Tests
194+ Hakyll.Core.UnixFilter.Tests
195+ Hakyll.Core.Util.String.Tests
196+ Hakyll.Web.Template.Context.Tests
197+ Hakyll.Web.Template.Tests
198+ Hakyll.Web.Html.Tests
199+ Hakyll.Web.Html.RelativizeUrls.Tests
200+ TestSuite.Util
177201
178202 Build-Depends:
179203 HUnit >= 1.2 && < 1.3,
@@ -193,14 +217,12 @@ Test-suite hakyll-tests
193217 deepseq >= 1.3 && < 1.4,
194218 directory >= 1.0 && < 1.3,
195219 filepath >= 1.0 && < 1.4,
196− http-conduit >= 1.8 && < 1.10,
197− http-types >= 0.7 && < 0.9,
198220 lrucache >= 1.1.1 && < 1.2,
199221 mtl >= 1 && < 2.2,
200222 old-locale >= 1.0 && < 1.1,
201223 old-time >= 1.0 && < 1.2,
202224 cmdargs >= 0.10 && < 0.11,
203− pandoc >= 1.0 && < 1.11,
225+ pandoc >= 1.10 && < 1.11,
204226 parsec >= 3.0 && < 3.2,
205227 process >= 1.0 && < 1.2,
206228 random >= 1.0 && < 1.1,
@@ -210,21 +232,22 @@ Test-suite hakyll-tests
210232 text >= 0.11 && < 1.12,
211233 time >= 1.1 && < 1.5
212234
213− Other-modules:
214− Hakyll.Core.Dependencies.Tests
215− Hakyll.Core.Identifier.Tests
216− Hakyll.Core.Provider.Tests
217− Hakyll.Core.Routes.Tests
218− Hakyll.Core.Rules.Tests
219− Hakyll.Core.Runtime.Tests
220− Hakyll.Core.Store.Tests
221− Hakyll.Core.UnixFilter.Tests
222− Hakyll.Core.Util.String.Tests
223− Hakyll.Web.Template.Context.Tests
224− Hakyll.Web.Template.Tests
225− Hakyll.Web.Html.Tests
226− Hakyll.Web.Html.RelativizeUrls.Tests
227− TestSuite.Util
235+ If flag(previewServer)
236+ Build-depends:
237+ snap-core >= 0.6 && < 0.10,
238+ snap-server >= 0.6 && < 0.10
239+ Cpp-options:
240+ -DPREVIEW_SERVER
241+ Other-modules:
242+ Hakyll.Preview.Poll
243+ Hakyll.Preview.Server
244+
245+ If flag(checkExternal)
246+ Build-depends:
247+ http-conduit >= 1.8 && < 1.10,
248+ http-types >= 0.7 && < 0.9
249+ Cpp-options:
250+ -DCHECK_EXTERNAL
228251
229252Executable hakyll-init
230253 Ghc-options: -Wall
src/Hakyll/Check.hs+27−10
@@ -1,4 +1,5 @@
11--------------------------------------------------------------------------------
2+{-# LANGUAGE CPP #-}
23{-# LANGUAGE OverloadedStrings #-}
34module Hakyll.Check
45 ( Check (..)
@@ -8,22 +9,15 @@ module Hakyll.Check
89
910--------------------------------------------------------------------------------
1011import Control.Applicative ((<$>))
11−import Control.Exception (AsyncException (..),
12− SomeException (..), handle, throw)
1312import Control.Monad (forM_)
1413import Control.Monad.Reader (ask)
1514import Control.Monad.RWS (RWST, runRWST)
16−import Control.Monad.State (get, modify)
1715import Control.Monad.Trans (liftIO)
1816import Control.Monad.Writer (tell)
19−import Data.List (intercalate, isPrefixOf)
17+import Data.List (isPrefixOf)
2018import Data.Monoid (Monoid (..))
2119import Data.Set (Set)
2220import qualified Data.Set as S
23−import Data.Typeable (cast)
24−import GHC.Exts (fromString)
25−import qualified Network.HTTP.Conduit as Http
26−import qualified Network.HTTP.Types as Http
2721import System.Directory (doesDirectoryExist, doesFileExist)
2822import System.Exit (ExitCode (..))
2923import System.FilePath (takeDirectory, takeExtension, (</>))
@@ -31,13 +25,26 @@ import qualified Text.HTML.TagSoup as TS
3125
3226
3327--------------------------------------------------------------------------------
28+#ifdef CHECK_EXTERNAL
29+import Control.Exception (AsyncException (..),
30+ SomeException (..), handle, throw)
31+import Control.Monad.State (get, modify)
32+import Data.List (intercalate)
33+import Data.Typeable (cast)
3434import Data.Version (versionBranch)
35+import GHC.Exts (fromString)
36+import qualified Network.HTTP.Conduit as Http
37+import qualified Network.HTTP.Types as Http
38+import qualified Paths_hakyll as Paths_hakyll
39+#endif
40+
41+
42+--------------------------------------------------------------------------------
3543import Hakyll.Core.Configuration
3644import Hakyll.Core.Logger (Logger, Verbosity)
3745import qualified Hakyll.Core.Logger as Logger
3846import Hakyll.Core.Util.File
3947import Hakyll.Web.Html
40−import qualified Paths_hakyll as Paths_hakyll
4148
4249
4350--------------------------------------------------------------------------------
@@ -87,7 +94,12 @@ runChecker :: Checker a -> Configuration -> Verbosity -> Check
8794 -> IO (a, CheckerWrite)
8895runChecker checker config verbosity check' = do
8996 logger <- Logger.new verbosity
90− let read' = CheckerRead config logger check'
97+ let read' = CheckerRead
98+ { checkerConfig = config
99+ , checkerLogger = logger
100+ , checkerCheck = check'
101+ }
102+
91103 (x, _, write) <- runRWST checker read' S.empty
92104 Logger.flush logger
93105 return (x, write)
@@ -157,6 +169,7 @@ checkInternalUrl base url = case url' of
157169
158170--------------------------------------------------------------------------------
159171checkExternalUrl :: String -> Checker ()
172+#ifdef CHECK_EXTERNAL
160173checkExternalUrl url = do
161174 logger <- checkerLogger <$> ask
162175 needsCheck <- (== All) . checkerCheck <$> ask
@@ -190,6 +203,10 @@ checkExternalUrl url = do
190203 failure logger (SomeException e) = case cast e of
191204 Just UserInterrupt -> throw UserInterrupt
192205 _ -> Logger.error logger (show e) >> return False
206+#else
207+checkExternalUrl _ = return ()
208+#endif
209+
193210
194211
195212--------------------------------------------------------------------------------