mirror of
https://github.com/simonmichael/hledger.git
synced 2024-09-18 17:57:11 +03:00
docs: move most docs to doc/, hakyll cleanups fixing site preview
This commit is contained in:
parent
d3794ba5b6
commit
6b9f5d37a5
28
Makefile
28
Makefile
@ -76,13 +76,13 @@ WEBFILES:= \
|
||||
hledger-web/static/*.css
|
||||
|
||||
DOCFILES:= \
|
||||
*.md
|
||||
doc/*.md
|
||||
|
||||
# files which should be updated when the version changes
|
||||
VERSIONSENSITIVEFILES=\
|
||||
$(CABALFILES) \
|
||||
MANUAL.md \
|
||||
# DOWNLOAD.md \
|
||||
doc/MANUAL.md \
|
||||
# doc/DOWNLOAD.md \
|
||||
|
||||
# file(s) which require recompilation for a build to have an up-to-date version string
|
||||
VERSIONSOURCEFILE=hledger/Hledger/Cli/Version.hs
|
||||
@ -563,13 +563,13 @@ docs: site codedocs
|
||||
site: site/site
|
||||
cd site; ./site build
|
||||
|
||||
cleansite: site/site cleanoldsource
|
||||
cleansite: site/site cleanolddocs
|
||||
cd site; ./site clean
|
||||
|
||||
previewsite: site/site
|
||||
cd site; ./site preview
|
||||
|
||||
site/site: site/site.hs oldsource
|
||||
site/site: site/site.hs olddocs
|
||||
cd site; $(GHC) site.hs $(PREFERMACUSRLIBFLAGS)
|
||||
|
||||
autosite:
|
||||
@ -580,24 +580,24 @@ viewsite: site
|
||||
|
||||
# ensure some old doc versions are in place:
|
||||
|
||||
oldsource: site/0.22 site/0.21 site/0.20 site/0.19 site/0.18
|
||||
olddocs: site/0.22 site/0.21 #site/0.20 site/0.19 site/0.18
|
||||
|
||||
site/0.22:
|
||||
git archive --prefix site/0.22/ tags/0.22 '*.md' | tar xf -
|
||||
git archive --prefix site/0.22/ tags/0.22 'doc/*.md' | tar xf -
|
||||
|
||||
site/0.21:
|
||||
git archive --prefix site/0.21/ tags/0.21.3 '*.md' | tar xf -
|
||||
git archive --prefix site/0.21/ tags/0.21.3 'doc/*.md' | tar xf -
|
||||
|
||||
site/0.20:
|
||||
git archive --prefix site/0.20/ tags/0.20 '*.md' | tar xf -
|
||||
git archive --prefix site/0.20/ tags/0.20 'doc/*.md' | tar xf -
|
||||
|
||||
site/0.19:
|
||||
git archive --prefix site/0.19/ tags/0_19_3 '*.md' | tar xf -
|
||||
git archive --prefix site/0.19/ tags/0_19_3 'doc/*.md' | tar xf -
|
||||
|
||||
site/0.18:
|
||||
git archive --prefix site/0.18/ tags/0_18_2 '*.md' | tar xf -
|
||||
git archive --prefix site/0.18/ tags/0_18_2 'doc/*.md' | tar xf -
|
||||
|
||||
cleanoldsource:
|
||||
cleanolddocs:
|
||||
cd site; rm -rf 0.22 0.21 0.20 0.19 0.18
|
||||
|
||||
# generate html versions of docs (and the hledger.org website)
|
||||
@ -819,10 +819,10 @@ hledger-web/hledger-web.cabal: $(VERSIONFILE)
|
||||
perl -p -e "s/(^[ ,]*hledger-lib *[>=]=) *.*/\1 $(VERSION)/" -i $@
|
||||
perl -p -e "s/(-DVERSION=\")[^\"]+/\$${1}$(VERSION)/" -i $@
|
||||
|
||||
MANUAL.md: $(VERSIONFILE)
|
||||
doc/MANUAL.md: $(VERSIONFILE)
|
||||
perl -p -e "s/(^Version:) +[0-9.]+/\1 $(VERSION)/" -i $@
|
||||
|
||||
DOWNLOAD.md: $(VERSIONFILE)
|
||||
doc/DOWNLOAD.md: $(VERSIONFILE)
|
||||
perl -p -e "s/hledger(|-chart|-web|-vty)-[0-9.]+-/hledger\1-$(VERSION)-/g" -i $@
|
||||
|
||||
tagrelease:
|
||||
|
65
site/site.hs
65
site/site.hs
@ -1,36 +1,61 @@
|
||||
#!/usr/bin/env runhaskell
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{- hakyll script to build hledger.org -}
|
||||
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
import Data.Monoid (mappend)
|
||||
import Hakyll
|
||||
import System.Directory
|
||||
import System.Process
|
||||
import Text.Pandoc.Options
|
||||
import Text.Printf
|
||||
import Control.Applicative ((<$>))
|
||||
import Control.Monad
|
||||
import Data.List
|
||||
import Data.Monoid (mappend)
|
||||
import Hakyll
|
||||
import System.Directory
|
||||
import System.FilePath
|
||||
import System.Process
|
||||
import Text.Pandoc.Options
|
||||
import Text.Printf
|
||||
|
||||
|
||||
docDir = "../doc"
|
||||
|
||||
-- hakyll's preview doesn't detect changes in symlinked files
|
||||
-- symlinkDocs = do
|
||||
-- filter (".md" `isSuffixOf`) <$> getDirectoryContents docDir
|
||||
-- >>= mapM_ (\f -> system $ printf "[ -f %s ] || ln -s %s/%s" f docDir f)
|
||||
|
||||
copyDocsIfNewer = do
|
||||
fs <- filter (".md" `isSuffixOf`) <$> getDirectoryContents docDir
|
||||
forM_ fs $ \f -> do
|
||||
let f1 = docDir </> f
|
||||
f2 = "." </> f
|
||||
t1 <- getModificationTime f1
|
||||
t2 <- getModificationTime f2
|
||||
when (t1 > t2) $ copyFile f1 f2
|
||||
|
||||
symlinkProfsDir = ensureSiteDir >> system "ln -sf ../../profs _site/profs"
|
||||
where
|
||||
ensureSiteDir = system "mkdir -p _site"
|
||||
|
||||
main = do
|
||||
-- preview doesn't detect changes in symlinked files
|
||||
symlinkPagesFromParentDir
|
||||
-- copyPagesFromParentDir
|
||||
|
||||
copyDocsIfNewer
|
||||
symlinkProfsDir
|
||||
hakyll $ do
|
||||
|
||||
match ("images/*" .||. "js/**" .||. "robots.txt") $ do
|
||||
route idRoute
|
||||
compile copyFileCompiler
|
||||
|
||||
match "css/*" $ do
|
||||
route idRoute
|
||||
compile compressCssCompiler
|
||||
|
||||
match "templates/*" $ compile templateCompiler
|
||||
|
||||
match ("README.md") $ do
|
||||
route $ constRoute "index.html"
|
||||
compile $
|
||||
pandocCompilerWith def def
|
||||
>>= loadAndApplyTemplate "templates/frontpage.html" defaultContext
|
||||
>>= relativizeUrls
|
||||
|
||||
match (("*.md" .&&. complement "README.md") .||. "0.22/*.md" .||. "0.21/*.md" .||. "0.20/*.md" .||. "0.19/*.md" .||. "0.18/*.md") $ do
|
||||
route $ setExtension "html"
|
||||
compile $
|
||||
@ -43,17 +68,3 @@ main = do
|
||||
}
|
||||
>>= loadAndApplyTemplate "templates/default.html" defaultContext
|
||||
>>= relativizeUrls
|
||||
|
||||
symlinkPagesFromParentDir = do
|
||||
filter (".md" `isSuffixOf`) `fmap` getDirectoryContents ".."
|
||||
>>= mapM_ (\f -> system $ printf "[ -f %s ] || ln -s ../%s" f f)
|
||||
|
||||
copyPagesFromParentDir = do
|
||||
fs <- filter (".md" `isSuffixOf`) `fmap` getDirectoryContents ".."
|
||||
forM_ fs $ \f -> system $ printf "cp ../%s ." f
|
||||
|
||||
symlinkProfsDir = ensureSiteDir >> system "ln -sf ../../profs _site/profs"
|
||||
|
||||
ensureSiteDir = system "mkdir -p _site"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user