vole
Clone
Read only, no credentials:
https://rodent.software/vole.git
Write over SSH with a registered key:
git clone ssh://git@rodent.software:2222/vole.git
A free and open-source forge that lives in your Git repo.
Serve repositories from the root of the URL space
ed03b3d1fa16ef6b55e2773aaf10e3be13282c3a · Keenan Nemetz · 8h ago · parent d37d301f
Serve repositories from the root of the URL space A repository is now /<name> and its Git transport /<name>.git, so the URL a person opens, the URL a clone uses, and the Go module path are the same name. The forge's own pages moved under /-/ (admin, accounts, the directory, the feed, sign-in, assets), a prefix no repository name can start with: names are [a-z0-9...] and cannot begin with "-". That leaves the router with two disjoint spaces and removes the /r/ and /git/ prefixes, which existed only to keep repositories away from the forge's own paths. Routes: repoRoutes lose /r/; global, auth and admin routes gain /-/; assets move to /-/static/ because a subtree pattern like /static/ cannot coexist with one-segment-wildcard repo routes — Go's mux reports them as conflicting neither-more-specific patterns. The catch-all still renders the styled 404. Transport: githttp.Route parses /<name>.git/<rest> instead of a /git/ prefix, and forgepaths.go hands such requests to the proxy before the mux, because a wildcard fills a whole segment and cannot match "<name>.git". LFS stays on the mux (<name>.git/info/lfs/...), and the Go module discovery probe moves to the same pre-router so a package path under a public repository is answered even when its first segments name a page tab. Names: repo.ValidateName now refuses the four root paths the forge must keep — static, robots.txt, sitemap.xml, sitemap-pages.xml. Everything else is an ordinary repository name, including admin, u, and activity. Docs and the packaged URLs follow the new layout; robots.txt, the sitemaps and the instance activity feed point at the new paths. No aliases: the old /r/ and /git/ URLs are gone. Verified with ./vole workflow check and ./vole workflow run verify.
server/instance_repo_test.go +18−18
| @@ -25,8 +25,8 @@ func TestInstanceRepoSuppliesThePage(t *testing.T) { | |||
| 25 | 25 | _, body := f.get("/") | |
| 26 | 26 | for _, want := range []string{ | |
| 27 | 27 | "From the repo", "Custom words.", | |
| 28 | `href="/static/custom/profile/custom.css?v=`, | ||
| 29 | `href="/static/custom/profile/favicon.svg?v=`, | ||
| 28 | `href="/-/static/custom/profile/custom.css?v=`, | ||
| 29 | `href="/-/static/custom/profile/favicon.svg?v=`, | ||
| 30 | 30 | } { | |
| 31 | 31 | if !strings.Contains(body, want) { | |
| 32 | 32 | t.Fatalf("home is missing %q:\n%s", want, body) | |
| @@ -48,16 +48,16 @@ func TestInstanceRepoSuppliesThePage(t *testing.T) { | |||
| 48 | 48 | t.Fatalf("signed-in home did not use the private README:\n%s", signed) | |
| 49 | 49 | } | |
| 50 | 50 | ||
| 51 | resp, css := f.get("/static/custom/profile/custom.css") | ||
| 51 | resp, css := f.get("/-/static/custom/profile/custom.css") | ||
| 52 | 52 | if resp != 200 || !strings.Contains(css, "--accent") { | |
| 53 | 53 | t.Fatalf("custom.css = %d %q", resp, css) | |
| 54 | 54 | } | |
| 55 | resp, png := f.get("/static/custom/assets/logo.png") | ||
| 55 | resp, png := f.get("/-/static/custom/assets/logo.png") | ||
| 56 | 56 | if resp != 200 || png != "PNG" { | |
| 57 | 57 | t.Fatalf("asset = %d %q", resp, png) | |
| 58 | 58 | } | |
| 59 | 59 | // A same-origin script is not an asset. | |
| 60 | if resp, _ := f.get("/static/custom/assets/evil.js"); resp != 404 { | ||
| 60 | if resp, _ := f.get("/-/static/custom/assets/evil.js"); resp != 404 { | ||
| 61 | 61 | t.Fatalf("a script under assets/ = %d, want 404", resp) | |
| 62 | 62 | } | |
| 63 | 63 | } | |
| @@ -72,16 +72,16 @@ func TestInstanceThemesAppearInAppearance(t *testing.T) { | |||
| 72 | 72 | }) | |
| 73 | 73 | ||
| 74 | 74 | _, cookie := f.browserSession(t, f.ownerID) | |
| 75 | resp, account := f.browserGet(t, "/account", cookie) | ||
| 75 | resp, account := f.browserGet(t, "/-/account", cookie) | ||
| 76 | 76 | if resp.StatusCode != 200 { | |
| 77 | t.Fatalf("/account = %d", resp.StatusCode) | ||
| 77 | t.Fatalf("/-/account = %d", resp.StatusCode) | ||
| 78 | 78 | } | |
| 79 | 79 | for _, want := range []string{ | |
| 80 | 80 | `value="acme-ocean"`, `Acme Ocean`, | |
| 81 | 81 | `value="acme-paper"`, `Acme Paper`, | |
| 82 | 82 | `data-themes="acme-ocean,acme-paper"`, | |
| 83 | `href="/static/custom/themes/acme-ocean.css?v=`, | ||
| 84 | `href="/static/custom/themes/acme-paper.css?v=`, | ||
| 83 | `href="/-/static/custom/themes/acme-ocean.css?v=`, | ||
| 84 | `href="/-/static/custom/themes/acme-paper.css?v=`, | ||
| 85 | 85 | } { | |
| 86 | 86 | if !strings.Contains(account, want) { | |
| 87 | 87 | t.Errorf("Account is missing %q:\n%s", want, account) | |
| @@ -91,11 +91,11 @@ func TestInstanceThemesAppearInAppearance(t *testing.T) { | |||
| 91 | 91 | t.Error("a non-CSS file under themes/ became a picker option") | |
| 92 | 92 | } | |
| 93 | 93 | ||
| 94 | code, css := f.get("/static/custom/themes/acme-ocean.css") | ||
| 94 | code, css := f.get("/-/static/custom/themes/acme-ocean.css") | ||
| 95 | 95 | if code != 200 || !strings.Contains(css, "#38bdf8") { | |
| 96 | 96 | t.Fatalf("theme stylesheet = %d %q", code, css) | |
| 97 | 97 | } | |
| 98 | if code, _ := f.get("/static/custom/themes/notes.css"); code != 404 { | ||
| 98 | if code, _ := f.get("/-/static/custom/themes/notes.css"); code != 404 { | ||
| 99 | 99 | t.Fatalf("a missing theme file = %d, want 404", code) | |
| 100 | 100 | } | |
| 101 | 101 | } | |
| @@ -110,10 +110,10 @@ func TestInstanceRepoIsListedLikeAnyOtherRepository(t *testing.T) { | |||
| 110 | 110 | f.publish(f.cfg.InstanceRepo) | |
| 111 | 111 | ||
| 112 | 112 | _, body := f.get("/") | |
| 113 | if !strings.Contains(body, `href="/r/`+f.cfg.InstanceRepo+`"`) { | ||
| 113 | if !strings.Contains(body, `href="/`+f.cfg.InstanceRepo+`"`) { | ||
| 114 | 114 | t.Fatalf("the instance repository is missing from the repository list:\n%s", body) | |
| 115 | 115 | } | |
| 116 | if !strings.Contains(body, `href="/r/demo"`) { | ||
| 116 | if !strings.Contains(body, `href="/demo"`) { | ||
| 117 | 117 | t.Fatalf("the project repository disappeared:\n%s", body) | |
| 118 | 118 | } | |
| 119 | 119 | } | |
| @@ -126,13 +126,13 @@ func TestAdminCreatesTheInstanceRepository(t *testing.T) { | |||
| 126 | 126 | } | |
| 127 | 127 | sess, cookie := f.browserSession(t, f.ownerID) | |
| 128 | 128 | ||
| 129 | resp, body := f.browserGet(t, "/admin?tab=configuration", cookie) | ||
| 130 | if resp.StatusCode != 200 || !strings.Contains(body, `action="/admin/instance/repo"`) || | ||
| 129 | resp, body := f.browserGet(t, "/-/admin?tab=configuration", cookie) | ||
| 130 | if resp.StatusCode != 200 || !strings.Contains(body, `action="/-/admin/instance/repo"`) || | ||
| 131 | 131 | !strings.Contains(body, "does not exist yet") { | |
| 132 | 132 | t.Fatalf("configuration tab has no create action = %d:\n%s", resp.StatusCode, body) | |
| 133 | 133 | } | |
| 134 | resp, _ = f.browserPost(t, "/admin/instance/repo", cookie, url.Values{"csrf": {sess.CSRF}}) | ||
| 135 | if resp.StatusCode != 303 || resp.Header.Get("Location") != "/admin?tab=configuration&created=1" { | ||
| 134 | resp, _ = f.browserPost(t, "/-/admin/instance/repo", cookie, url.Values{"csrf": {sess.CSRF}}) | ||
| 135 | if resp.StatusCode != 303 || resp.Header.Get("Location") != "/-/admin?tab=configuration&created=1" { | ||
| 136 | 136 | t.Fatalf("create = %d %q", resp.StatusCode, resp.Header.Get("Location")) | |
| 137 | 137 | } | |
| 138 | 138 | m, err := f.srv.Repos.Open(f.cfg.InstanceRepo) | |
| @@ -143,7 +143,7 @@ func TestAdminCreatesTheInstanceRepository(t *testing.T) { | |||
| 143 | 143 | if err != nil || !strings.Contains(string(blob), "landing page introduction") { | |
| 144 | 144 | t.Fatalf("scaffold profile/README.md = %q, %v", blob, err) | |
| 145 | 145 | } | |
| 146 | _, body = f.browserGet(t, "/admin?tab=configuration", cookie) | ||
| 146 | _, body = f.browserGet(t, "/-/admin?tab=configuration", cookie) | ||
| 147 | 147 | if !strings.Contains(body, "Loaded from") { | |
| 148 | 148 | t.Fatalf("configuration tab does not show the loaded repository:\n%s", body) | |
| 149 | 149 | } | |