2010-05-17 18:33:05 +04:00
|
|
|
#!/usr/bin/env runhaskell
|
2010-07-07 20:49:33 +04:00
|
|
|
{-
|
2010-05-21 22:20:07 +04:00
|
|
|
hakyll build script for hledger.org
|
|
|
|
requires Hakyll >= 2.1, pandoc >= 1.5
|
|
|
|
-}
|
2010-05-17 18:33:05 +04:00
|
|
|
|
|
|
|
import Control.Monad (forM_)
|
|
|
|
import Control.Monad.Trans (liftIO)
|
2010-07-07 20:49:33 +04:00
|
|
|
import System.Process (system)
|
|
|
|
import Text.Hakyll (hakyllWithConfiguration, defaultHakyllConfiguration)
|
|
|
|
import Text.Hakyll.HakyllMonad (HakyllConfiguration(..))
|
|
|
|
import Text.Hakyll.Render (renderChain, static)
|
2010-05-17 18:33:05 +04:00
|
|
|
import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
|
2010-07-07 20:49:33 +04:00
|
|
|
import Text.Pandoc (ParserState(..), WriterOptions(..), defaultParserState, defaultWriterOptions)
|
2010-05-17 18:33:05 +04:00
|
|
|
import Text.Printf
|
|
|
|
|
2010-07-07 20:49:33 +04:00
|
|
|
baseurl = "http://hledger.org"
|
2010-05-21 22:20:07 +04:00
|
|
|
|
2010-07-07 20:49:33 +04:00
|
|
|
main = hakyllWithConfiguration cfg $ do
|
2010-05-17 18:33:05 +04:00
|
|
|
mapM_ renderParentDirPage
|
|
|
|
["README.rst"
|
|
|
|
,"README2.rst"
|
|
|
|
,"NEWS.rst"
|
|
|
|
,"SCREENSHOTS.rst"
|
2010-05-20 20:46:30 +04:00
|
|
|
,"MANUAL.markdown"
|
2010-05-17 18:33:05 +04:00
|
|
|
,"CONTRIBUTORS.rst"
|
|
|
|
]
|
|
|
|
mapM_ static
|
|
|
|
["style.css"
|
|
|
|
,"sshot.png"
|
|
|
|
,"watchhours.png"
|
|
|
|
,"hledger-screen-1.png"
|
|
|
|
,"hledger-charts-2.png"
|
|
|
|
]
|
2010-07-07 20:49:33 +04:00
|
|
|
where
|
|
|
|
-- Render a page from the parent directory as if it was in the hakyll
|
|
|
|
-- root dir, setting up a symbolic link when needed.
|
|
|
|
renderParentDirPage p = do
|
|
|
|
liftIO $ system $ printf "[ -f %s ] || ln -s ../%s" p p
|
|
|
|
renderChain ["site.tmpl"] $ createPage p
|
2010-05-17 18:33:05 +04:00
|
|
|
|
2010-07-07 20:49:33 +04:00
|
|
|
cfg :: HakyllConfiguration
|
|
|
|
cfg = (defaultHakyllConfiguration baseurl) {
|
2010-07-14 02:52:32 +04:00
|
|
|
-- additionalContext = Context, -- An additional context to use when rendering. This additional context is used globally.
|
|
|
|
-- siteDirectory = FilePath, -- Directory where the site is placed.
|
|
|
|
-- cacheDirectory = FilePath, -- Directory for cache files.
|
|
|
|
-- enableIndexUrl = False, -- Enable index links.
|
|
|
|
-- previewPollDelay = Int, -- Delay between polls in preview mode.
|
2010-07-07 20:49:33 +04:00
|
|
|
pandocParserState = defaultParserState {
|
|
|
|
-- stateParseRaw = False, -- ^ Parse raw HTML and LaTeX?
|
|
|
|
-- stateParserContext = NullState, -- ^ Inside list?
|
|
|
|
-- stateQuoteContext = NoQuote, -- ^ Inside quoted environment?
|
|
|
|
-- stateSanitizeHTML = False, -- ^ Sanitize HTML?
|
|
|
|
-- stateKeys = [], -- ^ List of reference keys
|
|
|
|
-- stateNotes = [], -- ^ List of notes
|
|
|
|
-- stateTabStop = 4, -- ^ Tab stop
|
|
|
|
-- stateStandalone = False, -- ^ Parse bibliographic info?
|
|
|
|
-- stateTitle = [], -- ^ Title of document
|
|
|
|
-- stateAuthors = [], -- ^ Authors of document
|
|
|
|
-- stateDate = [], -- ^ Date of document
|
|
|
|
-- stateStrict = False, -- ^ Use strict markdown syntax?
|
|
|
|
stateSmart = False -- ^ Use smart typography?
|
|
|
|
-- stateLiterateHaskell = False, -- ^ Treat input as literate haskell
|
|
|
|
-- stateColumns = 80, -- ^ Number of columns in terminal
|
|
|
|
-- stateHeaderTable = [], -- ^ Ordered list of header types used
|
|
|
|
-- stateIndentedCodeClasses = [] -- ^ Classes to use for indented code blocks
|
2010-07-14 02:52:32 +04:00
|
|
|
},
|
|
|
|
pandocWriterOptions = defaultWriterOptions {
|
2010-07-14 03:27:31 +04:00
|
|
|
-- so we can have a TOC:
|
2010-07-14 02:52:32 +04:00
|
|
|
writerStandalone = True, -- ^ Include header and footer
|
|
|
|
writerTemplate = pandocTemplate, -- ^ Template to use in standalone mode
|
|
|
|
-- writerVariables = [], -- ^ Variables to set in template
|
|
|
|
-- writerIncludeBefore = "", -- ^ Text to include before the body
|
|
|
|
-- writerIncludeAfter = "", -- ^ Text to include after the body
|
|
|
|
-- writerTabStop = 4, -- ^ Tabstop for conversion btw spaces and tabs
|
|
|
|
writerTableOfContents = True -- ^ Include table of contents
|
|
|
|
-- writerS5 = False, -- ^ We're writing S5
|
|
|
|
-- writerXeTeX = False, -- ^ Create latex suitable for use by xetex
|
|
|
|
-- writerHTMLMathMethod = PlainMath, -- ^ How to print math in HTML
|
|
|
|
-- writerIgnoreNotes = False, -- ^ Ignore footnotes (used in making toc)
|
|
|
|
-- writerIncremental = False, -- ^ Incremental S5 lists
|
|
|
|
-- writerNumberSections = False, -- ^ Number sections in LaTeX
|
|
|
|
-- writerStrictMarkdown = False, -- ^ Use strict markdown syntax
|
|
|
|
-- writerReferenceLinks = False, -- ^ Use reference links in writing markdown, rst
|
|
|
|
-- writerWrapText = True, -- ^ Wrap text to line length
|
|
|
|
-- writerLiterateHaskell = False, -- ^ Write as literate haskell
|
|
|
|
-- writerEmailObfuscation = JavascriptObfuscation, -- ^ How to obfuscate emails
|
|
|
|
-- writerIdentifierPrefix = "", -- ^ Prefix for section & note ids in HTML
|
2010-07-07 20:49:33 +04:00
|
|
|
}
|
|
|
|
}
|
2010-05-21 22:20:07 +04:00
|
|
|
|
2010-07-14 03:27:31 +04:00
|
|
|
-- the body part of pandoc 1.5.1.1's html output template
|
2010-07-14 02:52:32 +04:00
|
|
|
pandocTemplate = "\
|
|
|
|
\$if(title)$\
|
|
|
|
\<h1 class=\"title\">$title$</h1>\
|
|
|
|
\$endif$\
|
|
|
|
\$for(include-before)$\
|
|
|
|
\$include-before$\
|
|
|
|
\$endfor$\
|
|
|
|
\$if(toc)$\
|
|
|
|
\$toc$\
|
|
|
|
\$endif$\
|
|
|
|
\$body$\
|
|
|
|
\$for(include-after)$\
|
|
|
|
\$include-after$\
|
|
|
|
\$endfor$\
|
|
|
|
\"
|