aboutsummaryrefslogtreecommitdiff
path: root/templates/gititemtree.qtpl
blob: 5898506af0e41201754aec08dcb72171efd2a675 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{% import "git.gabrielgio.me/cerrado/pkg/u" %}
{% import "github.com/go-git/go-git/v5/plumbing/object" %}

{% 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.NewPathing().
        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 url(name, Blob, ref, e.Name, g.Path) %}">{%s e.Name %}</a></div>
          {% else %}
          <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>
          <div class="size">{%dl Ignore(g.Tree.Size(e.Name))%} KiB</div>
      {% endfor %}
    </div>
  </div>
</div>
{% endfunc %}