1--------------------------------------------------------------------------------
2-- | Exports simple compilers to just copy files
3{-# LANGUAGE DeriveDataTypeable #-}
4{-# LANGUAGE GeneralizedNewtypeDeriving #-}
13--------------------------------------------------------------------------------
14import Data.Binary (Binary (..))
15import Data.Typeable (Typeable)
16import System.Directory (copyFile, doesFileExist,
18import System.FilePath ((</>))
19import System.Random (randomIO)
22--------------------------------------------------------------------------------
23import Hakyll.Core.Compiler
24import Hakyll.Core.Compiler.Internal
25import Hakyll.Core.Configuration
26import Hakyll.Core.Item
27import Hakyll.Core.Provider
28import qualified Hakyll.Core.Store as Store
29import Hakyll.Core.Util.File
30import Hakyll.Core.Writable
33--------------------------------------------------------------------------------
34-- | This will copy any file directly by using a system call
35newtype CopyFile = CopyFile FilePath
36 deriving (Binary, Eq, Ord, Show, Typeable)
39--------------------------------------------------------------------------------
40instance Writable CopyFile where
41 write dst (Item _ (CopyFile src)) = copyFile src dst
44--------------------------------------------------------------------------------
45copyFileCompiler :: Compiler (Item CopyFile)
47 identifier <- getUnderlying
48 provider <- compilerProvider <$> compilerAsk
49 makeItem $ CopyFile $ resourceFilePath provider identifier
52--------------------------------------------------------------------------------
53newtype TmpFile = TmpFile FilePath
57--------------------------------------------------------------------------------
58instance Binary TmpFile where
61 "Hakyll.Core.File.TmpFile: You tried to load a TmpFile, however, " ++
62 "this is not possible since these are deleted as soon as possible."
65--------------------------------------------------------------------------------
66instance Writable TmpFile where
67 write dst (Item _ (TmpFile fp)) = renameFile fp dst
70--------------------------------------------------------------------------------
72newTmpFile :: String -- ^ Suffix and extension
73 -> Compiler TmpFile -- ^ Resulting tmp path
76 compilerUnsafeIO $ makeDirectories path
77 debugCompiler $ "newTmpFile " ++ path
81 rand <- compilerUnsafeIO $ randomIO :: Compiler Int
82 tmp <- tmpDirectory . compilerConfig <$> compilerAsk
83 let path = tmp </> Store.hash [show rand] ++ "-" ++ suffix
84 exists <- compilerUnsafeIO $ doesFileExist path
85 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