1
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-02-02 15:09:33 -05:00

code unit get its sub path as every other unit

This commit is contained in:
6543 2024-10-29 00:06:39 +01:00
parent 91ae32ca7c
commit b33f9b6c95
3 changed files with 14 additions and 4 deletions

View File

@ -206,7 +206,7 @@ var (
UnitCode = Unit{
TypeCode,
"repo.code",
"/",
"/code",
"repo.code.desc",
0,
perm.AccessModeOwner,

View File

@ -773,8 +773,8 @@ func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
}
}
// Home render repository home page
func Home(ctx *context.Context) {
// HomeWithFeedCheck render repository home page or return feed
func HomeWithFeedCheck(ctx *context.Context) {
if setting.Other.EnableFeed {
isFeed, _, showFeedType := feed.GetFeedType(ctx.PathParam(":reponame"), ctx.Req)
if isFeed {
@ -790,6 +790,15 @@ func Home(ctx *context.Context) {
}
}
defaultURI := ctx.Repo.Repository.MustGetUnit(ctx, ctx.Repo.Repository.DefaultUnit).Unit().URI
if defaultURI == "/" { // support legacy code units
defaultURI = "/code"
}
ctx.Redirect(ctx.Repo.RepoLink + defaultURI)
}
// Home render repository home page
func Home(ctx *context.Context) {
checkHomeCodeViewable(ctx)
if ctx.Written() {
return

View File

@ -1140,7 +1140,8 @@ func registerRoutes(m *web.Router) {
// end "/{username}/{reponame}/settings"
// user/org home, including rss feeds
m.Get("/{username}/{reponame}", ignSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.Home)
m.Get("/{username}/{reponame}", ignSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.HomeWithFeedCheck)
m.Get("/{username}/{reponame}/code", ignSignIn, context.RepoAssignment, context.RepoRef(), repo.SetEditorconfigIfExists, repo.Home)
// TODO: maybe it should relax the permission to allow "any access"
m.Post("/{username}/{reponame}/markup", ignSignIn, context.RepoAssignment, context.RequireRepoReaderOr(unit.TypeCode, unit.TypeIssues, unit.TypePullRequests, unit.TypeReleases, unit.TypeWiki), web.Bind(structs.MarkupOption{}), misc.Markup)