projects

showcase

A public git mirror

feat: add tree, blob and raw pages

daniel daum committed parent 87745f1 commit 3446d65

Showing 23 changed files with 813 additions and 55 deletions.

docs/decisions.md +13 −0
@@ -61,3 +61,16 @@ The site's look matches saturn instead of a generic Flexoki light/dark theme.6161It is dark only and uses saturn's tokens, palettes, fonts and components. The6262details are in `docs/theme.md`. This replaces the spec's original6363"light and dark via `prefers-color-scheme`".6465## File pages6667- A blob page for `<path>` is stored as `<repo>/blob/<path>.html`, and the68  server maps `/blob/<path>` to it. Raw bytes are stored at `<repo>/raw/<path>`.69- Files over 50 MB get no raw copy, only a note to clone. Files over 512 KB,70  or binary ones (a NUL byte in the first 8 KB, or not valid UTF-8), get no71  highlighted view. png, jpg, gif and webp are shown as images.72- The last commit per entry comes from one `git log --name-only` pass over73  history, not one `git log` per path.74- Folder pages show their own README, if they have one.75- Highlighting: chroma tokens map to saturn's `hl-*` roles in76  `internal/render/highlight.go`. README code blocks use the same mapping.
go.mod +6 −1
@@ -2,4 +2,9 @@ module daum.dev/showcase2233go 1.27.4445require github.com/yuin/goldmark v1.8.7 // indirect5require (6	github.com/alecthomas/chroma/v2 v2.27.07	github.com/yuin/goldmark v1.8.78)910require github.com/dlclark/regexp2/v2 v2.2.1 // indirect
go.sum +10 −0
@@ -1,2 +1,12 @@1github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=2github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=3github.com/alecthomas/chroma/v2 v2.27.0 h1:FodwmyOBgJULFYmDqibcp9pvfDLWdtPRh9v/r5BXYZs=4github.com/alecthomas/chroma/v2 v2.27.0/go.mod h1:NjJ3ciIgrqBNeIkWZ4e46nseoLDslxU1LmfCoL+wcY8=5github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=6github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=7github.com/dlclark/regexp2/v2 v2.2.1 h1:mf4KkFUj0gJuarK8P+LgiS+Lit7m9N1yAwEfPbee7R0=8github.com/dlclark/regexp2/v2 v2.2.1/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU=9github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=10github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=111github.com/yuin/goldmark v1.8.7 h1:XT/tNqCIbabh0ln675w4x3dv04kQBKi8NwYqi9IJaxI=212github.com/yuin/goldmark v1.8.7/go.mod h1:ip/1k0VRfGynBgxOz0yCqHrbZXhcjxyuS66Brc7iBKg=
internal/build/build_test.go +20 −2
@@ -53,6 +53,8 @@ func fixtureRepos(t *testing.T) string {5353	if err := os.CopyFS(work, os.DirFS("../../testdata/repo-a")); err != nil {5454		t.Fatal(err)5555	}56	os.WriteFile(filepath.Join(work, "data.bin"), []byte("bin\x00ary"), 0o644)57	os.WriteFile(filepath.Join(work, "big.txt"), bytes.Repeat([]byte("0123456789abcde\n"), 40<<10), 0o644)5658	run(t, work, "", "init", "-q", "-b", "main")5759	run(t, work, "", "add", "-A", ":!CHANGELOG.md")5860	run(t, work, "2026-06-01T10:00:00Z", "commit", "-q", "--no-gpg-sign", "-m", "Initial commit")@@ -150,7 +152,11 @@ func checkGolden(t *testing.T, dir, rel string) []byte {150152	if !bytes.Equal(got, want) {151153		t.Errorf("%s differs from %s; run `just golden` and review the diff", rel, golden)152154	}153	for _, bad := range []string{"leaky", "should never render", "<script>", "tailnet.example", "javascript:", "tracker.example"} {155	bad := []string{"leaky", "should never render", "<script>", "tailnet.example"}156	if !strings.Contains(rel, "/blob/") { // file pages show source text, escaped157		bad = append(bad, "javascript:", "tracker.example")158	}159	for _, bad := range bad {154160		if bytes.Contains(got, []byte(bad)) {155161			t.Errorf("%s contains %q", rel, bad)156162		}@@ -168,9 +174,21 @@ func TestSiteGolden(t *testing.T) {168174	if err := testBuilder(t).Render(context.Background(), dir); err != nil {169175		t.Fatal(err)170176	}171	for _, rel := range []string{"index.html", "repo-a/index.html", "repo-b/index.html"} {177	for _, rel := range []string{178		"index.html", "repo-a/index.html", "repo-b/index.html",179		"repo-a/tree/docs/index.html", "repo-a/tree/cmd/hello/index.html",180		"repo-a/blob/cmd/hello/main.go.html", "repo-a/blob/README.md.html",181		"repo-a/blob/docs/logo.png.html", "repo-a/blob/data.bin.html", "repo-a/blob/big.txt.html",182	} {172183		checkGolden(t, dir, rel)173184	}185	for _, f := range []string{"cmd/hello/main.go", "docs/logo.png", "big.txt", "data.bin"} {186		want, _ := os.ReadFile(filepath.Join("../../testdata/repo-a", f))187		got, err := os.ReadFile(filepath.Join(dir, "repo-a/raw", f))188		if err != nil || (want != nil && !bytes.Equal(got, want)) {189			t.Errorf("raw %s: wrong or missing (%v)", f, err)190		}191	}174192	for _, f := range []string{"static/style.css", "static/avatar.png", "static/fonts/geistpixel/GeistPixel-Square.woff2", "static/fonts/geistmono/GeistMono-Regular.woff2"} {175193		if _, err := os.Stat(filepath.Join(dir, f)); err != nil {176194			t.Error(err)
internal/build/repo.go +126 −34
@@ -1,21 +1,27 @@11package build2233import (4	"bytes"45	"cmp"56	"context"67	"fmt"78	"html/template"89	"net/url"10	"path"911	"path/filepath"1012	"slices"1113	"strings"14	"unicode/utf8"12151316	"daum.dev/showcase/internal/gitea"1417	"daum.dev/showcase/internal/gitx"1518	"daum.dev/showcase/internal/render"1619)172018const maxRender = 512 << 10 // files larger than this aren't rendered21const (22	maxRender = 512 << 10 // larger files get no highlighted view23	maxRaw    = 50 << 20  // larger files get no raw copy24)19252026// repo is one allowlisted repo with its API metadata and local mirror.2127type repo struct {@@ -26,19 +32,34 @@ type repo struct {26322733type Row struct {2834	gitx.Entry35	Base string // last path segment2936	Href string3037	Last gitx.Commit3138}323940type Crumb struct{ Name, Href string }413342type RepoPage struct {3443	Repo     *gitea.Repo3544	Tab      string3645	CloneURL string3746	Latest   *gitx.Commit47	Crumbs   []Crumb // tree pages only3848	Rows     []Row3949	Readme   template.HTML4050}415152type BlobPage struct {53	Repo          *gitea.Repo54	Tab           string55	Crumbs        []Crumb56	Path, Raw     string57	Size          int6458	Lines         []template.HTML59	Image, Binary bool60	Large         bool // too big to render; Raw is "" if too big to keep61}624263// loadRepo fetches metadata and updates the mirror. Anonymous access means a4364// private repo fails here and is skipped by the caller.4465func (b *Builder) loadRepo(ctx context.Context, name string) (*repo, error) {@@ -63,8 +84,7 @@ func (b *Builder) loadRepo(ctx context.Context, name string) (*repo, error) {6384}64856586func (b *Builder) renderRepo(ctx context.Context, rd *render.Renderer, dir string, r *repo) error {66	base := "/" + r.Name67	p := RepoPage{Repo: r.Repo, Tab: "code", CloneURL: b.Cfg.SiteURL + base + ".git"}87	p := RepoPage{Repo: r.Repo, Tab: "code", CloneURL: b.Cfg.SiteURL + "/" + r.Name + ".git"}6888	page := render.Page{Title: r.Name, D: &p}6989	if r.Head == "" {7090		return rd.Write(dir, r.Name+"/index.html", "repo", page)@@ -75,48 +95,77 @@ func (b *Builder) renderRepo(ctx context.Context, rd *render.Renderer, dir strin7595		return fmt.Errorf("latest commit: %v", err)7696	}7797	p.Latest = &log[0]7879	entries, err := r.Git.Tree(ctx, r.Head, "")98	entries, err := r.Git.Tree(ctx, r.Head)8099	if err != nil {81100		return err82101	}83	rows, err := b.rows(ctx, r, "", entries)102	last, err := r.Git.LastChanges(ctx, r.Head)84103	if err != nil {85104		return err86105	}87	p.Rows = rows88106	kids := map[string][]gitx.Entry{}89107	for _, e := range entries {90		if e.Name == "go.mod" {91			page.GoImport = goImport(b.Cfg.SiteURL, r.Name)108		if slices.ContainsFunc(strings.Split(e.Name, "/"), func(s string) bool { return s == "" || s == "." || s == ".." }) {109			continue110		}111		parent := path.Dir(e.Name)112		if parent == "." {113			parent = ""92114		}93		if p.Readme == "" && e.Type == "blob" && isReadme(e.Name) {94			if p.Readme, err = b.readme(ctx, r, e, base); err != nil {115		kids[parent] = append(kids[parent], e)116	}117118	// root119	if p.Rows, p.Readme, err = b.listing(ctx, r, "", kids[""], last); err != nil {120		return err121	}122	if slices.ContainsFunc(kids[""], func(e gitx.Entry) bool { return e.Name == "go.mod" }) {123		page.GoImport = goImport(b.Cfg.SiteURL, r.Name)124	}125	if err := rd.Write(dir, r.Name+"/index.html", "repo", page); err != nil {126		return err127	}128129	for _, e := range entries {130		switch {131		case e.Type == "tree":132			tp := RepoPage{Repo: r.Repo, Tab: "code", Crumbs: crumbs(r.Name, e.Name)}133			if tp.Rows, tp.Readme, err = b.listing(ctx, r, e.Name, kids[e.Name], last); err != nil {134				return err135			}136			rel := r.Name + "/tree/" + e.Name + "/index.html"137			if err := rd.Write(dir, rel, "dir", render.Page{Title: e.Name + " · " + r.Name, D: &tp}); err != nil {95138				return err96139			}140		case e.Type == "blob":141			if err := b.renderBlob(ctx, rd, dir, r, e); err != nil {142				return fmt.Errorf("%s: %w", e.Name, err)143			}97144		}98145	}99	return rd.Write(dir, r.Name+"/index.html", "repo", page)146	return nil100147}101148102// rows sorts entries (directories first) and finds each one's last commit.103func (b *Builder) rows(ctx context.Context, r *repo, dir string, entries []gitx.Entry) ([]Row, error) {149// listing builds the rows and README for one directory.150func (b *Builder) listing(ctx context.Context, r *repo, dir string, entries []gitx.Entry, last map[string]gitx.Commit) ([]Row, template.HTML, error) {151	var readme template.HTML104152	rows := make([]Row, 0, len(entries))105153	for _, e := range entries {106		full := strings.TrimPrefix(dir+"/"+e.Name, "/")107		row := Row{Entry: e}154		row := Row{Entry: e, Base: path.Base(e.Name), Last: last[e.Name]}108155		switch e.Type {109156		case "tree":110			row.Href = "/" + r.Name + "/tree/" + render.EscapePath(full) + "/"157			row.Href = "/" + r.Name + "/tree/" + render.EscapePath(e.Name) + "/"111158		case "blob":112			row.Href = "/" + r.Name + "/blob/" + render.EscapePath(full)113		}114		log, err := r.Git.Log(ctx, r.Head, 1, full)115		if err != nil {116			return nil, err117		}118		if len(log) > 0 {119			row.Last = log[0]159			row.Href = "/" + r.Name + "/blob/" + render.EscapePath(e.Name)160			if readme == "" && isReadme(row.Base) && e.Size <= maxRender {161				src, err := r.Git.Blob(ctx, e.Hash)162				if err != nil {163					return nil, "", err164				}165				if readme, err = readmeHTML(row.Base, src, "/"+r.Name, dir); err != nil {166					return nil, "", err167				}168			}120169		}121170		rows = append(rows, row)122171	}@@ -124,18 +173,51 @@ func (b *Builder) rows(ctx context.Context, r *repo, dir string, entries []gitx.124173		if (a.Type == "tree") != (c.Type == "tree") {125174			return cmp.Compare(c.Type, a.Type) // "tree" sorts before "blob"/"commit"126175		}127		return cmp.Compare(strings.ToLower(a.Name), strings.ToLower(c.Name))176		return cmp.Compare(strings.ToLower(a.Base), strings.ToLower(c.Base))128177	})129	return rows, nil178	return rows, readme, nil130179}131180132func (b *Builder) readme(ctx context.Context, r *repo, e gitx.Entry, base string) (template.HTML, error) {133	src, err := r.Git.Blob(ctx, e.Hash, e.Size, maxRender)134	if err != nil || src == nil {135		return "", err181func (b *Builder) renderBlob(ctx context.Context, rd *render.Renderer, dir string, r *repo, e gitx.Entry) error {182	p := BlobPage{Repo: r.Repo, Tab: "code", Crumbs: crumbs(r.Name, e.Name), Path: e.Name, Size: e.Size}183	p.Image = isImage(e.Name)184	if e.Size <= maxRaw {185		src, err := r.Git.Blob(ctx, e.Hash)186		if err != nil {187			return err188		}189		if err := render.WriteFile(filepath.Join(dir, r.Name, "raw", filepath.FromSlash(e.Name)), src); err != nil {190			return err191		}192		p.Raw = "/" + r.Name + "/raw/" + render.EscapePath(e.Name)193		p.Binary = bytes.IndexByte(src[:min(len(src), 8000)], 0) >= 0 || !utf8.Valid(src)194		if !p.Binary && e.Size <= maxRender {195			p.Lines = render.Highlight(e.Name, "", string(src))196		}136197	}137	if strings.HasSuffix(strings.ToLower(e.Name), ".md") || strings.HasSuffix(strings.ToLower(e.Name), ".markdown") {138		return render.Markdown(src, base, "")198	p.Large = e.Size > maxRender199	// blob pages are stored as <path>.html; the server maps /blob/<path> to them200	return rd.Write(dir, r.Name+"/blob/"+e.Name+".html", "blob", render.Page{Title: e.Name + " · " + r.Name, Wide: true, D: &p})201}202203// crumbs links the repo and every parent directory of p; the last part has no link.204func crumbs(repoName, p string) []Crumb {205	cs := []Crumb{{repoName, "/" + repoName + "/"}}206	parts := strings.Split(p, "/")207	for i, part := range parts {208		c := Crumb{Name: part}209		if i < len(parts)-1 {210			c.Href = "/" + repoName + "/tree/" + render.EscapePath(strings.Join(parts[:i+1], "/")) + "/"211		}212		cs = append(cs, c)213	}214	return cs215}216217func readmeHTML(name string, src []byte, base, dir string) (template.HTML, error) {218	n := strings.ToLower(name)219	if strings.HasSuffix(n, ".md") || strings.HasSuffix(n, ".markdown") {220		return render.Markdown(src, base, dir)139221	}140222	return template.HTML("<pre>" + template.HTMLEscapeString(string(src)) + "</pre>"), nil141223}@@ -145,6 +227,16 @@ func isReadme(name string) bool {145227	return n == "readme" || n == "readme.md" || n == "readme.markdown" || n == "readme.txt"146228}147229230// isImage reports whether the raw route serves name as an image (see231// docs/decisions.md). SVG is deliberately not one.232func isImage(name string) bool {233	switch strings.ToLower(path.Ext(name)) {234	case ".png", ".jpg", ".jpeg", ".gif", ".webp":235		return true236	}237	return false238}239148240func goImport(siteURL, name string) string {149241	host := strings.TrimPrefix(strings.TrimPrefix(siteURL, "https://"), "http://")150242	return host + "/" + name + " git " + siteURL + "/" + name + ".git"
internal/gitx/gitx.go +34 −12
@@ -7,6 +7,7 @@ import (77	"fmt"88	"os"99	"os/exec"10	"path"1011	"strconv"1112	"strings"1213	"time"@@ -67,13 +68,9 @@ type Entry struct {6768	Size                   int64 // -1 for trees and submodules6869}697070// Tree lists the entries of dir ("" for the root) at rev.71func (r Repo) Tree(ctx context.Context, rev, dir string) ([]Entry, error) {72	spec := rev + "^{tree}"73	if dir != "" {74		spec = rev + ":" + dir75	}76	out, err := r.run(ctx, "ls-tree", "-z", "-l", "--end-of-options", spec)71// Tree lists every entry at rev, recursively, with full paths as names.72func (r Repo) Tree(ctx context.Context, rev string) ([]Entry, error) {73	out, err := r.run(ctx, "ls-tree", "-r", "-t", "-z", "-l", "--end-of-options", rev+"^{tree}")7774	if err != nil {7875		return nil, err7976	}@@ -93,11 +90,8 @@ func (r Repo) Tree(ctx context.Context, rev, dir string) ([]Entry, error) {9390	return es, nil9491}959296// Blob returns the contents of the blob at hash, or nil if it is larger than max.97func (r Repo) Blob(ctx context.Context, hash string, size, max int64) ([]byte, error) {98	if size > max {99		return nil, nil100	}93// Blob returns the contents of the blob at hash.94func (r Repo) Blob(ctx context.Context, hash string) ([]byte, error) {10195	return r.run(ctx, "cat-file", "blob", hash)10296}10397@@ -130,6 +124,34 @@ func (r Repo) Log(ctx context.Context, rev string, n int, path string) ([]Commit130124	return cs, nil131125}132126127// LastChanges maps every path (files and directories) to the newest commit128// reachable from rev that touched it, in one pass over history.129func (r Repo) LastChanges(ctx context.Context, rev string) (map[string]Commit, error) {130	out, err := r.run(ctx, "log", "-z", "--name-only", "--format=%x1e%H%x1f%an%x1f%at%x1f%s", "--end-of-options", rev)131	if err != nil {132		return nil, err133	}134	last := map[string]Commit{}135	for _, rec := range strings.Split(string(out), "\x1e")[1:] {136		head, files, _ := strings.Cut(rec, "\x00")137		f := strings.Split(head, "\x1f")138		if len(f) != 4 {139			continue140		}141		at, _ := strconv.ParseInt(f[2], 10, 64)142		c := Commit{Hash: f[0], Author: f[1], When: time.Unix(at, 0).UTC(), Subject: f[3]}143		for _, p := range strings.Split(strings.TrimLeft(files, "\n"), "\x00") {144			for ; p != "" && p != "."; p = path.Dir(p) {145				if _, ok := last[p]; ok {146					break // set by a newer commit, and so are its parents147				}148				last[p] = c149			}150		}151	}152	return last, nil153}154133155// CommitDays counts commits reachable from rev per UTC day since since.134156func (r Repo) CommitDays(ctx context.Context, rev string, since time.Time, into map[string]int) error {135157	out, err := r.run(ctx, "log", "--format=%at", "--since="+since.UTC().Format(time.RFC3339), "--end-of-options", rev)
internal/render/highlight.goadded +89 −0
@@ -0,0 +1,89 @@1package render23import (4	"html/template"5	"strings"67	"github.com/alecthomas/chroma/v2"8	"github.com/alecthomas/chroma/v2/lexers"9)1011// Highlight tokenises src with chroma and returns one HTML string per line.12// Tokens get saturn's hl-<role> classes, so the palette CSS applies and no13// inline styles are needed. name picks the lexer; lang, if set, wins.14func Highlight(name, lang, src string) []template.HTML {15	var lx chroma.Lexer16	if lang != "" {17		lx = lexers.Get(lang)18	}19	if lx == nil {20		lx = lexers.Match(name)21	}22	if lx == nil && name != "" {23		lx = lexers.Analyse(src)24	}25	if lx == nil {26		lx = lexers.Fallback27	}28	src = strings.TrimSuffix(src, "\n")29	it, err := chroma.Coalesce(lx).Tokenise(nil, src)30	if err != nil {31		it = chroma.Literator(chroma.Token{Type: chroma.Text, Value: src})32	}33	var lines []template.HTML34	for _, line := range chroma.SplitTokensIntoLines(it.Tokens()) {35		var b strings.Builder36		for _, t := range line {37			v := template.HTMLEscapeString(strings.TrimSuffix(t.Value, "\n"))38			if r := role(t.Type); r != "" && v != "" {39				b.WriteString(`<span class="hl-` + r + `">` + v + `</span>`)40			} else {41				b.WriteString(v)42			}43		}44		lines = append(lines, template.HTML(b.String()))45	}46	return lines47}4849// role maps a chroma token type to one of saturn's syntax roles, following50// the scopes in saturn's scripts/highlight.mjs.51func role(t chroma.TokenType) string {52	switch t {53	case chroma.KeywordConstant, chroma.NameConstant, chroma.NameDecorator, chroma.NameEntity:54		return "constant"55	case chroma.KeywordType, chroma.NameClass, chroma.NameException, chroma.NameNamespace:56		return "type"57	case chroma.NameBuiltinPseudo:58		return "self"59	case chroma.NameBuiltin:60		return "builtin"61	case chroma.NameFunction, chroma.NameFunctionMagic:62		return "function"63	case chroma.NameTag, chroma.NameAttribute, chroma.NameProperty:64		return "variable"65	case chroma.LiteralStringEscape, chroma.LiteralStringRegex, chroma.LiteralStringInterpol:66		return "escape"67	case chroma.GenericInserted:68		return "added"69	case chroma.GenericDeleted:70		return "removed"71	case chroma.GenericHeading, chroma.GenericSubheading:72		return "heading"73	}74	switch {75	case t.InCategory(chroma.Comment):76		return "comment"77	case t.InCategory(chroma.Keyword):78		return "keyword"79	case t.InSubCategory(chroma.NameVariable):80		return "variable"81	case t.InSubCategory(chroma.LiteralString):82		return "string"83	case t.InSubCategory(chroma.LiteralNumber):84		return "constant"85	case t.InCategory(chroma.Operator), t.InCategory(chroma.Punctuation):86		return "punct"87	}88	return ""89}
internal/render/markdown.go +29 −0
@@ -11,6 +11,7 @@ import (1111	"github.com/yuin/goldmark/ast"1212	"github.com/yuin/goldmark/extension"1313	"github.com/yuin/goldmark/parser"14	"github.com/yuin/goldmark/renderer"1415	"github.com/yuin/goldmark/text"1516	"github.com/yuin/goldmark/util"1617)@@ -25,6 +26,7 @@ func Markdown(src []byte, base, dir string) (template.HTML, error) {2526			parser.WithAutoHeadingID(),2627			parser.WithASTTransformers(util.Prioritized(linkFixer{base, dir}, 100)),2728		),29		goldmark.WithRendererOptions(renderer.WithNodeRenderers(util.Prioritized(codeRenderer{}, 100))),2830	)2931	var buf bytes.Buffer3032	if err := md.Convert(src, &buf); err != nil {@@ -106,3 +108,30 @@ func EscapePath(p string) string {106108	}107109	return strings.Join(parts, "/")108110}111112// codeRenderer highlights fenced code blocks with the same hl-* classes as113// file pages.114type codeRenderer struct{}115116func (codeRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {117	reg.Register(ast.KindFencedCodeBlock, func(w util.BufWriter, src []byte, n ast.Node, entering bool) (ast.WalkStatus, error) {118		if !entering {119			return ast.WalkContinue, nil120		}121		cb := n.(*ast.FencedCodeBlock)122		var code strings.Builder123		for i := 0; i < cb.Lines().Len(); i++ {124			seg := cb.Lines().At(i)125			code.Write(seg.Value(src))126		}127		w.WriteString("<pre><code>")128		for i, line := range Highlight("", string(cb.Language(src)), code.String()) {129			if i > 0 {130				w.WriteString("\n")131			}132			w.WriteString(string(line))133		}134		w.WriteString("</code></pre>\n")135		return ast.WalkSkipChildren, nil136	})137}
internal/render/render.go +1 −0
@@ -43,6 +43,7 @@ func New(now time.Time) (*Renderer, error) {4343		"date": func(t time.Time) string { return t.UTC().Format("2006-01-02") },4444		"lang": langClass,4545		"size": humanSize,46		"inc":  func(i int) int { return i + 1 },4647	}4748	names, err := fs.Glob(web.FS, "templates/*.html")4849	if err != nil {
justfile +9 −2
@@ -25,9 +25,16 @@ render config="config.json":2525    rm -rf out2626    go run ./cmd/daumdev -config {{config}} -data .data -once -out out272728# Serve ./out on localhost:8000 (plain static preview until the real server exists)28# Serve ./out on localhost:8000 (stand-in until the real server exists; maps /blob/<path> to <path>.html)2929serve:30    python3 -m http.server 8000 --bind 127.0.0.1 -d out30    #!/usr/bin/env python331    import http.server, os32    class H(http.server.SimpleHTTPRequestHandler):33        def translate_path(self, path):34            p = super().translate_path(path)35            return p + ".html" if "/blob/" in path and os.path.isfile(p + ".html") else p36    os.chdir("out")37    http.server.ThreadingHTTPServer(("127.0.0.1", 8000), H).serve_forever()31383239# Render from real Gitea (needs ./config.json) and serve it3340preview config="config.json": (render config) serve
testdata/golden/repo-a/blob/README.md.htmladded +49 −0
@@ -0,0 +1,49 @@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>README.md · 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/" aria-current="page">code</a>27  <a href="/repo-a/log/">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<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <span aria-current="page">README.md</span></nav>33<div class="code-block">34  <p class="code-label">35    <span>356 B · 18 lines</span><a href="/repo-a/raw/README.md">raw</a>36  </p>37  <pre class="lines"><code><span class="line" id="L1"><a class="ln" href="#L1" aria-hidden="true">1</a><span class="hl-heading"># repo-a</span></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>A tiny fixture repo. See the [<span class="hl-variable">guide</span>](<span class="hl-variable">docs/guide.md</span>), the [<span class="hl-variable">docs folder</span>](<span class="hl-variable">docs/</span>)</span><span class="line" id="L4"><a class="ln" href="#L4" aria-hidden="true">4</a>and [<span class="hl-variable">the section below</span>](<span class="hl-variable">#usage</span>).</span><span class="line" id="L5"><a class="ln" href="#L5" aria-hidden="true">5</a></span><span class="line" id="L6"><a class="ln" href="#L6" aria-hidden="true">6</a>![<span class="hl-variable">logo</span>](<span class="hl-variable">docs/logo.png</span>)</span><span class="line" id="L7"><a class="ln" href="#L7" aria-hidden="true">7</a>![<span class="hl-variable">remote</span>](<span class="hl-variable">https://example.com/badge.svg</span>)</span><span class="line" id="L8"><a class="ln" href="#L8" aria-hidden="true">8</a>![<span class="hl-variable">tracker</span>](<span class="hl-variable">http://tracker.example/pixel.gif</span>)</span><span class="line" id="L9"><a class="ln" href="#L9" aria-hidden="true">9</a></span><span class="line" id="L10"><a class="ln" href="#L10" aria-hidden="true">10</a>&lt;script&gt;alert(&#34;raw html must not render&#34;)&lt;/script&gt;</span><span class="line" id="L11"><a class="ln" href="#L11" aria-hidden="true">11</a></span><span class="line" id="L12"><a class="ln" href="#L12" aria-hidden="true">12</a>[<span class="hl-variable">bad link</span>](<span class="hl-variable">javascript:alert(1</span>))</span><span class="line" id="L13"><a class="ln" href="#L13" aria-hidden="true">13</a></span><span class="line" id="L14"><a class="ln" href="#L14" aria-hidden="true">14</a><span class="hl-heading">## Usage</span></span><span class="line" id="L15"><a class="ln" href="#L15" aria-hidden="true">15</a></span><span class="line" id="L16"><a class="ln" href="#L16" aria-hidden="true">16</a><span class="hl-string">```sh</span></span><span class="line" id="L17"><a class="ln" href="#L17" aria-hidden="true">17</a>go run ./cmd/hello</span><span class="line" id="L18"><a class="ln" href="#L18" aria-hidden="true">18</a><span class="hl-string">```</span></span></code></pre>38</div>39</main>40<footer>41  <nav aria-label="site links">42    <p aria-hidden="true">//</p>43    <a href="https://danieldaum.net" rel="me">website</a>44    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>45    <a href="https://github.com/example" rel="me">github</a>46  </nav>47</footer>48</body>49</html>
testdata/golden/repo-a/blob/big.txt.htmladded +49 −0
@@ -0,0 +1,49 @@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>big.txt · 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/" aria-current="page">code</a>27  <a href="/repo-a/log/">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<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <span aria-current="page">big.txt</span></nav>33<div class="code-block">34  <p class="code-label">35    <span>640.0 KB</span><a href="/repo-a/raw/big.txt">raw</a>36  </p>37  <p class="file-note">this file is too large to show here. use the raw link to view it.</p>38</div>39</main>40<footer>41  <nav aria-label="site links">42    <p aria-hidden="true">//</p>43    <a href="https://danieldaum.net" rel="me">website</a>44    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>45    <a href="https://github.com/example" rel="me">github</a>46  </nav>47</footer>48</body>49</html>
testdata/golden/repo-a/blob/cmd/hello/main.go.htmladded +49 −0
@@ -0,0 +1,49 @@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>cmd/hello/main.go · 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/" aria-current="page">code</a>27  <a href="/repo-a/log/">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<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>33<div class="code-block">34  <p class="code-label">35    <span>65 B · 5 lines</span><a href="/repo-a/raw/cmd/hello/main.go">raw</a>36  </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>38</div>39</main>40<footer>41  <nav aria-label="site links">42    <p aria-hidden="true">//</p>43    <a href="https://danieldaum.net" rel="me">website</a>44    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>45    <a href="https://github.com/example" rel="me">github</a>46  </nav>47</footer>48</body>49</html>
testdata/golden/repo-a/blob/data.bin.htmladded +49 −0
@@ -0,0 +1,49 @@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>data.bin · 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/" aria-current="page">code</a>27  <a href="/repo-a/log/">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<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <span aria-current="page">data.bin</span></nav>33<div class="code-block">34  <p class="code-label">35    <span>7 B</span><a href="/repo-a/raw/data.bin">raw</a>36  </p>37  <p class="file-note">binary file, not shown. use the raw link to download it.</p>38</div>39</main>40<footer>41  <nav aria-label="site links">42    <p aria-hidden="true">//</p>43    <a href="https://danieldaum.net" rel="me">website</a>44    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>45    <a href="https://github.com/example" rel="me">github</a>46  </nav>47</footer>48</body>49</html>
testdata/golden/repo-a/blob/docs/logo.png.htmladded +49 −0
@@ -0,0 +1,49 @@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>docs/logo.png · 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/" aria-current="page">code</a>27  <a href="/repo-a/log/">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<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <a href="/repo-a/tree/docs/">docs</a> / <span aria-current="page">logo.png</span></nav>33<div class="code-block">34  <p class="code-label">35    <span>8 B</span><a href="/repo-a/raw/docs/logo.png">raw</a>36  </p>37  <div class="file-note file-image"><img src="/repo-a/raw/docs/logo.png" alt="docs/logo.png"></div>38</div>39</main>40<footer>41  <nav aria-label="site links">42    <p aria-hidden="true">//</p>43    <a href="https://danieldaum.net" rel="me">website</a>44    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>45    <a href="https://github.com/example" rel="me">github</a>46  </nav>47</footer>48</body>49</html>
testdata/golden/repo-a/index.html +12 −3
@@ -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/5dd0c68a0a26442ffe65aaf0989dd021dd4f9010/">5dd0c68a0a</a>45      <a class="commit-log-hash" href="/repo-a/commit/d9ce9f4e4bb604af4043c004cc331de1d4004b05/">d9ce9f4e4b</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>@@ -61,11 +61,21 @@6161    <td class="table-desc">Initial commit</td>6262    <td class="table-date">5 months ago</td>6363  </tr>64  <tr class="table-row">65    <td><a class="table-title" href="/repo-a/blob/big.txt">big.txt</a></td>66    <td class="table-desc">Initial commit</td>67    <td class="table-date">5 months ago</td>68  </tr>6469  <tr class="table-row">6570    <td><a class="table-title" href="/repo-a/blob/CHANGELOG.md">CHANGELOG.md</a></td>6671    <td class="table-desc">Add changelog</td>6772    <td class="table-date">2 days ago</td>6873  </tr>74  <tr class="table-row">75    <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>78  </tr>6979  <tr class="table-row">7080    <td><a class="table-title" href="/repo-a/blob/go.mod">go.mod</a></td>7181    <td class="table-desc">Initial commit</td>@@ -88,8 +98,7 @@ tracker</p>8898<!-- raw HTML omitted -->8999<p><a href="">bad link</a></p>90100<h2 id="usage">Usage</h2>91<pre><code class="language-sh">go run ./cmd/hello92</code></pre>101<pre><code>go run ./cmd/hello</code></pre>93102</article>94103</main>95104<footer>
testdata/golden/repo-a/tree/cmd/hello/index.htmladded +52 −0
@@ -0,0 +1,52 @@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>cmd/hello · 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/" aria-current="page">code</a>27  <a href="/repo-a/log/">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<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <a href="/repo-a/tree/cmd/">cmd</a> / <span aria-current="page">hello</span></nav>33<table class="table tree">34  <tbody>35  <tr class="table-row">36    <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>39  </tr>40  </tbody>41</table>42</main>43<footer>44  <nav aria-label="site links">45    <p aria-hidden="true">//</p>46    <a href="https://danieldaum.net" rel="me">website</a>47    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>48    <a href="https://github.com/example" rel="me">github</a>49  </nav>50</footer>51</body>52</html>
testdata/golden/repo-a/tree/docs/index.htmladded +57 −0
@@ -0,0 +1,57 @@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>docs · 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/" aria-current="page">code</a>27  <a href="/repo-a/log/">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<nav class="breadcrumb" aria-label="path"><a href="/repo-a/">repo-a</a> / <span aria-current="page">docs</span></nav>33<table class="table tree">34  <tbody>35  <tr class="table-row">36    <td><a class="table-title" href="/repo-a/blob/docs/guide.md">guide.md</a></td>37    <td class="table-desc">Initial commit</td>38    <td class="table-date">5 months ago</td>39  </tr>40  <tr class="table-row">41    <td><a class="table-title" href="/repo-a/blob/docs/logo.png">logo.png</a></td>42    <td class="table-desc">Initial commit</td>43    <td class="table-date">5 months ago</td>44  </tr>45  </tbody>46</table>47</main>48<footer>49  <nav aria-label="site links">50    <p aria-hidden="true">//</p>51    <a href="https://danieldaum.net" rel="me">website</a>52    <a href="https://bsky.app/profile/daum.dev" rel="me">bluesky</a>53    <a href="https://github.com/example" rel="me">github</a>54  </nav>55</footer>56</body>57</html>
web/static/style.css +70 −0
@@ -1639,3 +1639,73 @@ a.commit-log-hash:hover {16391639.empty {16401640    color: var(--text-secondary);16411641}16421643/* file viewer */1644.breadcrumb [aria-current] {1645    color: var(--text-headings);1646}16471648.breadcrumb a,1649.breadcrumb [aria-current] {1650    text-transform: none;1651}16521653.code-block .code-label {1654    display: flex;1655    justify-content: space-between;1656    gap: 1rem;1657    text-transform: uppercase;1658    letter-spacing: 0.08em;1659}16601661.code-label a {1662    color: var(--text-secondary);1663}16641665.code-label a:hover {1666    color: var(--accent);1667}16681669pre.lines {1670    padding: 1rem 0;1671}16721673.line {1674    display: block;1675    padding-right: 1.25rem;1676    min-height: 1.5em;1677}16781679.ln {1680    display: inline-block;1681    width: 5ch;1682    margin-right: 1.25rem;1683    text-align: right;1684    color: var(--text-secondary);1685    opacity: 0.6;1686    user-select: none;1687}16881689.ln:hover {1690    color: var(--accent);1691    opacity: 1;1692}16931694.line:target {1695    background: var(--background-dark);1696    box-shadow: inset 2px 0 var(--accent);1697}16981699.file-note {1700    margin: 0;1701    padding: 1.25rem;1702    color: var(--text-secondary);1703    border: 1px solid var(--borders);1704    border-radius: 0 0 6px 6px;1705}17061707.file-image img {1708    width: auto;1709    max-width: 100%;1710    margin: 0 auto;1711}
web/templates/_crumbs.htmladded +5 −0
@@ -0,0 +1,5 @@1{{define "crumbs" -}}2<nav class="breadcrumb" aria-label="path">3  {{- range $i, $c := .}}{{if $i}} / {{end}}{{if .Href}}<a href="{{.Href}}">{{.Name}}</a>{{else}}<span aria-current="page">{{.Name}}</span>{{end}}{{end -}}4</nav>5{{- end}}
web/templates/_repo.html +1 −1
@@ -43,7 +43,7 @@4343  <tbody>4444  {{- range .}}4545  <tr class="table-row">46    <td>{{if .Href}}<a class="table-title" href="{{.Href}}">{{.Name}}{{if eq .Type "tree"}}<span class="tree-dir">/</span>{{end}}</a>{{else}}<span class="table-title">{{.Name}}</span>{{end}}</td>46    <td>{{if .Href}}<a class="table-title" href="{{.Href}}">{{.Base}}{{if eq .Type "tree"}}<span class="tree-dir">/</span>{{end}}</a>{{else}}<span class="table-title">{{.Base}}</span>{{end}}</td>4747    <td class="table-desc">{{.Last.Subject}}</td>4848    <td class="table-date">{{ago .Last.When}}</td>4949  </tr>
web/templates/blob.htmladded +25 −0
@@ -0,0 +1,25 @@1{{define "content" -}}2{{template "repohead" .}}3{{template "crumbs" .Crumbs}}4<div class="code-block">5  <p class="code-label">6    <span>{{size .Size}}{{with .Lines}} · {{len .}} lines{{end}}</span>7    {{- with .Raw}}<a href="{{.}}">raw</a>{{end}}8  </p>9  {{- if .Lines}}10  <pre class="lines"><code>11    {{- range $i, $l := .Lines}}{{$n := inc $i}}<span class="line" id="L{{$n}}"><a class="ln" href="#L{{$n}}" aria-hidden="true">{{$n}}</a>{{$l}}</span>{{end -}}12  </code></pre>13  {{- else if and .Image .Raw}}14  <div class="file-note file-image"><img src="{{.Raw}}" alt="{{.Path}}"></div>15  {{- else if not .Raw}}16  <p class="file-note">this file is too large to show here. clone the repository to get it.</p>17  {{- else if .Binary}}18  <p class="file-note">binary file, not shown. use the raw link to download it.</p>19  {{- else if .Large}}20  <p class="file-note">this file is too large to show here. use the raw link to view it.</p>21  {{- else}}22  <p class="file-note">empty file.</p>23  {{- end}}24</div>25{{- end}}
web/templates/dir.htmladded +9 −0
@@ -0,0 +1,9 @@1{{define "content" -}}2{{template "repohead" .}}3{{template "crumbs" .Crumbs}}4{{template "tree" .Rows}}5{{- with .Readme}}6<h2 class="section-label">readme</h2>7<article class="readme">{{.}}</article>8{{- end}}9{{- end}}