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