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

Commit 0b29c6cbe7bda35978f2aaa91d7d12cc52515737
Parent: d57f849993812c4cb9c5b0133a83ab8b970f4541
Author: mcol <mcol@posteo.net>
Date: 2021-10-04 11:25:44 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2021-10-04 11:25:44 +0100

Create treePathToHref helper function

src/Repositories.hs Modified

@@ -179,11 +179,16 @@
 treeAsLookup :: TreeFile -> Text -> Maybe (GVal m)
 treeAsLookup treefile = \case
     "path" -> Just . toGVal . treeFilePath $ treefile
-    "href" -> Just . toGVal . flip append ".html" . replace "/" "." .
-        decodeUtf8With lenientDecode . treeFilePath $ treefile
+    "href" -> Just . toGVal . treePathToHref . treeFilePath $ treefile
     "contents" -> Just . toGVal . treeFileContents $ treefile
     _ -> Nothing
 
+{-
+Get the name of a tree file path's HTML file.
+-}
+treePathToHref :: TreeFilePath -> Text
+treePathToHref = flip append ".html" . replace "/" "." .  decodeUtf8With lenientDecode
+
 ----------------------------------------------------------------------------------------
 
 {-
@@ -202,7 +207,7 @@
     category = const "commit"
 
 instance Target (TreeFile) where
-    identify = (++ ".html") . unpack . replace "/" "." . decodeUtf8With lenientDecode . treeFilePath
+    identify = unpack . treePathToHref . treeFilePath
     category = const "file"
 
 genTarget