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

Commit bfda0dff520387c269912bef87281ba88afd8546
Parent: 8156f120326ef3721746f1d92fb0d7d31d575dca
Author: mcol <mcol@posteo.net>
Date: 2022-04-06 01:52:30 +0100
Committer: mcol <mcol@posteo.net>
Committed: 2022-04-06 01:52:30 +0100

don't pack file contents into Text

src/Types.hs Modified

@@ -222,7 +222,7 @@
     , treeFileMode :: TreeEntryMode
     }
 
-data TreeFileContents = BinaryContents | FileContents Text | FolderContents [TreeFile]
+data TreeFileContents = BinaryContents | FileContents ByteString | FolderContents [TreeFile]
 
 data TreeEntryMode = ModeDirectory | ModePlain | ModeExecutable | ModeSymlink | ModeSubmodule
     deriving stock (Show)
@@ -267,7 +267,7 @@
 
     if toEnum . fromEnum $ isBinary -- This reads weird, but it goes CInt, to Int, to Bool.
         then return BinaryContents
-        else FileContents . bsToText <$> Git.catBlob oid
+        else FileContents <$> Git.catBlob oid
 
 {-
 GVal implementations for data definitions above, allowing commits to be rendered in
@@ -286,7 +286,7 @@
 instance ToGVal RunRepo TreeFileContents where
     toGVal :: TreeFileContents -> GVal RunRepo
     toGVal BinaryContents = def
-    toGVal (FileContents text) = toGVal . strip $ text
+    toGVal (FileContents bytestring) = toGVal bytestring
     toGVal (FolderContents treeFiles) =
         def
             { asHtml = html . pack . show . fmap treeFilePath $ treeFiles

src/Repositories.hs Modified

@@ -18,6 +18,7 @@
 import Control.Monad.Trans.Reader (ReaderT)
 import Data.Bool (bool)
 import qualified Data.ByteString as B
+import qualified Data.ByteString.UTF8 as B
 import Data.Either (isRight)
 import qualified Data.HashMap.Strict as HashMap
 import Data.IORef (IORef, modifyIORef, newIORef, readIORef, writeIORef)
@@ -298,7 +299,7 @@
 getEntryContents :: (Git.TreeFilePath, Git.TreeEntry LgRepo) -> ReaderT LgRepo IO TreeFileContents
 getEntryContents (_, Git.BlobEntry oid _) = getBlobContents oid
 getEntryContents (path, Git.TreeEntry oid) = FolderContents <$> getTree' path oid
-getEntryContents (_, Git.CommitEntry oid) = return . FileContents . T.pack . show . untag $ oid
+getEntryContents (_, Git.CommitEntry oid) = return . FileContents . B.fromString . show . untag $ oid
 
 getEntryModes :: Git.TreeEntry LgRepo -> ReaderT LgRepo IO TreeEntryMode
 getEntryModes (Git.BlobEntry _ kind) = return . blobkindToMode $ kind