mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor markup render system (#32589)
This PR mainly moves some code and introduces `RenderContext.WithXxx` functions
This commit is contained in:
@@ -259,9 +259,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
|
||||
|
||||
ctx.Data["IsFollowing"] = ctx.Doer != nil && user_model.IsFollowing(ctx, ctx.Doer.ID, ctx.ContextUser.ID)
|
||||
if len(ctx.ContextUser.Description) != 0 {
|
||||
content, err := markdown.RenderString(&markup.RenderContext{
|
||||
Ctx: ctx,
|
||||
}, ctx.ContextUser.Description)
|
||||
content, err := markdown.RenderString(markup.NewRenderContext(ctx), ctx.ContextUser.Description)
|
||||
if err != nil {
|
||||
ctx.ServerError("RenderString", err)
|
||||
return
|
||||
|
@@ -219,15 +219,11 @@ func composeIssueCommentMessages(ctx *mailCommentContext, lang string, recipient
|
||||
}
|
||||
|
||||
// This is the body of the new issue or comment, not the mail body
|
||||
body, err := markdown.RenderString(&markup.RenderContext{
|
||||
Ctx: ctx,
|
||||
Repo: ctx.Issue.Repo,
|
||||
Links: markup.Links{
|
||||
AbsolutePrefix: true,
|
||||
Base: ctx.Issue.Repo.HTMLURL(),
|
||||
},
|
||||
Metas: ctx.Issue.Repo.ComposeMetas(ctx),
|
||||
}, ctx.Content)
|
||||
body, err := markdown.RenderString(markup.NewRenderContext(ctx).
|
||||
WithRepoFacade(ctx.Issue.Repo).
|
||||
WithLinks(markup.Links{AbsolutePrefix: true, Base: ctx.Issue.Repo.HTMLURL()}).
|
||||
WithMetas(ctx.Issue.Repo.ComposeMetas(ctx)),
|
||||
ctx.Content)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@@ -56,14 +56,11 @@ func mailNewRelease(ctx context.Context, lang string, tos []*user_model.User, re
|
||||
locale := translation.NewLocale(lang)
|
||||
|
||||
var err error
|
||||
rel.RenderedNote, err = markdown.RenderString(&markup.RenderContext{
|
||||
Ctx: ctx,
|
||||
Repo: rel.Repo,
|
||||
Links: markup.Links{
|
||||
Base: rel.Repo.HTMLURL(),
|
||||
},
|
||||
Metas: rel.Repo.ComposeMetas(ctx),
|
||||
}, rel.Note)
|
||||
rel.RenderedNote, err = markdown.RenderString(markup.NewRenderContext(ctx).
|
||||
WithRepoFacade(rel.Repo).
|
||||
WithLinks(markup.Links{Base: rel.Repo.HTMLURL()}).
|
||||
WithMetas(rel.Repo.ComposeMetas(ctx)),
|
||||
rel.Note)
|
||||
if err != nil {
|
||||
log.Error("markdown.RenderString(%d): %v", rel.RepoID, err)
|
||||
return
|
||||
|
Reference in New Issue
Block a user