tools: hakyll cleanup
This commit is contained in:
parent
0276c095ca
commit
5732e42cc3
@ -1,20 +1,52 @@
|
||||
#!/usr/bin/env runhaskell
|
||||
{-o
|
||||
{-
|
||||
hakyll build script for hledger.org
|
||||
requires Hakyll >= 2.1, pandoc >= 1.5
|
||||
-}
|
||||
|
||||
import Control.Monad (forM_)
|
||||
import Control.Monad.Trans (liftIO)
|
||||
import System.Process
|
||||
import Text.Hakyll
|
||||
import Text.Hakyll.HakyllMonad
|
||||
import Text.Hakyll.Render
|
||||
import System.Process (system)
|
||||
import Text.Hakyll (hakyllWithConfiguration, defaultHakyllConfiguration)
|
||||
import Text.Hakyll.HakyllMonad (HakyllConfiguration(..))
|
||||
import Text.Hakyll.Render (renderChain, static)
|
||||
import Text.Hakyll.CreateContext (createPage, createCustomPage, createListing)
|
||||
import Text.Pandoc
|
||||
import Text.Pandoc (ParserState(..), WriterOptions(..), defaultParserState, defaultWriterOptions)
|
||||
import Text.Printf
|
||||
|
||||
pandocparsercfg = defaultParserState {
|
||||
baseurl = "http://hledger.org"
|
||||
|
||||
main = hakyllWithConfiguration cfg $ do
|
||||
mapM_ renderParentDirPage
|
||||
["README.rst"
|
||||
,"README2.rst"
|
||||
,"NEWS.rst"
|
||||
,"SCREENSHOTS.rst"
|
||||
,"MANUAL.markdown"
|
||||
,"CONTRIBUTORS.rst"
|
||||
]
|
||||
mapM_ static
|
||||
["style.css"
|
||||
,"sshot.png"
|
||||
,"watchhours.png"
|
||||
,"hledger-screen-1.png"
|
||||
,"hledger-charts-2.png"
|
||||
]
|
||||
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
|
||||
|
||||
cfg :: HakyllConfiguration
|
||||
cfg = (defaultHakyllConfiguration baseurl) {
|
||||
-- ,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 = Bool -- Enable index links.
|
||||
-- ,previewPollDelay = Int -- Delay between polls in preview mode.
|
||||
pandocParserState = defaultParserState {
|
||||
-- stateParseRaw = False, -- ^ Parse raw HTML and LaTeX?
|
||||
-- stateParserContext = NullState, -- ^ Inside list?
|
||||
-- stateQuoteContext = NoQuote, -- ^ Inside quoted environment?
|
||||
@ -33,8 +65,7 @@ pandocparsercfg = defaultParserState {
|
||||
-- stateHeaderTable = [], -- ^ Ordered list of header types used
|
||||
-- stateIndentedCodeClasses = [] -- ^ Classes to use for indented code blocks
|
||||
}
|
||||
|
||||
pandocwritercfg = defaultWriterOptions {
|
||||
,pandocWriterOptions = defaultWriterOptions {
|
||||
writerStandalone = False -- ^ Include header and footer
|
||||
-- ,writerTemplate = "" -- ^ Template to use in standalone mode
|
||||
-- ,writerVariables = [] -- ^ Variables to set in template
|
||||
@ -55,39 +86,5 @@ pandocwritercfg = defaultWriterOptions {
|
||||
-- ,writerEmailObfuscation = JavascriptObfuscation -- ^ How to obfuscate emails
|
||||
-- ,writerIdentifierPrefix = "" -- ^ Prefix for section & note ids in HTML
|
||||
}
|
||||
|
||||
hakyllcfg = (defaultHakyllConfiguration "http://hledger.org") {
|
||||
-- absoluteUrl = "http://hledger.org" -- Absolute URL of the site.
|
||||
-- ,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 = Bool -- Enable index links.
|
||||
-- ,previewPollDelay = Int -- Delay between polls in preview mode.
|
||||
pandocParserState = pandocparsercfg
|
||||
,pandocWriterOptions = pandocwritercfg
|
||||
}
|
||||
|
||||
main = hakyllWithConfiguration hakyllcfg $ do
|
||||
-- renderChain [] $ createPage "t.markdown"
|
||||
mapM_ renderParentDirPage
|
||||
["README.rst"
|
||||
,"README2.rst"
|
||||
,"NEWS.rst"
|
||||
,"SCREENSHOTS.rst"
|
||||
,"MANUAL.markdown"
|
||||
,"CONTRIBUTORS.rst"
|
||||
]
|
||||
mapM_ static
|
||||
["style.css"
|
||||
,"sshot.png"
|
||||
,"watchhours.png"
|
||||
,"hledger-screen-1.png"
|
||||
,"hledger-charts-2.png"
|
||||
]
|
||||
|
||||
-- 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
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user