From 3086165b7f08b77c8cb291ae275bb0c4524feeae Mon Sep 17 00:00:00 2001 From: Nirmal Kumar R Date: Tue, 5 Nov 2024 22:01:22 +0000 Subject: [PATCH] Fix data-context + Remove RelativePath attributes --- modules/structs/miscellaneous.go | 4 ---- routers/api/v1/misc/markup.go | 13 ++++++------- routers/common/markup.go | 6 +++--- routers/web/misc/markup.go | 13 ++++++------- templates/repo/editor/edit.tmpl | 2 +- templates/swagger/v1_json.tmpl | 4 ---- web_src/js/features/repo-editor.js | 1 - 7 files changed, 16 insertions(+), 27 deletions(-) diff --git a/modules/structs/miscellaneous.go b/modules/structs/miscellaneous.go index 3af7c818d1..7866cb5fc0 100644 --- a/modules/structs/miscellaneous.go +++ b/modules/structs/miscellaneous.go @@ -41,10 +41,6 @@ type MarkupOption struct { // // in: body BranchPath string - // Relative path to the repository - // - // in: body - RelativePath string } // MarkupRender is a rendered markup document diff --git a/routers/api/v1/misc/markup.go b/routers/api/v1/misc/markup.go index 94046c1352..155ad15712 100644 --- a/routers/api/v1/misc/markup.go +++ b/routers/api/v1/misc/markup.go @@ -42,13 +42,12 @@ func Markup(ctx *context.APIContext) { } re := common.Renderer{ - Mode: form.Mode, - Text: form.Text, - URLPrefix: form.Context, - FilePath: form.FilePath, - BranchPath: form.BranchPath, - RelativePath: form.RelativePath, - IsWiki: form.Wiki, + Mode: form.Mode, + Text: form.Text, + URLPrefix: form.Context, + FilePath: form.FilePath, + BranchPath: form.BranchPath, + IsWiki: form.Wiki, } re.RenderMarkup(ctx.Base, ctx.Repo) diff --git a/routers/common/markup.go b/routers/common/markup.go index 7e11d88e93..ea14e315f2 100644 --- a/routers/common/markup.go +++ b/routers/common/markup.go @@ -19,8 +19,8 @@ import ( ) type Renderer struct { - Mode, Text, URLPrefix, FilePath, BranchPath, RelativePath string - IsWiki bool + Mode, Text, URLPrefix, FilePath, BranchPath string + IsWiki bool } // RenderMarkup renders markup text for the /markup and /markdown endpoints @@ -55,7 +55,7 @@ func (re *Renderer) RenderMarkup(ctx *context.Base, repo *context.Repository) { case "file": // File as document based on file extension markupType = "" - re.URLPrefix = re.RelativePath + re.URLPrefix = repo.RepoLink relativePath = re.FilePath default: ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Unknown mode: %s", re.Mode)) diff --git a/routers/web/misc/markup.go b/routers/web/misc/markup.go index e9a6f951d1..2bae122b91 100644 --- a/routers/web/misc/markup.go +++ b/routers/web/misc/markup.go @@ -16,13 +16,12 @@ func Markup(ctx *context.Context) { form := web.GetForm(ctx).(*api.MarkupOption) re := common.Renderer{ - Mode: form.Mode, - Text: form.Text, - URLPrefix: form.Context, - FilePath: form.FilePath, - BranchPath: form.BranchPath, - RelativePath: form.RelativePath, - IsWiki: form.Wiki, + Mode: form.Mode, + Text: form.Text, + URLPrefix: form.Context, + FilePath: form.FilePath, + BranchPath: form.BranchPath, + IsWiki: form.Wiki, } re.RenderMarkup(ctx.Base, ctx.Repo) diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 7b750b1e27..39379a977c 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -28,7 +28,7 @@