Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 03:06:10 +01:00

Fix data-context + Remove RelativePath attributes

This commit is contained in:
Nirmal Kumar R 2024-11-05 22:01:22 +00:00
parent a625a0b307
commit a057b7f582
7 changed files with 16 additions and 27 deletions

View file

@ -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

View file

@ -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)

View file

@ -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))

View file

@ -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)

View file

@ -28,7 +28,7 @@
<div class="field">
<div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff">
<a class="active item" data-tab="write">{{svg "octicon-code"}} {{if .IsNewFile}}{{ctx.Locale.Tr "repo.editor.new_file"}}{{else}}{{ctx.Locale.Tr "repo.editor.edit_file"}}{{end}}</a>
<a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markup" data-context="{{.RepoLink}}/src/{{.BranchNameSubURL}}" data-branch-path="{{.BranchNameSubURL}}" data-relative-path="{{.Repository.Link}}" data-markup-mode="file">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a>
<a class="item" data-tab="preview" data-url="{{.Repository.Link}}/markup" data-context="{{.RepoLink}}" data-branch-path="{{.BranchNameSubURL}}" data-markup-mode="file">{{svg "octicon-eye"}} {{ctx.Locale.Tr "preview"}}</a>
{{if not .IsNewFile}}
<a class="item" data-tab="diff" hx-params="context,content" hx-vals='{"context":"{{.BranchLink}}"}' hx-include="#edit_area" hx-swap="innerHTML" hx-target=".tab[data-tab='diff']" hx-indicator=".tab[data-tab='diff']" hx-post="{{.RepoLink}}/_preview/{{.BranchName | PathEscapeSegments}}/{{.TreePath | PathEscapeSegments}}">{{svg "octicon-diff"}} {{ctx.Locale.Tr "repo.editor.preview_changes"}}</a>
{{end}}

View file

@ -24335,10 +24335,6 @@
"description": "Mode to render (comment, gfm, markdown, file)\n\nin: body",
"type": "string"
},
"RelativePath": {
"description": "Relative path to the repository\n\nin: body",
"type": "string"
},
"Text": {
"description": "Text markup to render\n\nin: body",
"type": "string"

View file

@ -27,7 +27,6 @@ function initEditPreviewTab($form) {
formData.append('mode', mode);
formData.append('context', context);
formData.append('branch_path', $this.data('branch-path'));
formData.append('relative_path', $this.data('relative-path'));
formData.append(
'text',
$form.find(`.tab[data-tab="${$tabMenu.data('write')}"] textarea`).val(),