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

Commit baeb6384dbc23c16b5ac745804da967866c63831
Parent: 58e95c809b927cfa3d03d71e178de9fd429e3a93
Author: mcol <mcol@posteo.net>
Date: 2021-09-18 23:09:29 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-09-18 23:09:40 +0100

Split processRepo into child function

src/Repositories.hs Modified

@@ -7,11 +7,14 @@
 import Control.Monad.IO.Class (liftIO)
 import Data.Foldable (foldMap)
 import Data.Tagged
+import Data.Text (unpack, Text)
 import Git
-import Git.Libgit2 (lgFactory)
+import Git.Types (RefTarget)
+import Git.Libgit2 (lgFactory, LgRepo)
 import System.Directory (createDirectoryIfMissing)
 import System.FilePath ((</>), takeFileName)
-import Text.Ginger (easyRender)
+import Text.Ginger (runGingerT, makeContextHtmlM, toGVal, GVal)
+import Text.Ginger.Html (htmlSource)
 
 import Config (Config, repoPaths, outputDirectory)
 import Templates (Template, templateGinger, templatePath)
@@ -33,18 +36,24 @@
 -}
 processRepo :: [Template] -> FilePath -> FilePath -> IO ()
 processRepo templates outputDirectory path = withRepository lgFactory path $ do
-    return $ createDirectoryIfMissing True outPath
-    maybeObjID <- resolveReference "HEAD"
-    case maybeObjID of
-        Just commitID -> do
-            headCommit <- lookupCommit (Tagged commitID)
-            liftIO $ print $ commitLog headCommit
-        _ -> liftIO $ print $ "gitserve: " <> (takeFileName path) <> ": Failed to resolve HEAD."
+    liftIO $ createDirectoryIfMissing True outPath
+    ref <- lookupReference "HEAD"
+    case ref of
+        Just commitID -> liftIO $ processRepo' templates outPath commitID
+        _ -> liftIO . print $ "gitserve: " <> (takeFileName path) <> ": Failed to resolve HEAD."
   where
     outPath = outputDirectory </> (takeFileName path)
 
+processRepo' :: [Template] -> FilePath -> RefTarget LgRepo -> IO ()
+processRepo' templates outPath commitID = do
+    --headCommit <- lookupCommit (Tagged commitID)
+    liftIO $ print "hi"
+    return ()
+
+    --mconcat $ runGingerT (makeContextHtmlM (scopeLookup context) (putStr . unpack . htmlSource)) tpl
+
 -- Variables:
-title = "gitserve"
-description = ""
-host = "http://localhost"
-path = ""
+--title = "gitserve"
+--description = ""
+--host = "http://localhost"
+--path = ""