2
0

feat(pages): add public releases option for landing pages

Allow private repositories to enable public release downloads on their landing pages. When enabled, unauthenticated users can download release attachments without accessing the repository. Adds download sections to all landing page templates with styling.
This commit is contained in:
2026-03-06 18:04:35 -05:00
parent 6ceb4f0ad4
commit 734dd895bb
9 changed files with 334 additions and 3 deletions

View File

@@ -37,6 +37,7 @@ import (
"code.gitcaddy.com/server/v3/modules/setting"
"code.gitcaddy.com/server/v3/modules/util"
asymkey_service "code.gitcaddy.com/server/v3/services/asymkey"
pages_service "code.gitcaddy.com/server/v3/services/pages"
"github.com/editorconfig/editorconfig-core-go/v2"
)
@@ -402,8 +403,13 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
EarlyResponseForGoGetMeta(ctx)
return
}
ctx.NotFound(nil)
return
// Allow release downloads for private repos with public_releases enabled
reqPath := ctx.Req.URL.Path
isReleaseDownload := strings.Contains(reqPath, "/releases/download/") || strings.Contains(reqPath, "/releases/attachments/")
if !isReleaseDownload || !pages_service.HasPublicReleases(ctx, repo) {
ctx.NotFound(nil)
return
}
}
ctx.Data["Permission"] = &ctx.Repo.Permission