Redesign source link

This commit is contained in:
2026-09-13 12:45:44 +02:00
parent 27be685834
commit 132e7c41d2
5 changed files with 32 additions and 23 deletions
+20 -18
View File
@@ -1148,33 +1148,35 @@ func TestNoFaviconMeansNoLink(t *testing.T) {
// --- the footer ------------------------------------------------------------
// The footer names where the source lives, and an instance that would rather
// not say so can drop it. A fork gets to point at its own.
// The upload page says where the source is; no other page does, and an
// instance that would rather not say so drops it there too.
func TestSourceLinkIsOptional(t *testing.T) {
body := func(h *harness, path string) string {
t.Helper()
resp := h.get(t, path, "")
raw, _ := io.ReadAll(resp.Body)
resp.Body.Close()
return string(raw)
}
shown := newHarness(t, nil)
resp := shown.get(t, "/", "")
page, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if !strings.Contains(string(page), `<footer><a href="https://git.uncensored.hu/thayol/uncensored-send">Source</a>`) {
t.Error("the default build does not link its source")
if !strings.Contains(body(shown, "/"), `<a href="https://git.uncensored.hu/thayol/uncensored-send">`) {
t.Error("the upload page does not link its source")
}
for _, path := range []string{"/login", "/files"} {
if strings.Contains(body(shown, path), "git.uncensored.hu") {
t.Errorf("GET %s carries the source link, which belongs on the upload page alone", path)
}
}
forked := newHarness(t, func(c *config.Config) { c.SourceURL = "https://example.org/me/fork" })
resp = forked.get(t, "/login", "")
page, _ = io.ReadAll(resp.Body)
resp.Body.Close()
if !strings.Contains(string(page), `href="https://example.org/me/fork"`) {
if !strings.Contains(body(forked, "/"), `href="https://example.org/me/fork"`) {
t.Error("a fork's own source URL is not used")
}
quiet := newHarness(t, func(c *config.Config) { c.SourceURL = "" })
for _, path := range []string{"/", "/login", "/files"} {
resp := quiet.get(t, path, "")
page, _ := io.ReadAll(resp.Body)
resp.Body.Close()
if strings.Contains(string(page), "<footer>") {
t.Errorf("GET %s still carries a footer with the source link switched off", path)
}
if page := body(quiet, "/"); strings.Contains(page, ">Source<") || strings.Contains(page, "git.uncensored.hu") {
t.Error("the upload page still names a source with the link switched off")
}
}