Home

ugit @22cdff623a8ec2342b9f90cc60f4d66f0e7ec712 - refs - log -
-
https://git.jolheiser.com/ugit.git
The code powering this h*ckin' site
ugit / internal / html / index.templ
- raw
 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
69
70
71
72
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
    CloneURL string
    Repos    []*git.Repo
}

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 {
		return humanize.Time(c.When)
	}
	return c.When.Format("01/02/2006 03:04:05 PM")
}

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>
						<a class="underline decoration-mauve/50 decoration-dashed hover:decoration-solid" href={ templ.SafeURL("mailto:" + ic.Profile.Email) }>{ ic.Profile.Email }</a>
					</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>
			<div class="grid grid-cols-8 gap-1 mt-5">
				for _, repo := range ic.Repos {
					<div class="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="col-span-5 text-subtext0">{ repo.Meta.Description }</div>
					<div class="col-span-2 text-text/80" title={ lastCommit(repo, false) }>{ lastCommit(repo, true) }</div>
				}
			</div>
		</main>
	}
}