Commit 5983ebce640f9cba7f9d19cf47ab9e6ab1921263 Parent: 1529a8825a46c964ec613fdbef7fbffe80fb80ff Author: mcol <mcol@posteo.net> Date: 2021-12-01 00:26:29 +0000 Committer: mcol <mcol@posteo.net> Committed: 2021-12-01 00:26:29 +0000 Add `name` attribute to the file object
templates/base/template.html.include Modified
@@ -22,10 +22,10 @@ <a href="{{ host }}/{{ name }}/tree.html">Files</a> | <a href="{{ host }}/{{ name }}/refs.html">Refs</a> {% if readme %} - | <a href="{{ host }}/{{ name }}/file/{{ readme.href }}">{{ readme.path }}</a> + | <a href="{{ host }}/{{ name }}/file/{{ readme.href }}">{{ readme.name }}</a> {% endif %} {% if license %} - | <a href="{{ host }}/{{ name }}/file/{{ license.href }}">{{ license.path }}</a> + | <a href="{{ host }}/{{ name }}/file/{{ license.href }}">{{ license.name }}</a> {% endif %} </div> </p>
src/Types.hs Modified
@@ -22,6 +22,7 @@ import Git import Git.Libgit2 (LgRepo) import Path (Abs, Dir, Path, dirname, toFilePath) +import System.FilePath (takeFileName) import Text.Ginger.GVal (GVal, ToGVal, asBoolean, asHtml, asList, asLookup, asText, toGVal) import Text.Ginger.Html (Html, html) import Text.Ginger.Parse (SourcePos) @@ -161,6 +162,7 @@ treeAsLookup :: TreeFile -> Text -> Maybe (GVal RunRepo) treeAsLookup treefile = \case "path" -> Just . toGVal . treeFilePath $ treefile + "name" -> Just . toGVal . takeFileName . toString . treeFilePath $ treefile "href" -> Just . toGVal . treePathToHref . treeFilePath $ treefile "contents" -> Just . toGVal . treeFileContents $ treefile "mode" -> Just . toGVal . drop 4 . show . treeFileMode $ treefile
DOCUMENTATION.md Modified
@@ -174,6 +174,7 @@ | | encoding | The commit encoding. | | | parent | The SHA of the parent commit. | | file | path | The path the file relative to the repository root. | +| | name | The name of the file. | | | href | The HTML output path relative to `outputDirectory`. | | | contents | The file's contents. | | | mode | Directory, Plain, Executable, Symlink or Submodule. | @@ -183,8 +184,11 @@ | ref | name | The tag or branch name. | | | commit | The commit pointed to by the tag or branch. | -Note that some attributes point to other objects that have attributes. For -example, `branches[0].commit.parent` will work as expected. +Note: + +- Some attributes point to other objects that have attributes. For example, + `branches[0].commit.parent` will work as expected. +- "file" includes directories and symbolic links. Questions? ----------