projects

showcase

A public git mirror

feat: add commit log and diff pages

daniel daum committed parent 3446d65 commit 9dbbd6b

Showing 17 changed files with 537 additions and 16 deletions.

docs/decisions.md +8 −0
@@ -74,3 +74,11 @@ details are in `docs/theme.md`. This replaces the spec's original7474- Folder pages show their own README, if they have one.7575- Highlighting: chroma tokens map to saturn's `hl-*` roles in7676  `internal/render/highlight.go`. README code blocks use the same mapping.7778## Log and commit pages7980- Only the commits on the log page (the last `max_commits` on the default81  branch) get commit pages. Parent links show only when the parent has a page.82- Diffs are against the first parent (`--diff-merges=first-parent`), with83  rename detection. At most 5,000 diff lines are kept per commit. The rest are84  counted in the stats but not shown.
internal/build/build.go +3 −0
@@ -98,6 +98,9 @@ func (b *Builder) Render(ctx context.Context, dir string) error {9898		if err := b.renderRepo(ctx, rd, dir, rp); err != nil {9999			return fmt.Errorf("%s: %w", rp.Name, err)100100		}101		if err := b.renderLog(ctx, rd, dir, rp); err != nil {102			return fmt.Errorf("%s log: %w", rp.Name, err)103		}101104	}102105	return nil103106}
internal/build/build_test.go +19 −3
@@ -59,7 +59,9 @@ func fixtureRepos(t *testing.T) string {5959	run(t, work, "", "add", "-A", ":!CHANGELOG.md")6060	run(t, work, "2026-06-01T10:00:00Z", "commit", "-q", "--no-gpg-sign", "-m", "Initial commit")6161	os.WriteFile(filepath.Join(work, "CHANGELOG.md"), []byte("# Changes\n"), 0o644)62	run(t, work, "", "add", "CHANGELOG.md")62	os.WriteFile(filepath.Join(work, "cmd/hello/main.go"), []byte("package main\n\nimport \"fmt\"\n\nfunc main() { fmt.Println(\"hello, world\") }\n"), 0o644)63	os.WriteFile(filepath.Join(work, "data.bin"), []byte("bin\x00ary2"), 0o644)64	run(t, work, "", "add", "-A")6365	run(t, work, "2026-11-19T08:30:00Z", "commit", "-q", "--no-gpg-sign", "-m", "Add changelog", "-m", "With a body.")6466	run(t, root, "", "clone", "-q", "--bare", work, "daniel/repo-a.git")6567	run(t, root, "", "init", "-q", "--bare", "-b", "main", "daniel/repo-b.git")@@ -153,7 +155,7 @@ func checkGolden(t *testing.T, dir, rel string) []byte {153155		t.Errorf("%s differs from %s; run `just golden` and review the diff", rel, golden)154156	}155157	bad := []string{"leaky", "should never render", "<script>", "tailnet.example"}156	if !strings.Contains(rel, "/blob/") { // file pages show source text, escaped158	if !strings.Contains(rel, "/blob/") && !strings.Contains(rel, "commit") { // source text, escaped157159		bad = append(bad, "javascript:", "tracker.example")158160	}159161	for _, bad := range bad {@@ -179,10 +181,24 @@ func TestSiteGolden(t *testing.T) {179181		"repo-a/tree/docs/index.html", "repo-a/tree/cmd/hello/index.html",180182		"repo-a/blob/cmd/hello/main.go.html", "repo-a/blob/README.md.html",181183		"repo-a/blob/docs/logo.png.html", "repo-a/blob/data.bin.html", "repo-a/blob/big.txt.html",184		"repo-a/log/index.html", "repo-b/log/index.html",182185	} {183186		checkGolden(t, dir, rel)184187	}185	for _, f := range []string{"cmd/hello/main.go", "docs/logo.png", "big.txt", "data.bin"} {188	commits, _ := filepath.Glob(filepath.Join(dir, "repo-a/commit/*/index.html"))189	if len(commits) != 2 {190		t.Fatalf("want 2 commit pages, got %d", len(commits))191	}192	for _, c := range commits {193		b, _ := os.ReadFile(c)194		if bytes.Contains(b, []byte("<h2>Add changelog</h2>")) {195			os.Rename(c, filepath.Join(dir, "repo-a/commit-latest.html")) // hash-free golden name196			checkGolden(t, dir, "repo-a/commit-latest.html")197		} else if !bytes.Contains(b, []byte("diff truncated")) { // initial commit has 40k lines of big.txt198			t.Error("initial commit page: big.txt diff should be truncated")199		}200	}201	for _, f := range []string{"docs/logo.png", "go.mod"} {186202		want, _ := os.ReadFile(filepath.Join("../../testdata/repo-a", f))187203		got, err := os.ReadFile(filepath.Join(dir, "repo-a/raw", f))188204		if err != nil || (want != nil && !bytes.Equal(got, want)) {
internal/build/log.goadded +67 −0
@@ -0,0 +1,67 @@1package build23import (4	"context"56	"daum.dev/showcase/internal/gitea"7	"daum.dev/showcase/internal/gitx"8	"daum.dev/showcase/internal/render"9)1011type LogPage struct {12	Repo    *gitea.Repo13	Tab     string14	Commits []gitx.Commit15}1617type CommitPage struct {18	Repo           *gitea.Repo19	Tab            string20	C              gitx.Commit21	Parents        []Crumb // Href is "" when the parent has no page22	Files          []gitx.FileDiff23	Added, Deleted int24}2526// renderLog writes the log page and one page per listed commit. Only those27// commits get pages, so the site's size stays bounded.28func (b *Builder) renderLog(ctx context.Context, rd *render.Renderer, dir string, r *repo) error {29	p := LogPage{Repo: r.Repo, Tab: "log"}30	if r.Head != "" {31		var err error32		if p.Commits, err = r.Git.Log(ctx, r.Head, b.Cfg.MaxCommits, ""); err != nil {33			return err34		}35	}36	if err := rd.Write(dir, r.Name+"/log/index.html", "log", render.Page{Title: "commits · " + r.Name, D: &p}); err != nil {37		return err38	}3940	listed := map[string]bool{}41	for _, c := range p.Commits {42		listed[c.Hash] = true43	}44	for _, c := range p.Commits {45		cp := CommitPage{Repo: r.Repo, Tab: "log", C: c}46		for _, h := range c.Parents {47			cr := Crumb{Name: h[:min(len(h), 10)]}48			if listed[h] {49				cr.Href = "/" + r.Name + "/commit/" + h + "/"50			}51			cp.Parents = append(cp.Parents, cr)52		}53		var err error54		if cp.Files, err = r.Git.Diff(ctx, c.Hash); err != nil {55			return err56		}57		for _, f := range cp.Files {58			cp.Added += f.Added59			cp.Deleted += f.Deleted60		}61		page := render.Page{Title: c.Subject + " · " + r.Name, Wide: true, D: &cp}62		if err := rd.Write(dir, r.Name+"/commit/"+c.Hash+"/index.html", "commit", page); err != nil {63			return err64		}65	}66	return nil67}
internal/gitx/diff.goadded +103 −0
@@ -0,0 +1,103 @@1package gitx23import (4	"context"5	"strconv"6	"strings"7)89const maxDiffLines = 5000 // per commit; the rest is counted but not kept1011type FileDiff struct {12	Path, OldPath     string // OldPath is set for renames13	Status            string // "added", "deleted", "renamed" or ""14	Added, Deleted    int15	Binary, Truncated bool16	Lines             []DiffLine17}1819type DiffLine struct {20	Kind     byte // ' ', '+', '-' or '@' for a hunk header21	Old, New int  // line numbers, 0 if none22	Text     string23}2425// Diff returns the changes a commit made, against its first parent (or the26// empty tree for a root commit).27func (r Repo) Diff(ctx context.Context, hash string) ([]FileDiff, error) {28	out, err := r.run(ctx, "show", "--format=", "--patch", "-M", "--no-color", "--no-ext-diff",29		"--diff-merges=first-parent", "--end-of-options", hash)30	if err != nil {31		return nil, err32	}33	var files []FileDiff34	var f *FileDiff35	kept, oldN, newN := 0, 0, 036	inHunk := false37	for _, line := range strings.Split(string(out), "\n") {38		switch {39		case strings.HasPrefix(line, "diff --git "):40			files = append(files, FileDiff{})41			f, inHunk = &files[len(files)-1], false42			if s := line[len("diff --git "):]; len(s)%2 == 1 { // "a/P b/P"43				f.Path = s[len(s)/2+3:]44			}45		case f == nil:46		case inHunk && line != "" && strings.ContainsRune(" +-\\", rune(line[0])):47			d := DiffLine{Kind: line[0], Text: line[1:]}48			switch d.Kind {49			case '+':50				f.Added++51				d.New, newN = newN, newN+152			case '-':53				f.Deleted++54				d.Old, oldN = oldN, oldN+155			case ' ':56				d.Old, d.New, oldN, newN = oldN, newN, oldN+1, newN+157			default:58				continue // "\ No newline at end of file"59			}60			if kept < maxDiffLines {61				f.Lines, kept = append(f.Lines, d), kept+162			} else {63				f.Truncated = true64			}65		case strings.HasPrefix(line, "@@ "):66			inHunk = true67			oldN, newN = hunkStart(line, '-'), hunkStart(line, '+')68			if kept < maxDiffLines {69				f.Lines, kept = append(f.Lines, DiffLine{Kind: '@', Text: line}), kept+170			}71		case inHunk:72		case strings.HasPrefix(line, "new file"):73			f.Status = "added"74		case strings.HasPrefix(line, "deleted file"):75			f.Status = "deleted"76		case strings.HasPrefix(line, "rename from "):77			f.Status, f.OldPath = "renamed", line[len("rename from "):]78		case strings.HasPrefix(line, "rename to "):79			f.Path = line[len("rename to "):]80		case strings.HasPrefix(line, "+++ b/"):81			f.Path = line[len("+++ b/"):]82		case strings.HasPrefix(line, "--- a/") && f.Path == "":83			f.Path = line[len("--- a/"):]84		case strings.HasPrefix(line, "Binary files "):85			f.Binary = true86		}87	}88	return files, nil89}9091// hunkStart reads the start line after sign in "@@ -1,2 +3,4 @@".92func hunkStart(h string, sign byte) int {93	i := strings.IndexByte(h, sign)94	if i < 0 {95		return 096	}97	s := h[i+1:]98	if j := strings.IndexAny(s, ", "); j >= 0 {99		s = s[:j]100	}101	n, _ := strconv.Atoi(s)102	return n103}
internal/gitx/gitx.go +5 −3
@@ -98,13 +98,14 @@ func (r Repo) Blob(ctx context.Context, hash string) ([]byte, error) {9898type Commit struct {9999	Hash, Author, Subject, Body string100100	When                        time.Time101	Parents                     []string101102}102103103104func (c Commit) Short() string { return c.Hash[:min(len(c.Hash), 10)] }104105105106// Log returns up to n commits reachable from rev, optionally touching path.106107func (r Repo) Log(ctx context.Context, rev string, n int, path string) ([]Commit, error) {107	args := []string{"log", "-n", strconv.Itoa(n), "--format=%H%x1f%an%x1f%at%x1f%s%x1f%b%x1e", "--end-of-options", rev}108	args := []string{"log", "-n", strconv.Itoa(n), "--format=%H%x1f%an%x1f%at%x1f%s%x1f%b%x1f%P%x1e", "--end-of-options", rev}108109	if path != "" {109110		args = append(args, "--", ":(literal)"+path)110111	}@@ -115,11 +116,12 @@ func (r Repo) Log(ctx context.Context, rev string, n int, path string) ([]Commit115116	var cs []Commit116117	for _, rec := range strings.Split(string(out), "\x1e") {117118		f := strings.Split(strings.TrimLeft(rec, "\n"), "\x1f")118		if len(f) != 5 {119		if len(f) != 6 {119120			continue120121		}121122		at, _ := strconv.ParseInt(f[2], 10, 64)122		cs = append(cs, Commit{Hash: f[0], Author: f[1], When: time.Unix(at, 0).UTC(), Subject: f[3], Body: strings.TrimSpace(f[4])})123		cs = append(cs, Commit{Hash: f[0], Author: f[1], When: time.Unix(at, 0).UTC(), Subject: f[3],124			Body: strings.TrimSpace(f[4]), Parents: strings.Fields(f[5])})123125	}124126	return cs, nil125127}
internal/render/render.go +15 −0
@@ -44,6 +44,8 @@ func New(now time.Time) (*Renderer, error) {4444		"lang": langClass,4545		"size": humanSize,4646		"inc":  func(i int) int { return i + 1 },47		"day":  func(t time.Time) string { return t.UTC().Format("02 Jan 06") },48		"diff": diffClass,4749	}4850	names, err := fs.Glob(web.FS, "templates/*.html")4951	if err != nil {@@ -143,3 +145,16 @@ func humanSize(n int64) string {143145	}144146	return fmt.Sprintf("%.1f GB", float64(n)/(1<<30))145147}148149// diffClass maps a diff line kind to a CSS class; +/- reuse saturn's roles.150func diffClass(kind byte) string {151	switch kind {152	case '+':153		return "hl-added"154	case '-':155		return "hl-removed"156	case '@':157		return "hunk"158	}159	return ""160}
testdata/golden/repo-a/blob/cmd/hello/main.go.html +2 −2
@@ -32,9 +32,9 @@3232<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <a href="/repo-a/tree/cmd/">cmd</a> / <a href="/repo-a/tree/cmd/hello/">hello</a> / <span aria-current="page">main.go</span></nav>3333<div class="code-block">3434  <p class="code-label">35    <span>65 B · 5 lines</span><a href="/repo-a/raw/cmd/hello/main.go">raw</a>35    <span>72 B · 5 lines</span><a href="/repo-a/raw/cmd/hello/main.go">raw</a>3636  </p>37  <pre class="lines"><code><span class="line" id="L1"><a class="ln" href="#L1" aria-hidden="true">1</a><span class="hl-keyword">package</span> main</span><span class="line" id="L2"><a class="ln" href="#L2" aria-hidden="true">2</a></span><span class="line" id="L3"><a class="ln" href="#L3" aria-hidden="true">3</a><span class="hl-keyword">import</span> <span class="hl-string">&#34;fmt&#34;</span></span><span class="line" id="L4"><a class="ln" href="#L4" aria-hidden="true">4</a></span><span class="line" id="L5"><a class="ln" href="#L5" aria-hidden="true">5</a><span class="hl-keyword">func</span> <span class="hl-function">main</span><span class="hl-punct">()</span> <span class="hl-punct">{</span> fmt<span class="hl-punct">.</span><span class="hl-function">Println</span><span class="hl-punct">(</span><span class="hl-string">&#34;hello&#34;</span><span class="hl-punct">)</span> <span class="hl-punct">}</span></span></code></pre>37  <pre class="lines"><code><span class="line" id="L1"><a class="ln" href="#L1" aria-hidden="true">1</a><span class="hl-keyword">package</span> main</span><span class="line" id="L2"><a class="ln" href="#L2" aria-hidden="true">2</a></span><span class="line" id="L3"><a class="ln" href="#L3" aria-hidden="true">3</a><span class="hl-keyword">import</span> <span class="hl-string">&#34;fmt&#34;</span></span><span class="line" id="L4"><a class="ln" href="#L4" aria-hidden="true">4</a></span><span class="line" id="L5"><a class="ln" href="#L5" aria-hidden="true">5</a><span class="hl-keyword">func</span> <span class="hl-function">main</span><span class="hl-punct">()</span> <span class="hl-punct">{</span> fmt<span class="hl-punct">.</span><span class="hl-function">Println</span><span class="hl-punct">(</span><span class="hl-string">&#34;hello, world&#34;</span><span class="hl-punct">)</span> <span class="hl-punct">}</span></span></code></pre>3838</div>3939</main>4040<footer>
testdata/golden/repo-a/blob/data.bin.html +1 −1
@@ -32,7 +32,7 @@3232<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <span aria-current="page">data.bin</span></nav>3333<div class="code-block">3434  <p class="code-label">35    <span>7 B</span><a href="/repo-a/raw/data.bin">raw</a>35    <span>8 B</span><a href="/repo-a/raw/data.bin">raw</a>3636  </p>3737  <p class="file-note">binary file, not shown. use the raw link to download it.</p>3838</div>
testdata/golden/repo-a/commit-latest.htmladded +75 −0
@@ -0,0 +1,75 @@1<!doctype html>2<html lang="en" data-theme="moss">3<head>4<meta charset="utf-8">5<meta name="viewport" content="width=device-width, initial-scale=1">6<title>Add changelog · repo-a</title>7<link rel="preload" href="/static/fonts/geistpixel/GeistPixel-Square.woff2" as="font" type="font/woff2" crossorigin>8<link rel="stylesheet" href="/static/style.css">9</head>10<body class="page--code">11<a class="skip-link" href="#site-main">skip to content</a>12<header class="site-header">13  <a class="site-name" href="/">daum.dev</a>14  <nav aria-label="site">15    <a href="/">repos</a>16    <a href="https://danieldaum.net">website</a>17  </nav>18</header>19<main id="site-main">20<header class="page-header">21  <h1>repo-a</h1><p>A small Go service &amp; friends</p>22  <div class="pills"><span class="pill">go</span><span class="pill">web</span>23  </div>24</header>25<nav class="tabs" aria-label="repository">26  <a href="/repo-a/">code</a>27  <a href="/repo-a/log/" aria-current="page">commits</a>28  <a href="/repo-a/releases/">releases</a>29  <a href="/repo-a/pulls/">pulls</a>30  <a href="/repo-a/packages/">packages</a>31</nav>32<section class="commit-head">33  <h2>Add changelog</h2>34  <p class="commit-body">With a body.</p>35  <p class="meta meta-split">36    <span>Daniel</span><span class="meta-sep" aria-hidden="true">·</span>37    <time datetime="2026-11-19T08:30:00Z">19 Nov 26</time><span class="meta-sep" aria-hidden="true">·</span>38    <span>3 files · <span class="hl-added">+2</span> <span class="hl-removed">-1</span></span>39  </p>40  <p class="meta commit-ids">41    commit <code>3d795796b9b7ec4c803650d10e0e29d27dd41027</code> · parent <a href="/repo-a/commit/ec75ecddd0ca549fc7cca769182cebb680c2dc86/"><code>ec75ecddd0</code></a>42  </p>43</section>44<div class="code-block diff">45  <p class="code-label">46    <span class="diff-path">CHANGELOG.md <span class="diff-status">added</span></span>47    <span><span class="hl-added">+1</span> <span class="hl-removed">-0</span></span>48  </p>49  <pre class="lines"><code><span class="line hunk">@@ -0,0 &#43;1 @@</span><span class="line hl-added"><span class="ln"></span><span class="ln">1</span><span class="sign" aria-hidden="true">&#43;</span># Changes</span></code></pre>50</div>51<div class="code-block diff">52  <p class="code-label">53    <span class="diff-path">cmd/hello/main.go</span>54    <span><span class="hl-added">+1</span> <span class="hl-removed">-1</span></span>55  </p>56  <pre class="lines"><code><span class="line hunk">@@ -2,4 &#43;2,4 @@ package main</span><span class="line "><span class="ln">2</span><span class="ln">2</span><span class="sign" aria-hidden="true"> </span></span><span class="line "><span class="ln">3</span><span class="ln">3</span><span class="sign" aria-hidden="true"> </span>import &#34;fmt&#34;</span><span class="line "><span class="ln">4</span><span class="ln">4</span><span class="sign" aria-hidden="true"> </span></span><span class="line hl-removed"><span class="ln">5</span><span class="ln"></span><span class="sign" aria-hidden="true">-</span>func main() { fmt.Println(&#34;hello&#34;) }</span><span class="line hl-added"><span class="ln"></span><span class="ln">5</span><span class="sign" aria-hidden="true">&#43;</span>func main() { fmt.Println(&#34;hello, world&#34;) }</span></code></pre>57</div>58<div class="code-block diff">59  <p class="code-label">60    <span class="diff-path">data.bin</span>61    <span><span class="hl-added">+0</span> <span class="hl-removed">-0</span></span>62  </p>63  <p class="file-note">binary file, not shown.</p>64</div>65</main>66<footer>67  <nav aria-label="site links">68    <p aria-hidden="true">//</p>69    <a href="https://danieldaum.net" rel="me">website</a>70    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>71    <a href="https://github.com/example" rel="me">github</a>72  </nav>73</footer>74</body>75</html>
testdata/golden/repo-a/index.html +5 −5
@@ -42,7 +42,7 @@4242  </div>4343  <ol class="commit-log-list">4444    <li class="commit-log-row">45      <a class="commit-log-hash" href="/repo-a/commit/d9ce9f4e4bb604af4043c004cc331de1d4004b05/">d9ce9f4e4b</a>45      <a class="commit-log-hash" href="/repo-a/commit/3d795796b9b7ec4c803650d10e0e29d27dd41027/">3d795796b9</a>4646      <span class="commit-log-msg">Add changelog</span>4747      <time class="commit-log-date" datetime="2026-11-19T08:30:00Z">2 days ago</time>4848    </li>@@ -53,8 +53,8 @@5353  <tbody>5454  <tr class="table-row">5555    <td><a class="table-title" href="/repo-a/tree/cmd/">cmd<span class="tree-dir">/</span></a></td>56    <td class="table-desc">Initial commit</td>57    <td class="table-date">5 months ago</td>56    <td class="table-desc">Add changelog</td>57    <td class="table-date">2 days ago</td>5858  </tr>5959  <tr class="table-row">6060    <td><a class="table-title" href="/repo-a/tree/docs/">docs<span class="tree-dir">/</span></a></td>@@ -73,8 +73,8 @@7373  </tr>7474  <tr class="table-row">7575    <td><a class="table-title" href="/repo-a/blob/data.bin">data.bin</a></td>76    <td class="table-desc">Initial commit</td>77    <td class="table-date">5 months ago</td>76    <td class="table-desc">Add changelog</td>77    <td class="table-date">2 days ago</td>7878  </tr>7979  <tr class="table-row">8080    <td><a class="table-title" href="/repo-a/blob/go.mod">go.mod</a></td>
testdata/golden/repo-a/log/index.htmladded +59 −0
@@ -0,0 +1,59 @@1<!doctype html>2<html lang="en" data-theme="moss">3<head>4<meta charset="utf-8">5<meta name="viewport" content="width=device-width, initial-scale=1">6<title>commits · repo-a</title>7<link rel="preload" href="/static/fonts/geistpixel/GeistPixel-Square.woff2" as="font" type="font/woff2" crossorigin>8<link rel="stylesheet" href="/static/style.css">9</head>10<body>11<a class="skip-link" href="#site-main">skip to content</a>12<header class="site-header">13  <a class="site-name" href="/">daum.dev</a>14  <nav aria-label="site">15    <a href="/">repos</a>16    <a href="https://danieldaum.net">website</a>17  </nav>18</header>19<main id="site-main">20<header class="page-header">21  <h1>repo-a</h1><p>A small Go service &amp; friends</p>22  <div class="pills"><span class="pill">go</span><span class="pill">web</span>23  </div>24</header>25<nav class="tabs" aria-label="repository">26  <a href="/repo-a/">code</a>27  <a href="/repo-a/log/" aria-current="page">commits</a>28  <a href="/repo-a/releases/">releases</a>29  <a href="/repo-a/pulls/">pulls</a>30  <a href="/repo-a/packages/">packages</a>31</nav>32<div class="commit-log commit-log--inline">33  <div class="commit-log-head">34    <span>latest 2 commits on main</span>35  </div>36  <ol class="commit-log-list">37    <li class="commit-log-row">38      <a class="commit-log-hash" href="/repo-a/commit/3d795796b9b7ec4c803650d10e0e29d27dd41027/">3d795796b9</a>39      <a class="commit-log-msg" href="/repo-a/commit/3d795796b9b7ec4c803650d10e0e29d27dd41027/">Add changelog</a>40      <time class="commit-log-date" datetime="2026-11-19T08:30:00Z" title="Daniel">19 Nov 26</time>41    </li>42    <li class="commit-log-row">43      <a class="commit-log-hash" href="/repo-a/commit/ec75ecddd0ca549fc7cca769182cebb680c2dc86/">ec75ecddd0</a>44      <a class="commit-log-msg" href="/repo-a/commit/ec75ecddd0ca549fc7cca769182cebb680c2dc86/">Initial commit</a>45      <time class="commit-log-date" datetime="2026-06-01T10:00:00Z" title="Daniel">01 Jun 26</time>46    </li>47  </ol>48</div>49</main>50<footer>51  <nav aria-label="site links">52    <p aria-hidden="true">//</p>53    <a href="https://danieldaum.net" rel="me">website</a>54    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>55    <a href="https://github.com/example" rel="me">github</a>56  </nav>57</footer>58</body>59</html>
testdata/golden/repo-a/tree/cmd/hello/index.html +2 −2
@@ -34,8 +34,8 @@3434  <tbody>3535  <tr class="table-row">3636    <td><a class="table-title" href="/repo-a/blob/cmd/hello/main.go">main.go</a></td>37    <td class="table-desc">Initial commit</td>38    <td class="table-date">5 months ago</td>37    <td class="table-desc">Add changelog</td>38    <td class="table-date">2 days ago</td>3939  </tr>4040  </tbody>4141</table>
testdata/golden/repo-b/log/index.htmladded +41 −0
@@ -0,0 +1,41 @@1<!doctype html>2<html lang="en" data-theme="moss">3<head>4<meta charset="utf-8">5<meta name="viewport" content="width=device-width, initial-scale=1">6<title>commits · repo-b</title>7<link rel="preload" href="/static/fonts/geistpixel/GeistPixel-Square.woff2" as="font" type="font/woff2" crossorigin>8<link rel="stylesheet" href="/static/style.css">9</head>10<body>11<a class="skip-link" href="#site-main">skip to content</a>12<header class="site-header">13  <a class="site-name" href="/">daum.dev</a>14  <nav aria-label="site">15    <a href="/">repos</a>16    <a href="https://danieldaum.net">website</a>17  </nav>18</header>19<main id="site-main">20<header class="page-header">21  <h1>repo-b</h1>22</header>23<nav class="tabs" aria-label="repository">24  <a href="/repo-b/">code</a>25  <a href="/repo-b/log/" aria-current="page">commits</a>26  <a href="/repo-b/releases/">releases</a>27  <a href="/repo-b/pulls/">pulls</a>28  <a href="/repo-b/packages/">packages</a>29</nav>30<p class="empty">no commits yet.</p>31</main>32<footer>33  <nav aria-label="site links">34    <p aria-hidden="true">//</p>35    <a href="https://danieldaum.net" rel="me">website</a>36    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>37    <a href="https://github.com/example" rel="me">github</a>38  </nav>39</footer>40</body>41</html>
web/static/style.css +70 −0
@@ -1709,3 +1709,73 @@ pre.lines {17091709    max-width: 100%;17101710    margin: 0 auto;17111711}17121713/* commit log page */1714a.commit-log-msg:hover {1715    color: var(--accent);1716}17171718/* commit page */1719.commit-head {1720    margin-bottom: 2rem;1721}17221723.commit-head h2 {1724    margin-top: 0;1725}17261727.commit-body {1728    white-space: pre-wrap;1729}17301731.commit-head .meta {1732    margin: 0.25rem 0 0;1733}17341735.commit-ids code {1736    font-size: 0.8rem;1737}17381739.diff-path {1740    text-transform: none;1741    color: var(--text-headings);1742    overflow-wrap: anywhere;1743}17441745.diff-status {1746    color: var(--text-secondary);1747    text-transform: uppercase;1748}17491750.diff + .diff {1751    margin-top: 1.5rem;1752}17531754.diff .ln {1755    width: 4ch;1756    margin-right: 0.75rem;1757}17581759.diff .sign {1760    display: inline-block;1761    width: 1.5ch;1762    user-select: none;1763}17641765.diff .line.hl-added {1766    background: color-mix(in oklab, var(--syn-string) 10%, transparent);1767}17681769.diff .line.hl-removed {1770    background: color-mix(in oklab, var(--syn-variable) 10%, transparent);1771}17721773.diff .hunk {1774    padding: 0.25rem 1.25rem;1775    color: var(--text-secondary);1776    background: var(--background-dark);1777}17781779.diff .hunk:not(:first-child) {1780    margin-top: 0.5rem;1781}
web/templates/commit.htmladded +40 −0
@@ -0,0 +1,40 @@1{{define "content" -}}2{{template "repohead" .}}3<section class="commit-head">4  <h2>{{.C.Subject}}</h2>5  {{- with .C.Body}}6  <p class="commit-body">{{.}}</p>7  {{- end}}8  <p class="meta meta-split">9    <span>{{.C.Author}}</span><span class="meta-sep" aria-hidden="true">·</span>10    <time datetime="{{.C.When.Format "2006-01-02T15:04:05Z07:00"}}">{{day .C.When}}</time><span class="meta-sep" aria-hidden="true">·</span>11    <span>{{len .Files}} files · <span class="hl-added">+{{.Added}}</span> <span class="hl-removed">-{{.Deleted}}</span></span>12  </p>13  <p class="meta commit-ids">14    commit <code>{{.C.Hash}}</code>15    {{- range .Parents}} · parent {{if .Href}}<a href="{{.Href}}"><code>{{.Name}}</code></a>{{else}}<code>{{.Name}}</code>{{end}}{{end}}16  </p>17</section>18{{- range .Files}}19<div class="code-block diff">20  <p class="code-label">21    <span class="diff-path">{{with .OldPath}}{{.}} → {{end}}{{.Path}}{{with .Status}} <span class="diff-status">{{.}}</span>{{end}}</span>22    <span><span class="hl-added">+{{.Added}}</span> <span class="hl-removed">-{{.Deleted}}</span></span>23  </p>24  {{- if .Binary}}25  <p class="file-note">binary file, not shown.</p>26  {{- else if .Lines}}27  <pre class="lines"><code>28    {{- range .Lines}}<span class="line {{diff .Kind}}">29      {{- if eq .Kind 64}}{{.Text}}{{else}}<span class="ln">{{if .Old}}{{.Old}}{{end}}</span><span class="ln">{{if .New}}{{.New}}{{end}}</span><span class="sign" aria-hidden="true">{{printf "%c" .Kind}}</span>{{.Text}}{{end -}}30    </span>{{end -}}31  </code></pre>32  {{- if .Truncated}}<p class="file-note">diff truncated. clone the repository for the full change.</p>{{end}}33  {{- else if .Truncated}}34  <p class="file-note">diff truncated. clone the repository for the full change.</p>35  {{- else}}36  <p class="file-note">no content changes.</p>37  {{- end}}38</div>39{{- end}}40{{- end}}
web/templates/log.htmladded +22 −0
@@ -0,0 +1,22 @@1{{define "content" -}}2{{template "repohead" .}}3{{- $repo := .Repo.Name}}4{{- if .Commits}}5<div class="commit-log commit-log--inline">6  <div class="commit-log-head">7    <span>latest {{len .Commits}} commits on {{.Repo.DefaultBranch}}</span>8  </div>9  <ol class="commit-log-list">10    {{- range .Commits}}11    <li class="commit-log-row">12      <a class="commit-log-hash" href="/{{$repo}}/commit/{{.Hash}}/">{{.Short}}</a>13      <a class="commit-log-msg" href="/{{$repo}}/commit/{{.Hash}}/">{{.Subject}}</a>14      <time class="commit-log-date" datetime="{{.When.Format "2006-01-02T15:04:05Z07:00"}}" title="{{.Author}}">{{day .When}}</time>15    </li>16    {{- end}}17  </ol>18</div>19{{- else}}20<p class="empty">no commits yet.</p>21{{- end}}22{{- end}}