Commit b6e820c57cb8101f56a2c42ef92c19f871690bd7 Parent: 3d895657661f67901fd76253a717c489c6ac5870 Author: mcol <mcol@posteo.net> Date: 2021-11-26 01:55:55 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-11-26 01:55:55 +0000 add repo scope variables to file scope test
test/templates/repo/file.html Modified
@@ -12,4 +12,18 @@ file.mode_symbolic: {{ file.mode_symbolic }} if file.is_directory then "directory" else "file": {%- if file.is_directory %} "directory"{% else %} "file"{% endif %} + + +file scope also should have data from repo scope available: +host: {{ host }} +repos: {{ repos }} +name: {{ name }} +description: {{ description }} +commits: (skipped) +tree: (skipped) +tags: (skipped) +branches: {{ branches }} + branches[0].name: {{ branches[0].name }} +readme.path: {{ readme.path }} +license.path: {{ license.path }} {% endblock %}
test/expected/index.html Modified
@@ -5,4 +5,3 @@ repositories[0]: gitserve repositories[0].name: gitserve repositories[0].description: 🐙 Templated web page generator for your git repositories -
test/expected/gitserve/file/test.templates.style.css.html Modified
@@ -7,4 +7,17 @@ file.mode: Plain file.mode_octal: 00644 file.mode_symbolic: -rw-r--r-- -if file.is_directory then "directory" else "file": "file" \ No newline at end of file +if file.is_directory then "directory" else "file": "file" + +file scope also should have data from repo scope available: +host: https://github.com/m-col/gitserve +repos: gitserve +name: gitserve +description: 🐙 Templated web page generator for your git repositories +commits: (skipped) +tree: (skipped) +tags: (skipped) +branches: master + branches[0].name: master +readme.path: README.rst +license.path: LICENSE
test/expected/gitserve/file/test.templates.html Modified
@@ -7,4 +7,17 @@ file.mode: Directory file.mode_octal: 40000 file.mode_symbolic: drwxr-xr-x -if file.is_directory then "directory" else "file": "directory" \ No newline at end of file +if file.is_directory then "directory" else "file": "directory" + +file scope also should have data from repo scope available: +host: https://github.com/m-col/gitserve +repos: gitserve +name: gitserve +description: 🐙 Templated web page generator for your git repositories +commits: (skipped) +tree: (skipped) +tags: (skipped) +branches: master + branches[0].name: master +readme.path: README.rst +license.path: LICENSE
src/Repositories.hs Modified
@@ -17,7 +17,7 @@ import qualified Data.HashMap.Strict as HashMap import Data.Maybe (catMaybes, fromJust, mapMaybe) import Data.Tagged -import Data.Text (Text, isPrefixOf, pack, stripPrefix, toLower, unpack) +import Data.Text (Text, isPrefixOf, pack, strip, stripPrefix, toLower, unpack) import Data.Text.Encoding (decodeUtf8With) import Data.Text.Encoding.Error (lenientDecode) import Git @@ -53,7 +53,7 @@ Pass the repository's folder, get its description. -} getDescription :: Path Abs Dir -> IO Text -getDescription = fmap (fromRight "") . tryIOError . fmap pack . readFile . flip FP.combine "description" . toFilePath +getDescription = fmap (fromRight "") . tryIOError . fmap (strip . pack) . readFile . flip FP.combine "description" . toFilePath {- This receives a file path to a single repository and tries to process it. If the