summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2017-12-18 20:05:28 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2017-12-18 20:05:28 +0100
commit030864a921d38405778ddeb1286e8922955c8ab4 (patch)
tree81b65317f3b48dd39f192739dcc39b5adac35c5f
parent7634b44e4ad9f6a0ba77c377eb1ee43085687789 (diff)
downloadhakyll-030864a921d38405778ddeb1286e8922955c8ab4.tar.gz
Fix warnings and errors
-rw-r--r--hakyll.cabal3
-rw-r--r--lib/Hakyll/Check.hs1
-rw-r--r--lib/Hakyll/Commands.hs4
-rw-r--r--lib/Hakyll/Web/Pandoc.hs14
-rw-r--r--test.hs30
-rw-r--r--tests/Hakyll/Web/CompressCss/Tests.hs3
-rw-r--r--tests/TestSuite/Util.hs7
7 files changed, 46 insertions, 16 deletions
diff --git a/hakyll.cabal b/hakyll.cabal
index df0509f..3692fe2 100644
--- a/hakyll.cabal
+++ b/hakyll.cabal
@@ -311,6 +311,9 @@ Executable hakyll-init
Hs-source-dirs: src
Main-is: Init.hs
+ Other-modules:
+ Paths_hakyll
+
Build-depends:
hakyll,
base >= 4 && < 5,
diff --git a/lib/Hakyll/Check.hs b/lib/Hakyll/Check.hs
index da77bac..f001cbe 100644
--- a/lib/Hakyll/Check.hs
+++ b/lib/Hakyll/Check.hs
@@ -17,7 +17,6 @@ import Control.Monad.Reader (ReaderT, ask, runReaderT)
import Control.Monad.State (StateT, get, modify, runStateT)
import Control.Monad.Trans (liftIO)
import Control.Monad.Trans.Resource (runResourceT)
-import Data.ByteString.Char8 (unpack)
import Data.List (isPrefixOf)
import qualified Data.Map.Lazy as Map
import Network.URI (unEscapeString)
diff --git a/lib/Hakyll/Commands.hs b/lib/Hakyll/Commands.hs
index 667f07a..84d1c56 100644
--- a/lib/Hakyll/Commands.hs
+++ b/lib/Hakyll/Commands.hs
@@ -16,7 +16,8 @@ module Hakyll.Commands
--------------------------------------------------------------------------------
import Control.Concurrent
-import System.Exit (ExitCode, exitWith)
+import System.Exit (ExitCode)
+
--------------------------------------------------------------------------------
import Hakyll.Check (Check(..))
@@ -29,6 +30,7 @@ import Hakyll.Core.Rules.Internal
import Hakyll.Core.Runtime
import Hakyll.Core.Util.File
+
--------------------------------------------------------------------------------
#ifdef WATCH_SERVER
import Hakyll.Preview.Poll (watchUpdates)
diff --git a/lib/Hakyll/Web/Pandoc.hs b/lib/Hakyll/Web/Pandoc.hs
index 6dcae32..5f04de4 100644
--- a/lib/Hakyll/Web/Pandoc.hs
+++ b/lib/Hakyll/Web/Pandoc.hs
@@ -22,11 +22,9 @@ module Hakyll.Web.Pandoc
--------------------------------------------------------------------------------
-import qualified Data.Set as S
+import qualified Data.Text as T
import Text.Pandoc
-import Text.Pandoc.Error (PandocError (..))
import Text.Pandoc.Highlighting (pygments)
-import qualified Data.Text as T
--------------------------------------------------------------------------------
@@ -51,11 +49,9 @@ readPandocWith
-> Compiler (Item Pandoc) -- ^ Resulting document
readPandocWith ropt item =
case runPure $ traverse (reader ropt (itemFileType item)) (fmap T.pack item) of
- Left (PandocParseError err) -> fail $
- "Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ err
- Left (PandocParsecError _ err) -> fail $
+ Left err -> fail $
"Hakyll.Web.Pandoc.readPandocWith: parse failed: " ++ show err
- Right item' -> return item'
+ Right item' -> return item'
where
reader ro t = case t of
DocBook -> readDocBook ro
@@ -88,8 +84,8 @@ writePandocWith :: WriterOptions -- ^ Writer options for pandoc
-> Item String -- ^ Resulting HTML
writePandocWith wopt (Item itemi doc) =
case runPure $ writeHtml5String wopt doc of
- Left (PandocSomeError err) -> error $ "Hakyll.Web.Pandoc.writePandocWith: unknown error: " ++ err
- Right item' -> Item itemi $ T.unpack item'
+ Left err -> error $ "Hakyll.Web.Pandoc.writePandocWith: " ++ show err
+ Right item' -> Item itemi $ T.unpack item'
--------------------------------------------------------------------------------
diff --git a/test.hs b/test.hs
new file mode 100644
index 0000000..8b3a2de
--- /dev/null
+++ b/test.hs
@@ -0,0 +1,30 @@
+{-# LANGUAGE BangPatterns #-}
+import Control.Monad (forM)
+import qualified Crypto.Hash.SHA256 as SHA256
+import qualified Data.ByteString.Base16 as Base16
+import qualified Data.ByteString.Char8 as BS8
+import qualified Data.ByteString.Lazy as BSL
+import Data.Map (Map)
+import qualified Data.Map as Map
+import Hakyll
+import System.FilePath ((</>))
+
+type FileHashes = Map Identifier String
+
+mkFileHashes :: FilePath -> IO FileHashes
+mkFileHashes dir = do
+ allFiles <- getRecursiveContents (\_ -> return False) dir
+ fmap Map.fromList $ forM allFiles $ \path0 -> do
+ let path1 = dir </> path0
+ !h <- hash path1
+ return (fromFilePath path1, h)
+ where
+ hash :: FilePath -> IO String
+ hash fp = do
+ !h <- SHA256.hashlazy <$> BSL.readFile fp
+ return $! BS8.unpack $! Base16.encode h
+
+main :: IO ()
+main = hakyll $ do
+ fileHashes <- preprocess (mkFileHashes "images")
+ undefined
diff --git a/tests/Hakyll/Web/CompressCss/Tests.hs b/tests/Hakyll/Web/CompressCss/Tests.hs
index bf51ee2..66922cd 100644
--- a/tests/Hakyll/Web/CompressCss/Tests.hs
+++ b/tests/Hakyll/Web/CompressCss/Tests.hs
@@ -5,9 +5,8 @@ module Hakyll.Web.CompressCss.Tests
--------------------------------------------------------------------------------
-import Data.Char (toUpper)
import Test.Tasty (TestTree, testGroup)
-import Test.Tasty.HUnit (assert, (@=?))
+import Test.Tasty.HUnit ((@=?))
--------------------------------------------------------------------------------
diff --git a/tests/TestSuite/Util.hs b/tests/TestSuite/Util.hs
index 35ee112..33b26ef 100644
--- a/tests/TestSuite/Util.hs
+++ b/tests/TestSuite/Util.hs
@@ -76,13 +76,14 @@ testCompilerDone store provider underlying compiler = do
result <- testCompiler store provider underlying compiler
case result of
CompilerDone x _ -> return x
- CompilerError e -> error $
+ CompilerError e -> fail $
"TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++
" threw: " ++ intercalate "; " e
- CompilerRequire i _ -> error $
+ CompilerRequire i _ -> fail $
"TestSuite.Util.testCompilerDone: compiler " ++ show underlying ++
" requires: " ++ show i
-
+ CompilerSnapshot _ _ -> fail
+ "TestSuite.Util.testCompilerDone: unexpected CompilerSnapshot"
--------------------------------------------------------------------------------