2024-01-15 22:26:51 +00:00
|
|
|
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) {
|
2024-01-20 02:34:27 +00:00
|
|
|
<div class="grid grid-cols-8 text-text py-5 rounded px-5 bg-base dark:bg-base/50">
|
2024-01-15 22:26:51 +00:00
|
|
|
if rtcc.Back != "" {
|
|
|
|
<div class="col-span-2"></div>
|
|
|
|
<div class="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="col-span-1">{ fi.Mode }</div>
|
|
|
|
<div class="col-span-1">{ fi.Size }</div>
|
|
|
|
<div class="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, fi.Path)) }>{ slashDir(fi.Name(), fi.IsDir) }</a></div>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
|