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
|
package html
import (
"fmt"
"go.jolheiser.com/ugit/internal/git"
)
type RepoTreeContext struct {
BaseContext
RepoHeaderComponentContext
RepoTreeComponentContext
ReadmeComponentContext
Description string
}
templ RepoTree(rtc RepoTreeContext) {
@base(rtc.BaseContext) {
@repoHeaderComponent(rtc.RepoHeaderComponentContext)
@repoTreeComponent(rtc.RepoTreeComponentContext)
@readmeComponent(rtc.ReadmeComponentContext)
}
}
type RepoTreeComponentContext struct {
Repo string
Ref string
Tree []git.FileInfo
Back string
}
func slashDir(name string, isDir bool) string {
if isDir {
return name + "/"
}
return name
}
templ repoTreeComponent(rtcc RepoTreeComponentContext) {
<div class="grid grid-cols-3 sm:grid-cols-8 text-text py-5 rounded px-5 gap-x-3 gap-y-1 bg-base dark:bg-base/50">
if rtcc.Back != "" {
<div class="col-span-2"></div>
<div class="sm:col-span-6"><a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s", rtcc.Repo, rtcc.Ref, rtcc.Back)) }>..</a></div>
}
for _, fi := range rtcc.Tree {
<div class="sm:col-span-1 break-keep">{ fi.Mode }</div>
<div class="sm:col-span-1 text-right">{ fi.Size }</div>
<div class="sm:col-span-6 overflow-hidden text-ellipsis"><a class="underline decoration-text/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL(fmt.Sprintf("/%s/tree/%s/%s", rtcc.Repo, rtcc.Ref, fi.Path)) }>{ slashDir(fi.Name(), fi.IsDir) }</a></div>
}
</div>
}
|