mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 10:48:37 +00:00
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.
This commit is contained in:
@@ -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,
|
||||
|
@@ -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(),
|
||||
},
|
||||
|
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user