2024-01-15 22:26:51 +00:00
|
|
|
package html
|
|
|
|
|
|
|
|
import "go.jolheiser.com/ugit/internal/git"
|
|
|
|
import "github.com/dustin/go-humanize"
|
|
|
|
import "go.jolheiser.com/ugit/assets"
|
|
|
|
|
|
|
|
type IndexContext struct {
|
|
|
|
BaseContext
|
|
|
|
Profile IndexProfile
|
2024-01-20 02:34:27 +00:00
|
|
|
Repos []*git.Repo
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type IndexProfile struct {
|
|
|
|
Username string
|
|
|
|
Email string
|
|
|
|
Links []IndexLink
|
|
|
|
}
|
|
|
|
|
|
|
|
type IndexLink struct {
|
|
|
|
Name string
|
|
|
|
URL string
|
|
|
|
}
|
|
|
|
|
|
|
|
func lastCommit(repo *git.Repo, human bool) string {
|
|
|
|
c, err := repo.LastCommit()
|
|
|
|
if err != nil {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
if human {
|
2024-01-16 04:54:43 +00:00
|
|
|
return humanize.Time(c.When)
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
2024-01-16 04:54:43 +00:00
|
|
|
return c.When.Format("01/02/2006 03:04:05 PM")
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
templ Index(ic IndexContext) {
|
|
|
|
@base(ic.BaseContext) {
|
|
|
|
<header>
|
|
|
|
<h1 class="text-text text-xl font-bold">{ ic.Title }</h1>
|
|
|
|
<h2 class="text-subtext1 text-lg">{ ic.Description }</h2>
|
|
|
|
</header>
|
|
|
|
<main class="mt-5">
|
|
|
|
<div class="grid grid-cols-1 sm:grid-cols-8">
|
|
|
|
if ic.Profile.Username != "" {
|
|
|
|
<div class="text-mauve">{ `@` + ic.Profile.Username }</div>
|
|
|
|
}
|
|
|
|
if ic.Profile.Email != "" {
|
|
|
|
<div class="text-mauve col-span-2">
|
|
|
|
<div class="w-5 h-5 stroke-mauve inline-block mr-1 align-middle">@templ.Raw(string(assets.EmailIcon))</div>
|
2024-01-15 23:17:11 +00:00
|
|
|
<a class="underline decoration-mauve/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL("mailto:" + ic.Profile.Email) }>{ ic.Profile.Email }</a>
|
2024-01-15 22:26:51 +00:00
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 sm:grid-cols-8">
|
|
|
|
for _, link := range ic.Profile.Links {
|
|
|
|
<div class="text-mauve">
|
|
|
|
<div class="w-5 h-5 stroke-mauve inline-block mr-1 align-middle">@templ.Raw(string(assets.LinkIcon))</div>
|
|
|
|
<a class="underline decoration-mauve/50 decoration-dashed hover:decoration-solid" rel="me" href={ templ.SafeURL(link.URL) }>{ link.Name }</a>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
2024-03-20 03:46:57 +00:00
|
|
|
<div class="grid sm:grid-cols-8 gap-1 mt-5">
|
2024-01-15 22:26:51 +00:00
|
|
|
for _, repo := range ic.Repos {
|
2024-03-20 03:46:57 +00:00
|
|
|
<div class="sm:col-span-1 text-blue dark:text-lavender"><a class="underline decoration-blue/50 dark:decoration-lavender/50 decoration-dashed hover:decoration-solid" href={ templ.URL("/" + repo.Name()) }>{ repo.Name() }</a></div>
|
|
|
|
<div class="sm:col-span-5 text-subtext0">{ repo.Meta.Description }</div>
|
|
|
|
<div class="sm:col-span-2 text-text/80 mb-4 sm:mb-0" title={ lastCommit(repo, false) }>{ lastCommit(repo, true) }</div>
|
2024-01-15 22:26:51 +00:00
|
|
|
}
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|