From 6b9f5d37a5614575826c51cf6c721d8c280bd0a8 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 11 Jan 2014 21:22:53 -0800 Subject: [PATCH] docs: move most docs to doc/, hakyll cleanups fixing site preview --- Makefile | 28 +++++------ ALIASES.md => doc/ALIASES.md | 0 ANNOUNCE => doc/ANNOUNCE | 0 CONTRIBUTORS.md => doc/CONTRIBUTORS.md | 0 CSV.md => doc/CSV.md | 0 DEVELOP.md => doc/DEVELOP.md | 0 DOCS.md => doc/DOCS.md | 0 DOWNLOAD.md => doc/DOWNLOAD.md | 0 FAQ.md => doc/FAQ.md | 0 HCAR.tex => doc/HCAR.tex | 0 INSTALL.md => doc/INSTALL.md | 0 MANUAL.md => doc/MANUAL.md | 0 NEWS.md => doc/NEWS.md | 0 NOTES.org => doc/NOTES.org | 0 SCREENSHOTS.md => doc/SCREENSHOTS.md | 0 site/site.hs | 65 +++++++++++++++----------- 16 files changed, 52 insertions(+), 41 deletions(-) rename ALIASES.md => doc/ALIASES.md (100%) rename ANNOUNCE => doc/ANNOUNCE (100%) rename CONTRIBUTORS.md => doc/CONTRIBUTORS.md (100%) rename CSV.md => doc/CSV.md (100%) rename DEVELOP.md => doc/DEVELOP.md (100%) rename DOCS.md => doc/DOCS.md (100%) rename DOWNLOAD.md => doc/DOWNLOAD.md (100%) rename FAQ.md => doc/FAQ.md (100%) rename HCAR.tex => doc/HCAR.tex (100%) rename INSTALL.md => doc/INSTALL.md (100%) rename MANUAL.md => doc/MANUAL.md (100%) rename NEWS.md => doc/NEWS.md (100%) rename NOTES.org => doc/NOTES.org (100%) rename SCREENSHOTS.md => doc/SCREENSHOTS.md (100%) diff --git a/Makefile b/Makefile index 97c73ee2e..da61d7d83 100644 --- a/Makefile +++ b/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: diff --git a/ALIASES.md b/doc/ALIASES.md similarity index 100% rename from ALIASES.md rename to doc/ALIASES.md diff --git a/ANNOUNCE b/doc/ANNOUNCE similarity index 100% rename from ANNOUNCE rename to doc/ANNOUNCE diff --git a/CONTRIBUTORS.md b/doc/CONTRIBUTORS.md similarity index 100% rename from CONTRIBUTORS.md rename to doc/CONTRIBUTORS.md diff --git a/CSV.md b/doc/CSV.md similarity index 100% rename from CSV.md rename to doc/CSV.md diff --git a/DEVELOP.md b/doc/DEVELOP.md similarity index 100% rename from DEVELOP.md rename to doc/DEVELOP.md diff --git a/DOCS.md b/doc/DOCS.md similarity index 100% rename from DOCS.md rename to doc/DOCS.md diff --git a/DOWNLOAD.md b/doc/DOWNLOAD.md similarity index 100% rename from DOWNLOAD.md rename to doc/DOWNLOAD.md diff --git a/FAQ.md b/doc/FAQ.md similarity index 100% rename from FAQ.md rename to doc/FAQ.md diff --git a/HCAR.tex b/doc/HCAR.tex similarity index 100% rename from HCAR.tex rename to doc/HCAR.tex diff --git a/INSTALL.md b/doc/INSTALL.md similarity index 100% rename from INSTALL.md rename to doc/INSTALL.md diff --git a/MANUAL.md b/doc/MANUAL.md similarity index 100% rename from MANUAL.md rename to doc/MANUAL.md diff --git a/NEWS.md b/doc/NEWS.md similarity index 100% rename from NEWS.md rename to doc/NEWS.md diff --git a/NOTES.org b/doc/NOTES.org similarity index 100% rename from NOTES.org rename to doc/NOTES.org diff --git a/SCREENSHOTS.md b/doc/SCREENSHOTS.md similarity index 100% rename from SCREENSHOTS.md rename to doc/SCREENSHOTS.md diff --git a/site/site.hs b/site/site.hs index 43cc73c44..0775976a2 100755 --- a/site/site.hs +++ b/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" - -