on master help sign in
defaultCopyFile → copyFileCompiler
a5438d8Jasper Van der Jeugt
src/Hakyll.hs+2
@@ -2,6 +2,7 @@
2--
2--
3module Hakyll
3module Hakyll
4 ( module Hakyll.Core.Compiler
4 ( module Hakyll.Core.Compiler
5+ , module Hakyll.Core.CopyFile
5 , module Hakyll.Core.Configuration
6 , module Hakyll.Core.Configuration
6 , module Hakyll.Core.Identifier
7 , module Hakyll.Core.Identifier
7 , module Hakyll.Core.Identifier.Pattern
8 , module Hakyll.Core.Identifier.Pattern
@@ -26,6 +27,7 @@ module Hakyll
26 ) where
27 ) where
27
28
28import Hakyll.Core.Compiler
29import Hakyll.Core.Compiler
30+import Hakyll.Core.CopyFile
29import Hakyll.Core.Configuration
31import Hakyll.Core.Configuration
30import Hakyll.Core.Identifier
32import Hakyll.Core.Identifier
31import Hakyll.Core.Identifier.Pattern
33import Hakyll.Core.Identifier.Pattern
src/Hakyll/Core/CopyFile.hsnew file+29
@@ -0,0 +1,29 @@
1+-- | Exports simple compilers to just copy files
2+--
3+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}
4+module Hakyll.Core.CopyFile
5+ ( CopyFile (..)
6+ , copyFileCompiler
7+ ) where
8+
9+import Control.Arrow ((>>^))
10+import System.Directory (copyFile)
11+
12+import Data.Typeable (Typeable)
13+import Data.Binary (Binary)
14+
15+import Hakyll.Core.ResourceProvider
16+import Hakyll.Core.Writable
17+import Hakyll.Core.Compiler
18+import Hakyll.Core.Identifier
19+
20+-- | Newtype construct around 'FilePath' which will copy the file directly
21+--
22+newtype CopyFile = CopyFile {unCopyFile :: FilePath}
23+ deriving (Show, Eq, Ord, Binary, Typeable)
24+
25+instance Writable CopyFile where
26+ write dst (CopyFile src) = copyFile src dst
27+
28+copyFileCompiler :: Compiler Resource CopyFile
29+copyFileCompiler = getIdentifier >>^ CopyFile . toFilePath
src/Hakyll/Core/Writable.hs+1−14
@@ -1,18 +1,13 @@
1-- | Describes writable items; items that can be saved to the disk
1-- | Describes writable items; items that can be saved to the disk
2--
2--
3−{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving,
3+{-# LANGUAGE FlexibleInstances #-}
4− DeriveDataTypeable #-}
5module Hakyll.Core.Writable
4module Hakyll.Core.Writable
6 ( Writable (..)
5 ( Writable (..)
7− , CopyFile (..)
8 ) where
6 ) where
9
7
10−import System.Directory (copyFile)
11import Data.Word (Word8)
8import Data.Word (Word8)
12
9
13import qualified Data.ByteString as SB
10import qualified Data.ByteString as SB
14−import Data.Binary (Binary)
15−import Data.Typeable (Typeable)
16
11
17-- | Describes an item that can be saved to the disk
12-- | Describes an item that can be saved to the disk
18--
13--
@@ -25,11 +20,3 @@ instance Writable [Char] where
25
20
26instance Writable [Word8] where
21instance Writable [Word8] where
27 write p = SB.writeFile p . SB.pack
22 write p = SB.writeFile p . SB.pack
28−
29−-- | Newtype construct around 'FilePath' which will copy the file directly
30−--
31−newtype CopyFile = CopyFile {unCopyFile :: FilePath}
32− deriving (Show, Eq, Ord, Binary, Typeable)
33−
34−instance Writable CopyFile where
35− write dst (CopyFile src) = copyFile src dst
src/Hakyll/Web.hs+1−5
@@ -1,8 +1,7 @@
1-- | Module exporting commonly used web-related functions
1-- | Module exporting commonly used web-related functions
2--
2--
3module Hakyll.Web
3module Hakyll.Web
4− ( defaultCopyFile
5− , defaultApplyTemplate
4+ ( defaultApplyTemplate
6 ) where
5 ) where
7
6
8import Control.Arrow ((>>^))
7import Control.Arrow ((>>^))
@@ -14,9 +13,6 @@ import Hakyll.Core.ResourceProvider
14import Hakyll.Web.Page
13import Hakyll.Web.Page
15import Hakyll.Web.Template
14import Hakyll.Web.Template
16
15
17−defaultCopyFile :: Compiler Resource CopyFile
18−defaultCopyFile = getIdentifier >>^ CopyFile . toFilePath
19−
20defaultApplyTemplate :: Identifier -- ^ Template
16defaultApplyTemplate :: Identifier -- ^ Template
21 -> Compiler (Page String) (Page String) -- ^ Compiler
17 -> Compiler (Page String) (Page String) -- ^ Compiler
22defaultApplyTemplate identifier = require identifier (flip applyTemplate)
18defaultApplyTemplate identifier = require identifier (flip applyTemplate)