Shake.hs, hakyll-std: build static parts of site directly with Shake target website-copy
This commit is contained in:
parent
9c99dcde39
commit
0669111c71
16
Shake.hs
16
Shake.hs
@ -73,6 +73,7 @@ hakyllstd = "site/hakyll-std/hakyll-std"
|
|||||||
makeinfo = "makeinfo"
|
makeinfo = "makeinfo"
|
||||||
-- nroff = "nroff"
|
-- nroff = "nroff"
|
||||||
groff = "groff"
|
groff = "groff"
|
||||||
|
dropDirectory2 = dropDirectory1 . dropDirectory1
|
||||||
|
|
||||||
main = do
|
main = do
|
||||||
|
|
||||||
@ -142,6 +143,9 @@ main = do
|
|||||||
-- manuals rendered to markdown and combined, ready for web output by hakyll
|
-- manuals rendered to markdown and combined, ready for web output by hakyll
|
||||||
webmanall = "site/manual.md"
|
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
|
-- hledger.1 -> hledger/doc, hledger_journal.5 -> hledger-lib/doc
|
||||||
manpageDir m
|
manpageDir m
|
||||||
| '_' `elem` m = "hledger-lib"
|
| '_' `elem` m = "hledger-lib"
|
||||||
@ -221,6 +225,7 @@ main = do
|
|||||||
webmanpages ++
|
webmanpages ++
|
||||||
[webmanall
|
[webmanall
|
||||||
,hakyllstd
|
,hakyllstd
|
||||||
|
,"website-copy"
|
||||||
]
|
]
|
||||||
cmd Shell (Cwd "site") "hakyll-std/hakyll-std" "build"
|
cmd Shell (Cwd "site") "hakyll-std/hakyll-std" "build"
|
||||||
-- website also links to old manuals, which are generated manually
|
-- website also links to old manuals, which are generated manually
|
||||||
@ -276,6 +281,17 @@ main = do
|
|||||||
cmd Shell "cp -r site/images" snapshot :: Action ExitCode
|
cmd Shell "cp -r site/images" snapshot :: Action ExitCode
|
||||||
cmd Shell "touch" out -- :: 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
|
-- build standard hakyll script used for site rendering
|
||||||
hakyllstd %> \out -> do
|
hakyllstd %> \out -> do
|
||||||
let dir = takeDirectory out
|
let dir = takeDirectory out
|
||||||
|
|||||||
@ -59,45 +59,6 @@ import Debug.Trace
|
|||||||
strace :: Show a => a -> a
|
strace :: Show a => a -> a
|
||||||
strace a = trace (show 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 =
|
filesToRender =
|
||||||
["*.md"
|
["*.md"
|
||||||
,"*.mdwn"
|
,"*.mdwn"
|
||||||
@ -128,8 +89,6 @@ main = do
|
|||||||
|
|
||||||
hakyll $ do
|
hakyll $ do
|
||||||
|
|
||||||
match (foldl1 (.||.) filesToCopy) $ route idRoute >> compile copyFileCompiler
|
|
||||||
|
|
||||||
-- there might or might not be a site template in ./ or ./site/
|
-- there might or might not be a site template in ./ or ./site/
|
||||||
mtmpl <- preprocess $ do
|
mtmpl <- preprocess $ do
|
||||||
t1 <- doesFileExist "site.tmpl"
|
t1 <- doesFileExist "site.tmpl"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user