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

Commit a7b783c236e1820dd4a645d4e737d9d216164b19
Parent: 39abe48f514e1a2fe26f91164e84cdfd9f72e4eb
Author: mcol <mcol@posteo.net>
Date: 2021-09-30 00:50:16 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-09-30 00:50:16 +0100

Pass Env to runIndex rather than Config

src/Repositories.hs Modified

@@ -40,7 +40,7 @@
 run :: Env -> IO ()
 run env = do
     foldMap (processRepo env) . repoPaths . envConfig $ env  -- TODO: make concurrent
-    runIndex (envConfig env) (envIndexTemplate env)
+    runIndex env
 
 ----------------------------------------------------------------------------------------
 -- Private -----------------------------------------------------------------------------
@@ -177,15 +177,19 @@
 This creates the main index file from the index template, using information from all
 configured respositories.
 -}
-runIndex :: Config -> Maybe Template -> IO ()
-runIndex _ Nothing = return ()
-runIndex config (Just template) = do
-    let paths = repoPaths config
-    descriptions <- mapM getDescription paths
-    let repos = zipWith ($) (Repo . takeFileName <$> paths) descriptions
-    let indexScope = packageIndex config repos
-    generate (outputDirectory config) indexScope (template { templatePath = "index.html" })
-    return ()
+runIndex :: Env -> IO ()
+runIndex env =
+    case envIndexTemplate env of
+        Nothing ->
+            return ()
+        Just template -> do
+            let config = envConfig env
+            let paths = repoPaths config
+            descriptions <- mapM getDescription paths
+            let repos = zipWith ($) (Repo . takeFileName <$> paths) descriptions
+            let indexScope = packageIndex config repos
+            generate (outputDirectory config) indexScope (template { templatePath = "index.html" })
+            return ()
 
 packageIndex
     :: Config