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

Commit 9a98af4184e9926753fbb880e9477fa691e096e4
Parent: 649de38e8ede60b0c57b33531b9c2bacc098b7e1
Author: mcol <mcol@posteo.net>
Date: 2021-11-26 00:55:22 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2021-11-26 00:55:22 +0000

add test for index scope

test/test.sh Modified

@@ -29,6 +29,7 @@
 
 declare -a TESTS
 TESTS=(
+    "index.html"
     "gitserve/commit/0292014748caae952bbc8dd6225680d83c0a5135.html"
     "gitserve/file/test.templates.style.css.html"
 )

test/templates/title.html.include Modified

@@ -2,3 +2,5 @@
 {#- This file should not appear in the outputfolder. -#}
 
 {% block title %}{% endblock %}
+
+{% block body %}{% endblock %}

test/templates/index.html Modified

@@ -1,6 +1,5 @@
 {% extends "title.html.include" %}
 {%- block title -%}{{ host }}{%- endblock -%}
-
 {% block body %}
-index
+{{ repositories }}
 {% endblock %}

test/expected/index.html Added

@@ -0,0 +1,2 @@
+https://github.com/m-col/gitserve
+gitserve

test/expected/gitserve/file/test.templates.style.css.html Modified

@@ -1 +1,2 @@
-test/templates/style.css

\ No newline at end of file
+test/templates/style.css
+file

test/expected/gitserve/commit/0292014748caae952bbc8dd6225680d83c0a5135.html Modified

@@ -1 +1,2 @@
 0292014748caae952bbc8dd6225680d83c0a5135
+commit

src/Types.hs Modified

@@ -50,19 +50,22 @@
     toGVal :: Repo -> GVal m
     toGVal repo =
         def
-            { asHtml = html . pack . show . dirname . repositoryPath $ repo
+            { asHtml = html . pack . init . showNoQuote . dirname . repositoryPath $ repo
             , asText = pack . show . dirname . repositoryPath $ repo
             , asLookup = Just . repoAsLookup $ repo
             }
 
 repoAsLookup :: Repo -> Text -> Maybe (GVal m)
 repoAsLookup repo = \case
-    "name" -> Just . toGVal . dirname . repositoryPath $ repo
+    "name" -> Just . toGVal . init . showNoQuote . dirname . repositoryPath $ repo
     "description" -> Just . toGVal . repositoryDescription $ repo
     "head" -> Just . toGVal . repositoryHead $ repo
     "updated" -> toGVal . show . signatureWhen . commitCommitter <$> repositoryHead repo
     _ -> Nothing
 
+showNoQuote :: Show a => a -> String
+showNoQuote = tail . init . show
+
 {-
 GVal implementation for `Git.Commit r`, allowing commits to be rendered in Ginger
 templates.