From a6a4910acf051e83c7341450dc3a987d86b2b3de Mon Sep 17 00:00:00 2001 From: "Yann Esposito (Yogsototh)" Date: Sat, 27 Jun 2020 15:49:25 +0200 Subject: [PATCH] Updates, added pdf. --- Shakefile.hs | 33 ++++++++++++++++++++++++++-- _full/.gitignore | 2 -- engine/deeplist.tex | 24 ++++++++++++++++++++ src/posts/0010-Haskell-Now/index.org | 17 +++++++------- templates/post.mustache | 1 + 5 files changed, 64 insertions(+), 13 deletions(-) delete mode 100644 _full/.gitignore create mode 100644 engine/deeplist.tex diff --git a/Shakefile.hs b/Shakefile.hs index fb4fb08..61eaf8b 100644 --- a/Shakefile.hs +++ b/Shakefile.hs @@ -148,6 +148,11 @@ buildRules = do if out == siteDir "archive.html" then buildArchive getPosts getTemplate out else genHtmlAction getPost getTemplate out + ".pdf" -> do + txtExists <- doesFileExist (srcDir asset) + if txtExists + then copyFileChanged (srcDir asset) out + else genPdfAction getPost out ".txt" -> do txtExists <- doesFileExist (srcDir asset) if txtExists @@ -261,8 +266,11 @@ genHtmlAction :: (FilePath -> Action BlogPost) -> (FilePath -> Action Template) -> [Char] -> Action () genHtmlAction getPost getTemplate out = do - let isPost = takeDirectory1 (dropDirectory1 out) == "posts" - template <- getTemplate ("templates" if isPost then "post.mustache" else "main.mustache") + let tplname = case takeDirectory1 (dropDirectory1 out) of + "posts" -> "post.mustache" + "drafts" -> "post.mustache" + _ -> "main.mustache" + template <- getTemplate ("templates" tplname) let srcFile = srcDir (dropDirectory1 (out -<.> "org")) liftIO $ putText $ "need: " <> (toS srcFile) <> " -> " <> (toS out) need [srcFile] @@ -278,6 +286,7 @@ genHtmlAction getPost getTemplate out = do , "body" .= innerHtml , "orgsource" .= T.pack (postUrl bp -<.> "org") , "txtsource" .= T.pack (postUrl bp -<.> "txt") + , "pdf" .= T.pack (postUrl bp -<.> "pdf") , "permalink" .= T.pack (toS origin <> postUrl bp) ] writeFile' out (toS htmlContent) @@ -305,12 +314,31 @@ genAsciiAction getPost out = do <> toS origin <> toS (postUrl bp) <> "\n\n" writeFile' out (toS (preamble <> toS innerAscii)) +genPdfAction getPost out = do + let srcFile = srcDir (dropDirectory1 (out -<.> "org")) + need [srcFile] + command_ [] "pandoc" + ["--pdf-engine=xelatex" + , "--resource-path=" <> takeDirectory srcFile + , srcFile + , "-H", "engine" "deeplist.tex" + , "-V", "mainfont:Hoefler Text" + , "-V", "monofont:Menlo" + , "-V", "monofontoptions:Scale=0.7" + , "-o", out ] + allHtmlAction :: Action () allHtmlAction = do allOrgFiles <- getDirectoryFiles srcDir ["//*.org"] let allHtmlFiles = map (-<.> "html") allOrgFiles need (map build allHtmlFiles) +allPdfAction :: Action () +allPdfAction = do + allOrgFiles <- getDirectoryFiles srcDir ["//*.org"] + let allHtmlFiles = map (-<.> "pdf") allOrgFiles + need (map build allHtmlFiles) + allAsciiAction :: Action () allAsciiAction = do allOrgFiles <- getDirectoryFiles srcDir ["//*.org"] @@ -341,6 +369,7 @@ needAll = do need (map build $ allAssets <> ["archive.html"]) allHtmlAction allAsciiAction + allPdfAction allRule :: Rules () allRule = phony "all" needAll diff --git a/_full/.gitignore b/_full/.gitignore deleted file mode 100644 index d6b7ef3..0000000 --- a/_full/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/engine/deeplist.tex b/engine/deeplist.tex new file mode 100644 index 0000000..3776db4 --- /dev/null +++ b/engine/deeplist.tex @@ -0,0 +1,24 @@ +\usepackage{enumitem} +\setlistdepth{9} + +\setlist[itemize,1]{label=$\bullet$} +\setlist[itemize,2]{label=$\bullet$} +\setlist[itemize,3]{label=$\bullet$} +\setlist[itemize,4]{label=$\bullet$} +\setlist[itemize,5]{label=$\bullet$} +\setlist[itemize,6]{label=$\bullet$} +\setlist[itemize,7]{label=$\bullet$} +\setlist[itemize,8]{label=$\bullet$} +\setlist[itemize,9]{label=$\bullet$} +\renewlist{itemize}{itemize}{9} + +\setlist[enumerate,1]{label=$\arabic*.$} +\setlist[enumerate,2]{label=$\alph*.$} +\setlist[enumerate,3]{label=$\roman*.$} +\setlist[enumerate,4]{label=$\arabic*.$} +\setlist[enumerate,5]{label=$\alpha*$} +\setlist[enumerate,6]{label=$\roman*.$} +\setlist[enumerate,7]{label=$\arabic*.$} +\setlist[enumerate,8]{label=$\alph*.$} +\setlist[enumerate,9]{label=$\roman*.$} +\renewlist{enumerate}{enumerate}{9} diff --git a/src/posts/0010-Haskell-Now/index.org b/src/posts/0010-Haskell-Now/index.org index 4bc5b4f..3a18613 100644 --- a/src/posts/0010-Haskell-Now/index.org +++ b/src/posts/0010-Haskell-Now/index.org @@ -36,7 +36,7 @@ Since I wrote my article the Haskell ecosystem has evolved: While the learning curve is as steep as before, the highest point of learning just climbed higher and higher with each successive new GHC release. 3. Still no real consencus about how to work, learn, and use Haskell. - In my opinion there are three different perspective on Haskell that + In my opinion there are three different perspectives on Haskell that could definitively change how you make decisions about different aspect of Haskell programming. I believe the main groups of ideolgies are application developers, library @@ -67,21 +67,20 @@ I am kind of confident that my Haskell understanding is a lot better than before. But I still think, the ability to learn new Haskell subject is infinite. -One article I would like to write someday is about my current team -philosophy about programming. +Someday I would like to write a post about my current team philosophy about +programming. Our main rule is to use as few features of a programming language as -possible to achieve your goal. +possible to achieve our goal. This is a kind of merge between minimalism and pragmatism that in the end provide a tremendous amount of benefits. -This is why, even if I like to play with the latest Haskell trendy features, -I generally program without those. +This is why, even if I like to play with the latest Haskell trendy +features, I generally program without those. With just a very few amount of Haskell features you will already be in enviromnent with a *lot* of benefits as compared to many programming languages. -So enough talk, here is my old article updated with a some changes and -cleanups. -I also added a section about how to create a new project template with nix. +So enough talk, here is my updated article. +I added a section about how to create a new project template with nix. I will try to write other articles about how to write a real program in Haskell. diff --git a/templates/post.mustache b/templates/post.mustache index e963c55..628730d 100644 --- a/templates/post.mustache +++ b/templates/post.mustache @@ -35,6 +35,7 @@ Yann Esposito's blog - source - txt - + pdf -