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 | 	hledger-web/static/*.css | ||||||
| 
 | 
 | ||||||
| DOCFILES:= \
 | DOCFILES:= \
 | ||||||
| 	*.md | 	doc/*.md | ||||||
| 
 | 
 | ||||||
| # files which should be updated when the version changes
 | # files which should be updated when the version changes
 | ||||||
| VERSIONSENSITIVEFILES=\
 | VERSIONSENSITIVEFILES=\
 | ||||||
| 	$(CABALFILES) \
 | 	$(CABALFILES) \
 | ||||||
| 	MANUAL.md \
 | 	doc/MANUAL.md \
 | ||||||
| #	DOWNLOAD.md \
 | #	doc/DOWNLOAD.md \
 | ||||||
| 
 | 
 | ||||||
| # file(s) which require recompilation for a build to have an up-to-date version string
 | # file(s) which require recompilation for a build to have an up-to-date version string
 | ||||||
| VERSIONSOURCEFILE=hledger/Hledger/Cli/Version.hs | VERSIONSOURCEFILE=hledger/Hledger/Cli/Version.hs | ||||||
| @ -563,13 +563,13 @@ docs: site codedocs | |||||||
| site: site/site | site: site/site | ||||||
| 	cd site; ./site build | 	cd site; ./site build | ||||||
| 
 | 
 | ||||||
| cleansite: site/site cleanoldsource | cleansite: site/site cleanolddocs | ||||||
| 	cd site; ./site clean | 	cd site; ./site clean | ||||||
| 
 | 
 | ||||||
| previewsite: site/site | previewsite: site/site | ||||||
| 	cd site; ./site preview | 	cd site; ./site preview | ||||||
| 
 | 
 | ||||||
| site/site: site/site.hs oldsource | site/site: site/site.hs olddocs | ||||||
| 	cd site; $(GHC) site.hs $(PREFERMACUSRLIBFLAGS) | 	cd site; $(GHC) site.hs $(PREFERMACUSRLIBFLAGS) | ||||||
| 
 | 
 | ||||||
| autosite: | autosite: | ||||||
| @ -580,24 +580,24 @@ viewsite: site | |||||||
| 
 | 
 | ||||||
| # ensure some old doc versions are in place:
 | # 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: | 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: | 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: | 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: | 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: | 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 | 	cd site; rm -rf 0.22 0.21 0.20 0.19 0.18 | ||||||
| 
 | 
 | ||||||
| # generate html versions of docs (and the hledger.org website)
 | # 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/(^[ ,]*hledger-lib *[>=]=) *.*/\1 $(VERSION)/" -i $@ | ||||||
| 	perl -p -e "s/(-DVERSION=\")[^\"]+/\$${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 $@ | 	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 $@ | 	perl -p -e "s/hledger(|-chart|-web|-vty)-[0-9.]+-/hledger\1-$(VERSION)-/g" -i $@ | ||||||
| 
 | 
 | ||||||
| tagrelease: | tagrelease: | ||||||
|  | |||||||
							
								
								
									
										47
									
								
								site/site.hs
									
									
									
									
									
								
							
							
						
						
									
										47
									
								
								site/site.hs
									
									
									
									
									
								
							| @ -1,5 +1,6 @@ | |||||||
| #!/usr/bin/env runhaskell | #!/usr/bin/env runhaskell | ||||||
| {-# LANGUAGE OverloadedStrings #-} | {-# LANGUAGE OverloadedStrings #-} | ||||||
|  | {- hakyll script to build hledger.org -} | ||||||
| 
 | 
 | ||||||
| import Control.Applicative ((<$>)) | import Control.Applicative ((<$>)) | ||||||
| import Control.Monad | import Control.Monad | ||||||
| @ -7,30 +8,54 @@ import           Data.List | |||||||
| import Data.Monoid         (mappend) | import Data.Monoid         (mappend) | ||||||
| import Hakyll | import Hakyll | ||||||
| import System.Directory | import System.Directory | ||||||
|  | import System.FilePath | ||||||
| import System.Process | import System.Process | ||||||
| import Text.Pandoc.Options | import Text.Pandoc.Options | ||||||
| import Text.Printf | import Text.Printf | ||||||
| 
 | 
 | ||||||
| main = do |  | ||||||
|   -- preview doesn't detect changes in symlinked files |  | ||||||
|   symlinkPagesFromParentDir |  | ||||||
|   -- copyPagesFromParentDir |  | ||||||
| 
 | 
 | ||||||
|  | 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 | ||||||
|  |   copyDocsIfNewer | ||||||
|   symlinkProfsDir |   symlinkProfsDir | ||||||
|   hakyll $ do |   hakyll $ do | ||||||
|  | 
 | ||||||
|     match ("images/*" .||. "js/**" .||. "robots.txt") $ do |     match ("images/*" .||. "js/**" .||. "robots.txt") $ do | ||||||
|         route   idRoute |         route   idRoute | ||||||
|         compile copyFileCompiler |         compile copyFileCompiler | ||||||
|  | 
 | ||||||
|     match "css/*" $ do |     match "css/*" $ do | ||||||
|         route   idRoute |         route   idRoute | ||||||
|         compile compressCssCompiler |         compile compressCssCompiler | ||||||
|  | 
 | ||||||
|     match "templates/*" $ compile templateCompiler |     match "templates/*" $ compile templateCompiler | ||||||
|  | 
 | ||||||
|     match ("README.md") $ do |     match ("README.md") $ do | ||||||
|         route $ constRoute "index.html" |         route $ constRoute "index.html" | ||||||
|         compile $ |         compile $ | ||||||
|           pandocCompilerWith def def |           pandocCompilerWith def def | ||||||
|           >>= loadAndApplyTemplate "templates/frontpage.html" defaultContext |           >>= loadAndApplyTemplate "templates/frontpage.html" defaultContext | ||||||
|           >>= relativizeUrls |           >>= relativizeUrls | ||||||
|  | 
 | ||||||
|     match (("*.md" .&&. complement "README.md") .||. "0.22/*.md" .||. "0.21/*.md" .||. "0.20/*.md" .||. "0.19/*.md" .||. "0.18/*.md") $ do |     match (("*.md" .&&. complement "README.md") .||. "0.22/*.md" .||. "0.21/*.md" .||. "0.20/*.md" .||. "0.19/*.md" .||. "0.18/*.md") $ do | ||||||
|         route   $ setExtension "html" |         route   $ setExtension "html" | ||||||
|         compile $ |         compile $ | ||||||
| @ -43,17 +68,3 @@ main = do | |||||||
|                } |                } | ||||||
|           >>= loadAndApplyTemplate "templates/default.html" defaultContext |           >>= loadAndApplyTemplate "templates/default.html" defaultContext | ||||||
|           >>= relativizeUrls |           >>= 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