diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-05-30 15:04:01 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-30 07:04:01 +0000 |
commit | 015efcd8bfd451ef593192eb43cfcfb7001f7861 (patch) | |
tree | 73ebb78e07ed61b2f09f0a042f38bd68cbd0b9f1 /routers | |
parent | d612a24e3e8cd288047448df86b69d00484dd183 (diff) | |
download | gitea-015efcd8bfd451ef593192eb43cfcfb7001f7861.tar.gz gitea-015efcd8bfd451ef593192eb43cfcfb7001f7861.zip |
Use repo as of renderctx's member rather than a repoPath on metas (#29222)
Use a `gitrepo.Repository` in the markup's RenderContext but not store
the repository's path.
Diffstat (limited to 'routers')
-rw-r--r-- | routers/common/markup.go | 6 | ||||
-rw-r--r-- | routers/web/feed/convert.go | 3 | ||||
-rw-r--r-- | routers/web/repo/commit.go | 1 | ||||
-rw-r--r-- | routers/web/repo/issue.go | 5 | ||||
-rw-r--r-- | routers/web/repo/milestone.go | 2 | ||||
-rw-r--r-- | routers/web/repo/projects.go | 2 | ||||
-rw-r--r-- | routers/web/repo/release.go | 1 | ||||
-rw-r--r-- | routers/web/user/home.go | 1 |
8 files changed, 19 insertions, 2 deletions
diff --git a/routers/common/markup.go b/routers/common/markup.go index 2d5638ef61..f7d096008a 100644 --- a/routers/common/markup.go +++ b/routers/common/markup.go @@ -9,6 +9,7 @@ import ( "net/http" "strings" + repo_model "code.gitea.io/gitea/models/repo" "code.gitea.io/gitea/modules/markup" "code.gitea.io/gitea/modules/markup/markdown" "code.gitea.io/gitea/modules/setting" @@ -66,7 +67,9 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr } meta := map[string]string{} + var repoCtx *repo_model.Repository if repo != nil && repo.Repository != nil { + repoCtx = repo.Repository if mode == "comment" { meta = repo.Repository.ComposeMetas(ctx) } else { @@ -78,7 +81,8 @@ func RenderMarkup(ctx *context.Base, repo *context.Repository, mode, text, urlPr } if err := markup.Render(&markup.RenderContext{ - Ctx: ctx, + Ctx: ctx, + Repo: repoCtx, Links: markup.Links{ AbsolutePrefix: true, Base: urlPrefix, diff --git a/routers/web/feed/convert.go b/routers/web/feed/convert.go index 20fcda6664..cb62858631 100644 --- a/routers/web/feed/convert.go +++ b/routers/web/feed/convert.go @@ -297,7 +297,8 @@ func releasesToFeedItems(ctx *context.Context, releases []*repo_model.Release) ( link := &feeds.Link{Href: rel.HTMLURL()} content, err = markdown.RenderString(&markup.RenderContext{ - Ctx: ctx, + Ctx: ctx, + Repo: rel.Repo, Links: markup.Links{ Base: rel.Repo.Link(), }, diff --git a/routers/web/repo/commit.go b/routers/web/repo/commit.go index a2c6ac33e8..7b5e72593f 100644 --- a/routers/web/repo/commit.go +++ b/routers/web/repo/commit.go @@ -382,6 +382,7 @@ func Diff(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, template.HTMLEscapeString(string(charset.ToUTF8WithFallback(note.Message, charset.ConvertOpts{})))) if err != nil { diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index ce459f23b9..18f975b4a6 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -1466,6 +1466,7 @@ func ViewIssue(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, issue.Content) if err != nil { @@ -1622,6 +1623,7 @@ func ViewIssue(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, comment.Content) if err != nil { @@ -1699,6 +1701,7 @@ func ViewIssue(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, comment.Content) if err != nil { @@ -2276,6 +2279,7 @@ func UpdateIssueContent(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, issue.Content) if err != nil { @@ -3196,6 +3200,7 @@ func UpdateCommentContent(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, comment.Content) if err != nil { diff --git a/routers/web/repo/milestone.go b/routers/web/repo/milestone.go index 95a4fe60cc..c6c8cb5cfb 100644 --- a/routers/web/repo/milestone.go +++ b/routers/web/repo/milestone.go @@ -86,6 +86,7 @@ func Milestones(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, m.Content) if err != nil { @@ -282,6 +283,7 @@ func MilestoneIssuesAndPulls(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, milestone.Content) if err != nil { diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 9ce5535a0e..2e32f478aa 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -96,6 +96,7 @@ func Projects(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, projects[i].Description) if err != nil { @@ -357,6 +358,7 @@ func ViewProject(ctx *context.Context) { }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, project.Description) if err != nil { diff --git a/routers/web/repo/release.go b/routers/web/repo/release.go index 7ba23f0701..8ba2adf3f1 100644 --- a/routers/web/repo/release.go +++ b/routers/web/repo/release.go @@ -119,6 +119,7 @@ func getReleaseInfos(ctx *context.Context, opts *repo_model.FindReleasesOptions) }, Metas: ctx.Repo.Repository.ComposeMetas(ctx), GitRepo: ctx.Repo.GitRepo, + Repo: ctx.Repo.Repository, Ctx: ctx, }, r.Note) if err != nil { diff --git a/routers/web/user/home.go b/routers/web/user/home.go index c3f34039e9..b03a514030 100644 --- a/routers/web/user/home.go +++ b/routers/web/user/home.go @@ -262,6 +262,7 @@ func Milestones(ctx *context.Context) { }, Metas: milestones[i].Repo.ComposeMetas(ctx), Ctx: ctx, + Repo: milestones[i].Repo, }, milestones[i].Content) if err != nil { ctx.ServerError("RenderString", err) |