🐙 Templated web page generator for your git repositories
git clone https://github.com/m-col/gitja
Files | Refs | Readme | License

Commit cb8b9f108c9ea0a48b759534fd16d52b9cac3da9
Parent: 7f05a4ae277c2cc2fb069bdad94b71e425c8b107
Author: mcol <mcol@posteo.net>
Date: 2021-09-25 20:09:08 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-09-25 20:09:08 +0100

Add commitTemplate config setting to specify a template with commit scope

src/Templates.hs Modified

@@ -24,7 +24,7 @@
 import Text.Ginger.Html (htmlSource, Html)
 import Text.Ginger.Run (easyRenderM, Run, RuntimeError)
 
-import Config (Config, templateDirectory, indexTemplate)
+import Config (Config, templateDirectory, indexTemplate, commitTemplate)
 
 data Template = Template
     { templatePath :: FilePath
@@ -76,6 +76,13 @@
     isTemplate' p = isSuffixOf "html" p || isSuffixOf "css" p || isSuffixOf "js" p
 
 {-
+This is used to filter files in the template directory to exclude those specified by the
+config settings ``indexTemplate`` or ``commitTemplate``.
+-}
+isScoped :: Config -> FilePath -> Bool
+isScoped config path = path /= (indexTemplate config) && path /= (commitTemplate config)
+
+{-
 This wraps getDirectoryContents so that we get a list of fully qualified paths of the
 directory's contents.
 -}
@@ -87,7 +94,8 @@
 valid template files.
 -}
 getFiles :: Config -> IO [FilePath]
-getFiles = filterM isTemplate <=< listTemplates . templateDirectory
+getFiles config =
+    filter (isScoped config) <$> (filterM isTemplate <=< listTemplates . templateDirectory $ config)
 
 {-
 This function gets the output HTML data and is responsible for saving it to file.

src/Config.hs Modified

@@ -6,6 +6,7 @@
     repoPaths,
     templateDirectory,
     indexTemplate,
+    commitTemplate,
     getConfig,
     outputDirectory,
     host
@@ -17,6 +18,7 @@
     { repoPaths :: [FilePath]
     , templateDirectory :: FilePath
     , indexTemplate :: FilePath
+    , commitTemplate :: FilePath
     , outputDirectory :: FilePath
     , host :: Text
     }