From 1b1460c8d4fa358433c51fd5293fd1c79f32aeff Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Mon, 1 Jul 2024 23:32:54 +0200 Subject: feat: Add pathing to the tree tab --- templates/gititemtree.qtpl | 48 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 5 deletions(-) (limited to 'templates/gititemtree.qtpl') diff --git a/templates/gititemtree.qtpl b/templates/gititemtree.qtpl index ffc063d..86fb29c 100644 --- a/templates/gititemtree.qtpl +++ b/templates/gititemtree.qtpl @@ -1,24 +1,62 @@ +{% import "git.gabrielgio.me/cerrado/pkg/u" %} {% import "github.com/go-git/go-git/v5/plumbing/object" %} -{% code -type GitItemTreePage struct { - CurrentPath string +{% code type GitItemTreePage struct { + Path []string Tree *object.Tree } %} +{% code const ( + Folder = "tree" + Blob = "blob" + Root = "" +) +%} + +{% code func url(name, mode, ref, filename string, path []string) string { + return u.Root(). + AddPath(name). + AddPath(mode). + AddPath(ref). + AddPaths(path). + AddPath(filename). + Done() +} +%} + {% func (g *GitItemTreePage) Nav(name, ref string) %}{%= GitItemNav(name, ref, Tree) %}{% endfunc %} {% func (g *GitItemTreePage) GitContent(name, ref string) %} +
+ {% stripspace %} + {% if len(g.Path) != 0 %} + root/ + {% for i, e := range g.Path[:len(g.Path)-1] %} + {%s e %}/ + {% endfor %} + {%s u.LastOrZero(g.Path) %} + {% else %} + root/ + {% endif %} + {% endstripspace %} +
+ {% if len(g.Path) != 0 %} + +
+
+
+
+ {% endif %} {% for _, e := range g.Tree.Entries %}
{%s Ignore(e.Mode.ToOSFileMode()).String() %}
{% if e.Mode.IsFile() %} - + {% else %} - + {% endif %}
-- cgit v1.2.3