chore: refactor paths 78e6bf0a
Steve · 2026-06-08 23:31 12 file(s) · +52 −52
apps/kepler/atom.go +5 −5
39 39
	feed := atomFeed{
40 40
		XMLNS:   "http://www.w3.org/2005/Atom",
41 41
		Title:   fmt.Sprintf("%s / %s — commits", siteName, repoName),
42 -
		ID:      baseURL + "/r/" + repoName,
42 +
		ID:      baseURL + "/" + repoName,
43 43
		Updated: time.Now().UTC().Format(time.RFC3339),
44 44
		Link: []atomLink{
45 -
			{Href: baseURL + "/r/" + repoName},
46 -
			{Rel: "self", Href: baseURL + "/r/" + repoName + "/atom.xml"},
45 +
			{Href: baseURL + "/" + repoName},
46 +
			{Rel: "self", Href: baseURL + "/" + repoName + "/atom.xml"},
47 47
		},
48 48
	}
49 49
	if len(commits) > 0 {
52 52
	for _, c := range commits {
53 53
		feed.Entries = append(feed.Entries, atomEntry{
54 54
			Title:   c.Subject,
55 -
			ID:      baseURL + "/r/" + repoName + "/commit/" + c.SHA,
55 +
			ID:      baseURL + "/" + repoName + "/commit/" + c.SHA,
56 56
			Updated: c.When.UTC().Format(time.RFC3339),
57 -
			Link:    atomLink{Href: baseURL + "/r/" + repoName + "/commit/" + c.SHA},
57 +
			Link:    atomLink{Href: baseURL + "/" + repoName + "/commit/" + c.SHA},
58 58
			Author:  atomAuthor{Name: c.Author, Email: c.Email},
59 59
			Summary: c.Body,
60 60
		})
apps/kepler/handlers.go +3 −3
54 54
	if c, err := resolveRef(repo, summary.DefaultRef); err == nil {
55 55
		if tree, err := c.Tree(); err == nil {
56 56
			if src, ok := findReadme(tree); ok {
57 -
				rawBase := "/r/" + summary.Name + "/raw/" + summary.DefaultRef + "/"
57 +
				rawBase := "/" + summary.Name + "/raw/" + summary.DefaultRef + "/"
58 58
				if html, err := renderMarkdown(src, rawBase); err == nil {
59 59
					data.ReadmeHTML = html
60 60
					data.HasReadme = true
266 266
}
267 267
268 268
func makeBreadcrumbs(repoName, ref, subPath string) []Breadcrumb {
269 -
	out := []Breadcrumb{{Name: repoName, Href: "/r/" + repoName + "/tree/" + ref}}
269 +
	out := []Breadcrumb{{Name: repoName, Href: "/" + repoName + "/tree/" + ref}}
270 270
	if subPath == "" {
271 271
		return out
272 272
	}
278 278
		} else {
279 279
			acc = acc + "/" + p
280 280
		}
281 -
		out = append(out, Breadcrumb{Name: p, Href: "/r/" + repoName + "/tree/" + ref + "/" + acc})
281 +
		out = append(out, Breadcrumb{Name: p, Href: "/" + repoName + "/tree/" + ref + "/" + acc})
282 282
	}
283 283
	return out
284 284
}
apps/kepler/kepler +0 −0

Binary file — no preview.

apps/kepler/routes.go +10 −10
30 30
	})
31 31
32 32
	mux.HandleFunc("GET /{$}", a.indexHandler)
33 -
	mux.HandleFunc("GET /r/{repo}", a.repoHandler)
34 -
	mux.HandleFunc("GET /r/{repo}/refs", a.refsHandler)
35 -
	mux.HandleFunc("GET /r/{repo}/atom.xml", a.atomHandler)
36 -
	mux.HandleFunc("GET /r/{repo}/log/{ref}", a.logHandler)
37 -
	mux.HandleFunc("GET /r/{repo}/commit/{sha}", a.commitHandler)
38 -
	mux.HandleFunc("GET /r/{repo}/tree/{ref}", a.treeHandler)
39 -
	mux.HandleFunc("GET /r/{repo}/tree/{ref}/{path...}", a.treeHandler)
40 -
	mux.HandleFunc("GET /r/{repo}/blob/{ref}/{path...}", a.blobHandler)
41 -
	mux.HandleFunc("GET /r/{repo}/raw/{ref}/{path...}", a.rawHandler)
42 -
	mux.HandleFunc("GET /r/{repo}/archive/{name}", a.archiveHandler)
33 +
	mux.HandleFunc("GET /{repo}", a.repoHandler)
34 +
	mux.HandleFunc("GET /{repo}/refs", a.refsHandler)
35 +
	mux.HandleFunc("GET /{repo}/atom.xml", a.atomHandler)
36 +
	mux.HandleFunc("GET /{repo}/log/{ref}", a.logHandler)
37 +
	mux.HandleFunc("GET /{repo}/commit/{sha}", a.commitHandler)
38 +
	mux.HandleFunc("GET /{repo}/tree/{ref}", a.treeHandler)
39 +
	mux.HandleFunc("GET /{repo}/tree/{ref}/{path...}", a.treeHandler)
40 +
	mux.HandleFunc("GET /{repo}/blob/{ref}/{path...}", a.blobHandler)
41 +
	mux.HandleFunc("GET /{repo}/raw/{ref}/{path...}", a.rawHandler)
42 +
	mux.HandleFunc("GET /{repo}/archive/{name}", a.archiveHandler)
43 43
44 44
	return mux
45 45
}
apps/kepler/templates/base.html +1 −1
14 14
        <nav class="repo-nav">
15 15
            <span class="repo-name">
16 16
                <a href="/">{{.SiteName}}</a>
17 -
                {{if .RepoName}}<span class="sep">/</span><a href="/r/{{.RepoName}}">{{.RepoName}}</a>{{end}}
17 +
                {{if .RepoName}}<span class="sep">/</span><a href="/{{.RepoName}}">{{.RepoName}}</a>{{end}}
18 18
            </span>
19 19
            {{block "tabs" .}}{{end}}
20 20
        </nav>
apps/kepler/templates/blob.html +5 −5
1 1
{{define "blob.html"}}{{template "base.html" .}}{{end}}
2 2
{{define "title"}}{{.Path}} — {{.Repo.Name}} — {{.SiteName}}{{end}}
3 3
{{define "tabs"}}
4 -
<a href="/r/{{.Repo.Name}}" class="tab">home</a>
5 -
<a href="/r/{{.Repo.Name}}/log/{{.Ref}}" class="tab">log</a>
6 -
<a href="/r/{{.Repo.Name}}/refs" class="tab">refs</a>
4 +
<a href="/{{.Repo.Name}}" class="tab">home</a>
5 +
<a href="/{{.Repo.Name}}/log/{{.Ref}}" class="tab">log</a>
6 +
<a href="/{{.Repo.Name}}/refs" class="tab">refs</a>
7 7
{{end}}
8 8
{{define "content"}}
9 9
<nav class="breadcrumbs">
14 14
    <header class="file-header">
15 15
        <span class="file-name">{{.Path}}</span>
16 16
        <span class="file-meta">{{humanSize .Size}}</span>
17 -
        <a href="/r/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">raw</a>
17 +
        <a href="/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">raw</a>
18 18
    </header>
19 19
    {{if .Binary}}
20 -
    <p class="empty">Binary file — <a href="/r/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">download raw</a>.</p>
20 +
    <p class="empty">Binary file — <a href="/{{.Repo.Name}}/raw/{{.Ref}}/{{.Path}}">download raw</a>.</p>
21 21
    {{else}}
22 22
    <div class="blob-view">{{.HighlightedHTML}}</div>
23 23
    {{end}}
apps/kepler/templates/commit.html +3 −3
1 1
{{define "commit.html"}}{{template "base.html" .}}{{end}}
2 2
{{define "title"}}{{.Commit.ShortSHA}} — {{.Repo.Name}} — {{.SiteName}}{{end}}
3 3
{{define "tabs"}}
4 -
<a href="/r/{{.Repo.Name}}" class="tab">home</a>
5 -
<a href="/r/{{.Repo.Name}}/log/{{.DefaultRef}}" class="tab active">log</a>
6 -
<a href="/r/{{.Repo.Name}}/refs" class="tab">refs</a>
4 +
<a href="/{{.Repo.Name}}" class="tab">home</a>
5 +
<a href="/{{.Repo.Name}}/log/{{.DefaultRef}}" class="tab active">log</a>
6 +
<a href="/{{.Repo.Name}}/refs" class="tab">refs</a>
7 7
{{end}}
8 8
{{define "content"}}
9 9
<article class="commit-info">
apps/kepler/templates/index.html +1 −1
6 6
    <tbody>
7 7
        {{range .Repos}}
8 8
        <tr>
9 -
            <td><a href="/r/{{.Name}}">{{.Name}}</a></td>
9 +
            <td><a href="/{{.Name}}">{{.Name}}</a></td>
10 10
        </tr>
11 11
        {{end}}
12 12
    </tbody>
apps/kepler/templates/log.html +6 −6
1 1
{{define "log.html"}}{{template "base.html" .}}{{end}}
2 2
{{define "title"}}log — {{.Repo.Name}} — {{.SiteName}}{{end}}
3 3
{{define "tabs"}}
4 -
<a href="/r/{{.Repo.Name}}" class="tab">home</a>
5 -
<a href="/r/{{.Repo.Name}}/log/{{.Ref}}" class="tab active">log</a>
6 -
<a href="/r/{{.Repo.Name}}/refs" class="tab">refs</a>
4 +
<a href="/{{.Repo.Name}}" class="tab">home</a>
5 +
<a href="/{{.Repo.Name}}/log/{{.Ref}}" class="tab active">log</a>
6 +
<a href="/{{.Repo.Name}}/refs" class="tab">refs</a>
7 7
{{end}}
8 8
{{define "content"}}
9 9
<table class="log-list">
18 18
    <tbody>
19 19
        {{range .Commits}}
20 20
        <tr>
21 -
            <td class="hash"><a href="/r/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></td>
21 +
            <td class="hash"><a href="/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></td>
22 22
            <td class="subject">{{.Subject}}</td>
23 23
            <td class="author desktop">{{.Author}}</td>
24 24
            <td class="date">{{timeAgo .When}}</td>
28 28
</table>
29 29
30 30
<div class="pagination">
31 -
    {{if .HasPrev}}<a href="/r/{{.Repo.Name}}/log/{{.Ref}}?page={{.PrevPage}}">&larr; Newer</a>{{end}}
32 -
    {{if .HasNext}}<a href="/r/{{.Repo.Name}}/log/{{.Ref}}?page={{.NextPage}}">Older &rarr;</a>{{end}}
31 +
    {{if .HasPrev}}<a href="/{{.Repo.Name}}/log/{{.Ref}}?page={{.PrevPage}}">&larr; Newer</a>{{end}}
32 +
    {{if .HasNext}}<a href="/{{.Repo.Name}}/log/{{.Ref}}?page={{.NextPage}}">Older &rarr;</a>{{end}}
33 33
</div>
34 34
{{end}}
apps/kepler/templates/refs.html +7 −7
1 1
{{define "refs.html"}}{{template "base.html" .}}{{end}}
2 2
{{define "title"}}refs — {{.Repo.Name}} — {{.SiteName}}{{end}}
3 3
{{define "tabs"}}
4 -
<a href="/r/{{.Repo.Name}}" class="tab">home</a>
5 -
<a href="/r/{{.Repo.Name}}/log/{{.DefaultRef}}" class="tab">log</a>
6 -
<a href="/r/{{.Repo.Name}}/refs" class="tab active">refs</a>
4 +
<a href="/{{.Repo.Name}}" class="tab">home</a>
5 +
<a href="/{{.Repo.Name}}/log/{{.DefaultRef}}" class="tab">log</a>
6 +
<a href="/{{.Repo.Name}}/refs" class="tab active">refs</a>
7 7
{{end}}
8 8
{{define "content"}}
9 9
<h3>Branches</h3>
12 12
    <tbody>
13 13
        {{range .Branches}}
14 14
        <tr>
15 -
            <td><a href="/r/{{$.Repo.Name}}/tree/{{.Name}}">{{.Name}}</a></td>
15 +
            <td><a href="/{{$.Repo.Name}}/tree/{{.Name}}">{{.Name}}</a></td>
16 16
            <td class="hash">{{shortSHA .SHA}}</td>
17 17
            <td class="author">{{.Author}}</td>
18 18
            <td class="date">{{timeAgo .Time}}</td>
19 -
            <td><a href="/r/{{$.Repo.Name}}/log/{{.Name}}">log</a></td>
19 +
            <td><a href="/{{$.Repo.Name}}/log/{{.Name}}">log</a></td>
20 20
        </tr>
21 21
        {{end}}
22 22
    </tbody>
31 31
    <tbody>
32 32
        {{range .Tags}}
33 33
        <tr>
34 -
            <td><a href="/r/{{$.Repo.Name}}/tree/{{.Name}}">{{.Name}}</a></td>
34 +
            <td><a href="/{{$.Repo.Name}}/tree/{{.Name}}">{{.Name}}</a></td>
35 35
            <td class="hash">{{shortSHA .SHA}}</td>
36 36
            <td class="author">{{.Author}}</td>
37 37
            <td class="date">{{timeAgo .Time}}</td>
38 -
            <td><a href="/r/{{$.Repo.Name}}/archive/{{.Name}}.tar.gz">tar.gz</a></td>
38 +
            <td><a href="/{{$.Repo.Name}}/archive/{{.Name}}.tar.gz">tar.gz</a></td>
39 39
        </tr>
40 40
        {{end}}
41 41
    </tbody>
apps/kepler/templates/repo.html +6 −6
1 1
{{define "repo.html"}}{{template "base.html" .}}{{end}}
2 2
{{define "title"}}{{.Repo.Name}} — {{.SiteName}}{{end}}
3 3
{{define "tabs"}}
4 -
<a href="/r/{{.Repo.Name}}" class="tab active">home</a>
5 -
<a href="/r/{{.Repo.Name}}/log/{{.DefaultRef}}" class="tab">log</a>
6 -
<a href="/r/{{.Repo.Name}}/refs" class="tab">refs</a>
4 +
<a href="/{{.Repo.Name}}" class="tab active">home</a>
5 +
<a href="/{{.Repo.Name}}/log/{{.DefaultRef}}" class="tab">log</a>
6 +
<a href="/{{.Repo.Name}}/refs" class="tab">refs</a>
7 7
{{end}}
8 8
{{define "content"}}
9 9
{{if .HasLatest}}
10 10
<div class="last-commit">
11 -
    <span class="hash"><a href="/r/{{.Repo.Name}}/commit/{{.LatestCommit.SHA}}">{{.LatestCommit.ShortSHA}}</a></span>
11 +
    <span class="hash"><a href="/{{.Repo.Name}}/commit/{{.LatestCommit.SHA}}">{{.LatestCommit.ShortSHA}}</a></span>
12 12
    <span class="subject">{{.LatestCommit.Subject}}</span>
13 13
    <span class="author">{{.LatestCommit.Author}}</span>
14 14
    <span class="date">{{timeAgo .LatestCommit.When}}</span>
20 20
        {{if .Entries}}
21 21
        {{range .Entries}}
22 22
        {{if .IsDir}}
23 -
        <a class="tree-entry" href="/r/{{$.Repo.Name}}/tree/{{$.DefaultRef}}/{{.Path}}">
23 +
        <a class="tree-entry" href="/{{$.Repo.Name}}/tree/{{$.DefaultRef}}/{{.Path}}">
24 24
            <span class="name">{{.Name}}/</span>
25 25
        </a>
26 26
        {{else}}
27 -
        <a class="tree-entry" href="/r/{{$.Repo.Name}}/blob/{{$.DefaultRef}}/{{.Path}}">
27 +
        <a class="tree-entry" href="/{{$.Repo.Name}}/blob/{{$.DefaultRef}}/{{.Path}}">
28 28
            <span class="name">{{.Name}}</span>
29 29
            <span class="size">{{humanSize .Size}}</span>
30 30
        </a>
apps/kepler/templates/tree.html +5 −5
1 1
{{define "tree.html"}}{{template "base.html" .}}{{end}}
2 2
{{define "title"}}{{.Repo.Name}} / {{.Path}} — {{.SiteName}}{{end}}
3 3
{{define "tabs"}}
4 -
<a href="/r/{{.Repo.Name}}" class="tab">home</a>
5 -
<a href="/r/{{.Repo.Name}}/log/{{.Ref}}" class="tab">log</a>
6 -
<a href="/r/{{.Repo.Name}}/refs" class="tab">refs</a>
4 +
<a href="/{{.Repo.Name}}" class="tab">home</a>
5 +
<a href="/{{.Repo.Name}}/log/{{.Ref}}" class="tab">log</a>
6 +
<a href="/{{.Repo.Name}}/refs" class="tab">refs</a>
7 7
{{end}}
8 8
{{define "content"}}
9 9
<nav class="breadcrumbs">
16 16
        <tr>
17 17
            <td>
18 18
                {{if .IsDir}}
19 -
                <a href="/r/{{$.Repo.Name}}/tree/{{$.Ref}}/{{.Path}}">{{.Name}}/</a>
19 +
                <a href="/{{$.Repo.Name}}/tree/{{$.Ref}}/{{.Path}}">{{.Name}}/</a>
20 20
                {{else}}
21 -
                <a href="/r/{{$.Repo.Name}}/blob/{{$.Ref}}/{{.Path}}">{{.Name}}</a>
21 +
                <a href="/{{$.Repo.Name}}/blob/{{$.Ref}}/{{.Path}}">{{.Name}}</a>
22 22
                {{end}}
23 23
            </td>
24 24
            <td class="size">{{if not .IsDir}}{{humanSize .Size}}{{end}}</td>