on master help sign in
Make http-conduit dependency optional
5241e87Jasper Van der Jeugt
hakyll.cabal+70−47
@@ -78,40 +78,15 @@ Flag previewServer
78 Description: Include the preview server
78 Description: Include the preview server
79 Default: True
79 Default: True
80
80
81+Flag checkExternal
82+ Description: Include external link checking
83+ Default: True
84+
81Library
85Library
82 Ghc-Options: -Wall
86 Ghc-Options: -Wall
83 Ghc-Prof-Options: -auto-all -caf-all
87 Ghc-Prof-Options: -auto-all -caf-all
84 Hs-Source-Dirs: src
88 Hs-Source-Dirs: src
85
89
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−
115 Exposed-Modules:
90 Exposed-Modules:
116 Hakyll
91 Hakyll
117 Hakyll.Core.Compiler
92 Hakyll.Core.Compiler
@@ -159,6 +134,33 @@ Library
159 Hakyll.Web.Template.Internal
134 Hakyll.Web.Template.Internal
160 Paths_hakyll
135 Paths_hakyll
161
136
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+
162 If flag(previewServer)
164 If flag(previewServer)
163 Build-depends:
165 Build-depends:
164 snap-core >= 0.6 && < 0.10,
166 snap-core >= 0.6 && < 0.10,
@@ -169,11 +171,33 @@ Library
169 Hakyll.Preview.Poll
171 Hakyll.Preview.Poll
170 Hakyll.Preview.Server
172 Hakyll.Preview.Server
171
173
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+
172Test-suite hakyll-tests
181Test-suite hakyll-tests
173 Type: exitcode-stdio-1.0
182 Type: exitcode-stdio-1.0
174 Hs-source-dirs: src tests
183 Hs-source-dirs: src tests
175 Main-is: TestSuite.hs
184 Main-is: TestSuite.hs
176 Ghc-options: -Wall
185 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
177
201
178 Build-Depends:
202 Build-Depends:
179 HUnit >= 1.2 && < 1.3,
203 HUnit >= 1.2 && < 1.3,
@@ -193,14 +217,12 @@ Test-suite hakyll-tests
193 deepseq >= 1.3 && < 1.4,
217 deepseq >= 1.3 && < 1.4,
194 directory >= 1.0 && < 1.3,
218 directory >= 1.0 && < 1.3,
195 filepath >= 1.0 && < 1.4,
219 filepath >= 1.0 && < 1.4,
196− http-conduit >= 1.8 && < 1.10,
197− http-types >= 0.7 && < 0.9,
198 lrucache >= 1.1.1 && < 1.2,
220 lrucache >= 1.1.1 && < 1.2,
199 mtl >= 1 && < 2.2,
221 mtl >= 1 && < 2.2,
200 old-locale >= 1.0 && < 1.1,
222 old-locale >= 1.0 && < 1.1,
201 old-time >= 1.0 && < 1.2,
223 old-time >= 1.0 && < 1.2,
202 cmdargs >= 0.10 && < 0.11,
224 cmdargs >= 0.10 && < 0.11,
203− pandoc >= 1.0 && < 1.11,
225+ pandoc >= 1.10 && < 1.11,
204 parsec >= 3.0 && < 3.2,
226 parsec >= 3.0 && < 3.2,
205 process >= 1.0 && < 1.2,
227 process >= 1.0 && < 1.2,
206 random >= 1.0 && < 1.1,
228 random >= 1.0 && < 1.1,
@@ -210,21 +232,22 @@ Test-suite hakyll-tests
210 text >= 0.11 && < 1.12,
232 text >= 0.11 && < 1.12,
211 time >= 1.1 && < 1.5
233 time >= 1.1 && < 1.5
212
234
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
213− Other-modules:
241+ Other-modules:
214− Hakyll.Core.Dependencies.Tests
242+ Hakyll.Preview.Poll
215− Hakyll.Core.Identifier.Tests
243+ Hakyll.Preview.Server
216− Hakyll.Core.Provider.Tests
244+
217− Hakyll.Core.Routes.Tests
245+ If flag(checkExternal)
218− Hakyll.Core.Rules.Tests
246+ Build-depends:
219− Hakyll.Core.Runtime.Tests
247+ http-conduit >= 1.8 && < 1.10,
220− Hakyll.Core.Store.Tests
248+ http-types >= 0.7 && < 0.9
221− Hakyll.Core.UnixFilter.Tests
249+ Cpp-options:
222− Hakyll.Core.Util.String.Tests
250+ -DCHECK_EXTERNAL
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
228
251
229Executable hakyll-init
252Executable hakyll-init
230 Ghc-options: -Wall
253 Ghc-options: -Wall
src/Hakyll/Check.hs+27−10
@@ -1,4 +1,5 @@
1--------------------------------------------------------------------------------
1--------------------------------------------------------------------------------
2+{-# LANGUAGE CPP #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE OverloadedStrings #-}
3module Hakyll.Check
4module Hakyll.Check
4 ( Check (..)
5 ( Check (..)
@@ -8,22 +9,15 @@ module Hakyll.Check
8
9
9--------------------------------------------------------------------------------
10--------------------------------------------------------------------------------
10import Control.Applicative ((<$>))
11import Control.Applicative ((<$>))
11−import Control.Exception (AsyncException (..),
12− SomeException (..), handle, throw)
13import Control.Monad (forM_)
12import Control.Monad (forM_)
14import Control.Monad.Reader (ask)
13import Control.Monad.Reader (ask)
15import Control.Monad.RWS (RWST, runRWST)
14import Control.Monad.RWS (RWST, runRWST)
16−import Control.Monad.State (get, modify)
17import Control.Monad.Trans (liftIO)
15import Control.Monad.Trans (liftIO)
18import Control.Monad.Writer (tell)
16import Control.Monad.Writer (tell)
19−import Data.List (intercalate, isPrefixOf)
17+import Data.List (isPrefixOf)
20import Data.Monoid (Monoid (..))
18import Data.Monoid (Monoid (..))
21import Data.Set (Set)
19import Data.Set (Set)
22import qualified Data.Set as S
20import 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
27import System.Directory (doesDirectoryExist, doesFileExist)
21import System.Directory (doesDirectoryExist, doesFileExist)
28import System.Exit (ExitCode (..))
22import System.Exit (ExitCode (..))
29import System.FilePath (takeDirectory, takeExtension, (</>))
23import System.FilePath (takeDirectory, takeExtension, (</>))
@@ -31,13 +25,26 @@ import qualified Text.HTML.TagSoup as TS
31
25
32
26
33--------------------------------------------------------------------------------
27--------------------------------------------------------------------------------
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)
34import Data.Version (versionBranch)
34import 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+--------------------------------------------------------------------------------
35import Hakyll.Core.Configuration
43import Hakyll.Core.Configuration
36import Hakyll.Core.Logger (Logger, Verbosity)
44import Hakyll.Core.Logger (Logger, Verbosity)
37import qualified Hakyll.Core.Logger as Logger
45import qualified Hakyll.Core.Logger as Logger
38import Hakyll.Core.Util.File
46import Hakyll.Core.Util.File
39import Hakyll.Web.Html
47import Hakyll.Web.Html
40−import qualified Paths_hakyll as Paths_hakyll
41
48
42
49
43--------------------------------------------------------------------------------
50--------------------------------------------------------------------------------
@@ -87,7 +94,12 @@ runChecker :: Checker a -> Configuration -> Verbosity -> Check
87 -> IO (a, CheckerWrite)
94 -> IO (a, CheckerWrite)
88runChecker checker config verbosity check' = do
95runChecker checker config verbosity check' = do
89 logger <- Logger.new verbosity
96 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+
91 (x, _, write) <- runRWST checker read' S.empty
103 (x, _, write) <- runRWST checker read' S.empty
92 Logger.flush logger
104 Logger.flush logger
93 return (x, write)
105 return (x, write)
@@ -157,6 +169,7 @@ checkInternalUrl base url = case url' of
157
169
158--------------------------------------------------------------------------------
170--------------------------------------------------------------------------------
159checkExternalUrl :: String -> Checker ()
171checkExternalUrl :: String -> Checker ()
172+#ifdef CHECK_EXTERNAL
160checkExternalUrl url = do
173checkExternalUrl url = do
161 logger <- checkerLogger <$> ask
174 logger <- checkerLogger <$> ask
162 needsCheck <- (== All) . checkerCheck <$> ask
175 needsCheck <- (== All) . checkerCheck <$> ask
@@ -190,6 +203,10 @@ checkExternalUrl url = do
190 failure logger (SomeException e) = case cast e of
203 failure logger (SomeException e) = case cast e of
191 Just UserInterrupt -> throw UserInterrupt
204 Just UserInterrupt -> throw UserInterrupt
192 _ -> Logger.error logger (show e) >> return False
205 _ -> Logger.error logger (show e) >> return False
206+#else
207+checkExternalUrl _ = return ()
208+#endif
209+
193
210
194
211
195--------------------------------------------------------------------------------
212--------------------------------------------------------------------------------