diff options
author | Joris | 2019-05-01 15:52:32 +0200 |
---|---|---|
committer | Joris | 2019-05-01 17:11:02 +0200 |
commit | 23f04635cc26e1b0553088f28553f518488a9fc8 (patch) | |
tree | 97037643bab24564046ce4aba90481e3b92a15d3 /src/PDF.hs | |
parent | 0fe906ae7453aa684e998bbcc7a78b62d84f0206 (diff) |
Setup personal page with Hakyll
Diffstat (limited to 'src/PDF.hs')
-rw-r--r-- | src/PDF.hs | 41 |
1 files changed, 0 insertions, 41 deletions
diff --git a/src/PDF.hs b/src/PDF.hs deleted file mode 100644 index a002b38..0000000 --- a/src/PDF.hs +++ /dev/null @@ -1,41 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} - -module PDF - ( generatePDFAt - ) where - -import Control.Exception (SomeException, try) -import System.Directory (copyFile, createDirectoryIfMissing) -import System.FilePath (takeDirectory) -import System.IO (hClose) -import System.IO.Temp (withTempFile) -import qualified System.Process as Process (callCommand) -import Text.LaTeX (LaTeX, renderFile) - -generatePDFAt :: FilePath -> LaTeX -> IO () -generatePDFAt path latex = do - (basePath, tmpPath) <- generatePDF latex - createDirectoryIfMissing True (takeDirectory path) - copyFile tmpPath path - Process.callCommand ("rm " ++ basePath ++ "*") - -generatePDF :: LaTeX -> IO (FilePath, FilePath) -generatePDF latex = - withTempFile "/tmp" "latex" $ \filePath handle -> do - hClose handle - renderFile filePath latex - renderFile "/home/joris/resume.tex" latex - pdfCommand filePath - pdfCommand filePath - return (filePath, filePath ++ ".pdf") - -pdfCommand :: String -> IO () -pdfCommand path = do - let command = "cd resume && pdflatex --output-directory /tmp " ++ path ++ " >/dev/null" - result <- try $ Process.callCommand command :: IO (Either SomeException ()) - case result of - Left err -> do - putStrLn "Error generating PDF:" - putStrLn (show err) - Right _ -> - return () |