parent
7cd0443f9c
commit
4fb6f81d83
11
Types.hs
11
Types.hs
|
@ -56,7 +56,7 @@ data SiteState = SiteState
|
||||||
, _sourceDirs :: [FilePath] -- ^ Path to page source data
|
, _sourceDirs :: [FilePath] -- ^ Path to page source data
|
||||||
, _notSourceDirs :: [FilePath] -- ^ Subdirectories of source dirs where pages should not be sourced
|
, _notSourceDirs :: [FilePath] -- ^ Subdirectories of source dirs where pages should not be sourced
|
||||||
, _tagMetaFile :: FilePath -- ^ Name of the "tag metadata" files to find in the source directories.
|
, _tagMetaFile :: FilePath -- ^ Name of the "tag metadata" files to find in the source directories.
|
||||||
, _templateDir :: FilePath -- ^ Path to template directory
|
, _templateDirs :: [FilePath] -- ^ Paths to template directories
|
||||||
, _defaultTemplate :: FilePath -- ^ Name of the default template
|
, _defaultTemplate :: FilePath -- ^ Name of the default template
|
||||||
, _redirectTemplate :: FilePath -- ^ Name of the template for redirect pages
|
, _redirectTemplate :: FilePath -- ^ Name of the template for redirect pages
|
||||||
, _tagTemplate :: FilePath -- ^ Name of the template for category pages
|
, _tagTemplate :: FilePath -- ^ Name of the template for category pages
|
||||||
|
@ -113,10 +113,12 @@ siteOptions' = do
|
||||||
<> help "Name of files with tag metadata"
|
<> help "Name of files with tag metadata"
|
||||||
<> value "tag-metadata.yml"
|
<> value "tag-metadata.yml"
|
||||||
<> showDefault
|
<> showDefault
|
||||||
_templateDir <-
|
_templateDirs <-
|
||||||
strOption
|
many . strOption
|
||||||
$ long "template-directory"
|
$ long "template-directory"
|
||||||
<> help "Path to the directory with templates"
|
<> short 't'
|
||||||
|
<> help
|
||||||
|
"Path to the directory with templates (possibly multiple paths)"
|
||||||
<> value "templates"
|
<> value "templates"
|
||||||
<> showDefault
|
<> showDefault
|
||||||
_defaultTemplate <-
|
_defaultTemplate <-
|
||||||
|
@ -162,6 +164,7 @@ siteOptions' = do
|
||||||
++ Y.prettyPrintParseException err
|
++ Y.prettyPrintParseException err
|
||||||
in fmap (foldl objMerge Y.Null . map processKeyVal) . many . strOption
|
in fmap (foldl objMerge Y.Null . map processKeyVal) . many . strOption
|
||||||
$ long "extra-metadata"
|
$ long "extra-metadata"
|
||||||
|
<> short 'e'
|
||||||
<> help
|
<> help
|
||||||
"Extra metadata to add to pages rendering in YAML format. May be specified multiple times."
|
"Extra metadata to add to pages rendering in YAML format. May be specified multiple times."
|
||||||
_urlBase <-
|
_urlBase <-
|
||||||
|
|
19
reploy.hs
19
reploy.hs
|
@ -118,19 +118,18 @@ pageTemplates = do
|
||||||
|
|
||||||
-- | Compile a single template in a directory
|
-- | Compile a single template in a directory
|
||||||
compileTemplate ::
|
compileTemplate ::
|
||||||
FilePath
|
FilePath -> Site (Either Text.Parsec.Error.ParseError Mu.Template)
|
||||||
-> FilePath
|
compileTemplate templ = do
|
||||||
-> Site (Either Text.Parsec.Error.ParseError Mu.Template)
|
tds <- use templateDirs
|
||||||
compileTemplate templdir templ =
|
|
||||||
io $ do
|
io $ do
|
||||||
putStrLn $ "T <- " ++ (templdir </> templ)
|
putStrLn $ "T <- " ++ templ
|
||||||
Mu.automaticCompile [templdir] templ
|
Mu.automaticCompile tds templ
|
||||||
|
|
||||||
-- | Use a template set from a given directory.
|
-- | Use a template set from a given directory.
|
||||||
sourceTemplates :: FilePath -> Site ()
|
sourceTemplates :: Site ()
|
||||||
sourceTemplates templdir = do
|
sourceTemplates = do
|
||||||
ts <- pageTemplates
|
ts <- pageTemplates
|
||||||
templs' <- fmap sequence . traverse (compileTemplate templdir) $ ts
|
templs' <- fmap sequence . traverse compileTemplate $ ts
|
||||||
case templs' of
|
case templs' of
|
||||||
Left err -> error $ "template compilation: " ++ show err
|
Left err -> error $ "template compilation: " ++ show err
|
||||||
Right templs -> templates .= M.fromList (zip ts templs)
|
Right templs -> templates .= M.fromList (zip ts templs)
|
||||||
|
@ -492,7 +491,7 @@ main = do
|
||||||
use sourceDirs >>= traverse sourcePages
|
use sourceDirs >>= traverse sourcePages
|
||||||
use sourceDirs >>= traverse sourceTagMeta
|
use sourceDirs >>= traverse sourceTagMeta
|
||||||
sourceTags
|
sourceTags
|
||||||
use templateDir >>= sourceTemplates
|
sourceTemplates
|
||||||
use pages >>= traverse (uncurry installPage) . M.assocs
|
use pages >>= traverse (uncurry installPage) . M.assocs
|
||||||
renderTags
|
renderTags
|
||||||
renderLists
|
renderLists
|
||||||
|
|
Loading…
Reference in a new issue