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:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user