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

Commit 9885c412167b8ec53221a90fc240db67fe26e323
Parent: 3d1fcf8e17a60adbb9f46350850773524ac8511c
Author: mcol <mcol@posteo.net>
Date: 2021-10-03 23:56:23 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-10-03 23:56:23 +0100

Make Target.identify return FilePath

src/Repositories.hs Modified

@@ -192,15 +192,15 @@
 genTarget can work on any target type.
 -}
 class ToGVal (Run SourcePos IO Html) a => Target a where
-    identify :: a -> String
+    identify :: a -> FilePath
     category :: a -> FilePath
 
 instance Target (Commit LgRepo) where
-    identify = unpack . renderObjOid . commitOid 
+    identify = (++ ".html") . unpack . renderObjOid . commitOid 
     category = const "commit"
 
 instance Target (TreeFile) where
-    identify = unpack . replace "/" "." . decodeUtf8 . treeFilePath
+    identify = (++ ".html") . unpack . replace "/" "." . decodeUtf8 . treeFilePath
     category = const "file"
 
 genTarget
@@ -212,7 +212,7 @@
     -> IO ()
 genTarget _ _ Nothing _ = return ()
 genTarget output scope (Just template) target = do
-    let template' = template { templatePath = identify target ++ ".html" }
+    let template' = template { templatePath = identify target }
     let scope' = scope <> HashMap.fromList [(pack . category $ target, toGVal target)]
     liftIO $ createDirectoryIfMissing True (output </> category target)
     generate (output </> category target) scope' template'