Shake.hs, hakyll-std: build static parts of site directly with Shake target website-copy
This commit is contained in:
parent
9c99dcde39
commit
0669111c71
18
Shake.hs
18
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
|
||||
|
||||
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user