2024-01-15 22:26:51 +00:00
|
|
|
package html
|
|
|
|
|
|
|
|
import (
|
2024-06-27 04:23:41 +00:00
|
|
|
"fmt"
|
|
|
|
"go.jolheiser.com/ugit/internal/git"
|
2024-01-15 22:26:51 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type RepoTreeContext struct {
|
2024-06-27 04:23:41 +00:00
|
|
|
BaseContext
|
2024-01-15 22:26:51 +00:00
|
|
|
RepoHeaderComponentContext
|
2024-06-27 04:23:41 +00:00
|
|
|
RepoBreadcrumbComponentContext
|
|
|
|
RepoTreeComponentContext
|
|
|
|
ReadmeComponentContext
|
|
|
|
Description string
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
templ RepoTree(rtc RepoTreeContext) {
|
|
|
|
@base(rtc.BaseContext) {
|
|
|
|
@repoHeaderComponent(rtc.RepoHeaderComponentContext)
|
2024-06-27 04:23:41 +00:00
|
|
|
@repoBreadcrumbComponent(rtc.RepoBreadcrumbComponentContext)
|
2024-01-15 22:26:51 +00:00
|
|
|
@repoTreeComponent(rtc.RepoTreeComponentContext)
|
|
|
|
@readmeComponent(rtc.ReadmeComponentContext)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type RepoTreeComponentContext struct {
|
2024-06-27 04:23:41 +00:00
|
|
|
Repo string
|
|
|
|
Ref string
|
|
|
|
Tree []git.FileInfo
|
|
|
|
Back string
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func slashDir(name string, isDir bool) string {
|
2024-06-27 04:23:41 +00:00
|
|
|
if isDir {
|
|
|
|
return name + "/"
|
|
|
|
}
|
|
|
|
return name
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
templ repoTreeComponent(rtcc RepoTreeComponentContext) {
|
2024-03-20 03:46:57 +00:00
|
|
|
<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">
|
2024-01-15 22:26:51 +00:00
|
|
|
if rtcc.Back != "" {
|
|
|
|
<div class="col-span-2"></div>
|
2024-03-20 03:46:57 +00:00
|
|
|
<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>
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
for _, fi := range rtcc.Tree {
|
2024-03-20 03:46:57 +00:00
|
|
|
<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>
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
}
|