diff options
| author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-07-01 23:32:54 +0200 | 
|---|---|---|
| committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-07-01 23:32:54 +0200 | 
| commit | 1b1460c8d4fa358433c51fd5293fd1c79f32aeff (patch) | |
| tree | b87528374798941a89e07ead5b92c2842deb40b6 /templates/gititemtree.qtpl | |
| parent | 8f9853c8e26ffbad74e6414cec31104281a3860b (diff) | |
| download | cerrado-1b1460c8d4fa358433c51fd5293fd1c79f32aeff.tar.gz cerrado-1b1460c8d4fa358433c51fd5293fd1c79f32aeff.tar.bz2 cerrado-1b1460c8d4fa358433c51fd5293fd1c79f32aeff.zip | |
feat: Add pathing to the tree tabv0.0.9
Diffstat (limited to 'templates/gititemtree.qtpl')
| -rw-r--r-- | templates/gititemtree.qtpl | 48 | 
1 files changed, 43 insertions, 5 deletions
| 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) %} +<div class="pathing"> +    {% stripspace %} +    {% if len(g.Path) != 0 %} +    <a href="{%s url(name, Folder, ref, Root, []string{}) %}">root/</a> +    {% for i, e := range g.Path[:len(g.Path)-1] %} +    <a href="{%s url(name, Folder, ref, Root, g.Path[:1+i]) %}">{%s e %}/</a> +    {% endfor %} +    <a>{%s u.LastOrZero(g.Path) %}</a> +    {% else %} +    <a>root/</a> +    {% endif %} +    {% endstripspace %} +</div>  <div class="row">    <div class="col-md-12">      <div class="tree-list"> +      {% if len(g.Path) != 0 %} +          <div class="mode"><a href="{%s url(name, Folder, ref, g.Path[len(g.Path)-1], g.Path[:len(g.Path)-1]) %}">..</a></div> +          <div class="name tree"></div> +          <div class="commit"></div> +          <div class="date"></div> +          <div class="size"></div> +      {% endif %}        {% for _, e := range g.Tree.Entries %}            <div class="mode">{%s Ignore(e.Mode.ToOSFileMode()).String() %}</div>            {% if e.Mode.IsFile() %} -          <div class="name blob"><a href="/{%s name %}/blob/{%s ref%}/{%s g.CurrentPath %}/{%s e.Name %}">{%s e.Name %}</a></div> +          <div class="name blob"><a href="{%s url(name, Blob, ref, e.Name, g.Path) %}">{%s e.Name %}</a></div>            {% else %} -          <div class="name tree"><a href="./{%s g.CurrentPath %}/{%s e.Name %}">{%s e.Name %}</a></div> +          <div class="name tree"><a href="{%s url(name, Folder, ref, e.Name, g.Path) %}">{%s e.Name %}</a></div>            {% endif %}            <div class="commit"></div>            <div class="date"></div> | 
