From 0669111c71ebf914504210984abd9ec1cee8d991 Mon Sep 17 00:00:00 2001 From: Everett Hildenbrandt Date: Fri, 27 Apr 2018 21:29:26 -0600 Subject: [PATCH] Shake.hs, hakyll-std: build static parts of site directly with Shake target `website-copy` --- Shake.hs | 18 ++++++++++++++- site/hakyll-std/hakyll-std.hs | 41 ----------------------------------- 2 files changed, 17 insertions(+), 42 deletions(-) diff --git a/Shake.hs b/Shake.hs index ea2f69b82..41ab2e6d6 100755 --- a/Shake.hs +++ b/Shake.hs @@ -73,6 +73,7 @@ hakyllstd = "site/hakyll-std/hakyll-std" makeinfo = "makeinfo" -- nroff = "nroff" groff = "groff" +dropDirectory2 = dropDirectory1 . dropDirectory1 main = do @@ -142,6 +143,9 @@ main = do -- manuals rendered to markdown and combined, ready for web output by hakyll webmanall = "site/manual.md" + -- file extensions which should just be copied directly over to the website + webcopyfileexts = ["png", "gif", "cur", "js", "css", "eot", "ttf", "woff", "svg"] + -- hledger.1 -> hledger/doc, hledger_journal.5 -> hledger-lib/doc manpageDir m | '_' `elem` m = "hledger-lib" @@ -221,11 +225,12 @@ main = do webmanpages ++ [webmanall ,hakyllstd + ,"website-copy" ] cmd Shell (Cwd "site") "hakyll-std/hakyll-std" "build" -- website also links to old manuals, which are generated manually -- with ./Shake websnapshot and committed - -- TODO: when pandoc filters are missing, ./Shake website complains about them before building them + -- TODO: when pandoc filters are missing, ./Shake website complains about them before building them -- ./Shake.hs && ./Shake Clean && (cd site/hakyll-std; ./hakyll-std.hs) && ./Shake website -- use m4 and pandoc to process macros and filter content, leaving markdown suitable for web output @@ -276,6 +281,17 @@ main = do cmd Shell "cp -r site/images" snapshot :: Action ExitCode cmd Shell "touch" out -- :: Action ExitCode + phony "website-copy" $ do + orig_files <- getDirectoryFiles "site" (map ("//*" <.>) webcopyfileexts) + need [ "site/_site" file + | file <- "files/README" : orig_files + , not ("_site//*" ?== file) + ] + + "site/_site/files/README" : [ "site/_site//*" <.> ext | ext <- webcopyfileexts ] |%> \out -> do + let input = "site" dropDirectory2 out + copyFile' input out + -- build standard hakyll script used for site rendering hakyllstd %> \out -> do let dir = takeDirectory out diff --git a/site/hakyll-std/hakyll-std.hs b/site/hakyll-std/hakyll-std.hs index 5491e8cbe..72f7faf13 100755 --- a/site/hakyll-std/hakyll-std.hs +++ b/site/hakyll-std/hakyll-std.hs @@ -59,45 +59,6 @@ import Debug.Trace strace :: Show a => a -> a strace a = trace (show a) a -filesToCopy = - ["site/css/**" - ,"site/js/**" - ,"site/img/**" - ,"site/images/**" - ,"site/fonts/**" - ,"site/files/**" - ,"site/etc/**" - ,"site/*.html" - ,"site/*.htm" - ,"site/*.gif" - ,"site/*.jpg" - ,"site/*.jpeg" - ,"site/*.png" - ,"site/*.css" - ,"site/*.js" - ,"css/**" - ,"js/**" - ,"img/**" - ,"images/**" - ,"fonts/**" - ,"files/**" - ,"doc/**.html" - ,"doc/**.htm" - ,"doc/**.txt" - ,"doc/**.gif" - ,"doc/**.jpg" - ,"doc/**.jpeg" - ,"doc/**.png" - ,"*.html" - ,"*.htm" - ,"*.css" - ,"*.js" - ,"*.gif" - ,"*.jpg" - ,"*.jpeg" - ,"*.png" - ] - filesToRender = ["*.md" ,"*.mdwn" @@ -128,8 +89,6 @@ main = do hakyll $ do - match (foldl1 (.||.) filesToCopy) $ route idRoute >> compile copyFileCompiler - -- there might or might not be a site template in ./ or ./site/ mtmpl <- preprocess $ do t1 <- doesFileExist "site.tmpl"