on master help sign in
defaultCopyFile → copyFileCompiler
commita5438d8d9284ba2855934fc13f318c8f2dff6db9 authorJasper Van der Jeugt <jaspervdj@gmail.com> dateTue 15 Feb 2011, 22:46 (16 years ago) parent28a30ca
4 files changed+33−19
src/Hakyll.hs+2 src/Hakyll/Core/CopyFile.hs+29 src/Hakyll/Core/Writable.hs+1−14 src/Hakyll/Web.hs+1−5
src/Hakyll.hs+2
@@ -2,6 +2,7 @@
22--
33module Hakyll
44 ( module Hakyll.Core.Compiler
5+ , module Hakyll.Core.CopyFile
56 , module Hakyll.Core.Configuration
67 , module Hakyll.Core.Identifier
78 , module Hakyll.Core.Identifier.Pattern
@@ -26,6 +27,7 @@ module Hakyll
2627 ) where
2728
2829import Hakyll.Core.Compiler
30+import Hakyll.Core.CopyFile
2931import Hakyll.Core.Configuration
3032import Hakyll.Core.Identifier
3133import 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 @@
11-- | Describes writable items; items that can be saved to the disk
22--
3−{-# LANGUAGE FlexibleInstances, GeneralizedNewtypeDeriving,
4− DeriveDataTypeable #-}
3+{-# LANGUAGE FlexibleInstances #-}
54module Hakyll.Core.Writable
65 ( Writable (..)
7− , CopyFile (..)
86 ) where
97
10−import System.Directory (copyFile)
118import Data.Word (Word8)
129
1310import qualified Data.ByteString as SB
14−import Data.Binary (Binary)
15−import Data.Typeable (Typeable)
1611
1712-- | Describes an item that can be saved to the disk
1813--
@@ -25,11 +20,3 @@ instance Writable [Char] where
2520
2621instance Writable [Word8] where
2722 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 @@
11-- | Module exporting commonly used web-related functions
22--
33module Hakyll.Web
4− ( defaultCopyFile
5− , defaultApplyTemplate
4+ ( defaultApplyTemplate
65 ) where
76
87import Control.Arrow ((>>^))
@@ -14,9 +13,6 @@ import Hakyll.Core.ResourceProvider
1413import Hakyll.Web.Page
1514import Hakyll.Web.Template
1615
17−defaultCopyFile :: Compiler Resource CopyFile
18−defaultCopyFile = getIdentifier >>^ CopyFile . toFilePath
19−
2016defaultApplyTemplate :: Identifier -- ^ Template
2117 -> Compiler (Page String) (Page String) -- ^ Compiler
2218defaultApplyTemplate identifier = require identifier (flip applyTemplate)