1--------------------------------------------------------------------------------
2-- | Exports simple compilers to just copy files
3{-# LANGUAGE DeriveDataTypeable #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
13--------------------------------------------------------------------------------
14import Control.Applicative ((<$>))
15import Data.Binary (Binary (..))
16import Data.Typeable (Typeable)
17import System.Directory (copyFile, doesFileExist,
19import System.FilePath ((</>))
20import System.Random (randomIO)
23--------------------------------------------------------------------------------
24import Hakyll.Core.Compiler
25import Hakyll.Core.Compiler.Internal
26import Hakyll.Core.Configuration
27import Hakyll.Core.Identifier
28import Hakyll.Core.Item
29import qualified Hakyll.Core.Store as Store
30import Hakyll.Core.Util.File
31import Hakyll.Core.Writable
34--------------------------------------------------------------------------------
35-- | This will copy any file directly by using a system call
36data CopyFile = CopyFile
37 deriving (Show, Eq, Ord, Typeable)
40--------------------------------------------------------------------------------
41instance Binary CopyFile where
42 put CopyFile = return ()
46--------------------------------------------------------------------------------
47instance Writable CopyFile where
48 write dst item = copyFile (toFilePath $ itemIdentifier item) dst
51--------------------------------------------------------------------------------
52copyFileCompiler :: Compiler (Item CopyFile)
53copyFileCompiler = makeItem CopyFile
56--------------------------------------------------------------------------------
57newtype TmpFile = TmpFile FilePath
61--------------------------------------------------------------------------------
62instance Binary TmpFile where
65 "Hakyll.Core.File.TmpFile: You tried to load a TmpFile, however, " ++
66 "this is not possible since these are deleted as soon as possible."
69--------------------------------------------------------------------------------
70instance Writable TmpFile where
71 write dst (Item _ (TmpFile fp)) = renameFile fp dst
74--------------------------------------------------------------------------------
76newTmpFile :: String -- ^ Suffix and extension
77 -> Compiler TmpFile -- ^ Resulting tmp path
80 compilerUnsafeIO $ makeDirectories path
81 debugCompiler $ "newTmpFile " ++ path
85 rand <- compilerUnsafeIO $ randomIO :: Compiler Int
86 tmp <- tmpDirectory . compilerConfig <$> compilerAsk
87 let path = tmp </> Store.hash [show rand] ++ "-" ++ suffix
88 exists <- compilerUnsafeIO $ doesFileExist path
89 if exists then mkPath else return path
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list