Template
1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo synced 2024-11-25 11:16:11 +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 1c3faf8adb
commit 3086165b7f
7 changed files with 16 additions and 27 deletions

View file

@ -41,10 +41,6 @@ type MarkupOption struct {
// //
// in: body // in: body
BranchPath string BranchPath string
// Relative path to the repository
//
// in: body
RelativePath string
} }
// MarkupRender is a rendered markup document // MarkupRender is a rendered markup document

View file

@ -47,7 +47,6 @@ func Markup(ctx *context.APIContext) {
URLPrefix: form.Context, URLPrefix: form.Context,
FilePath: form.FilePath, FilePath: form.FilePath,
BranchPath: form.BranchPath, BranchPath: form.BranchPath,
RelativePath: form.RelativePath,
IsWiki: form.Wiki, IsWiki: form.Wiki,
} }

View file

@ -19,7 +19,7 @@ import (
) )
type Renderer struct { type Renderer struct {
Mode, Text, URLPrefix, FilePath, BranchPath, RelativePath string Mode, Text, URLPrefix, FilePath, BranchPath string
IsWiki bool IsWiki bool
} }
@ -55,7 +55,7 @@ func (re *Renderer) RenderMarkup(ctx *context.Base, repo *context.Repository) {
case "file": case "file":
// File as document based on file extension // File as document based on file extension
markupType = "" markupType = ""
re.URLPrefix = re.RelativePath re.URLPrefix = repo.RepoLink
relativePath = re.FilePath relativePath = re.FilePath
default: default:
ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Unknown mode: %s", re.Mode)) ctx.Error(http.StatusUnprocessableEntity, fmt.Sprintf("Unknown mode: %s", re.Mode))

View file

@ -21,7 +21,6 @@ func Markup(ctx *context.Context) {
URLPrefix: form.Context, URLPrefix: form.Context,
FilePath: form.FilePath, FilePath: form.FilePath,
BranchPath: form.BranchPath, BranchPath: form.BranchPath,
RelativePath: form.RelativePath,
IsWiki: form.Wiki, IsWiki: form.Wiki,
} }

View file

@ -28,7 +28,7 @@
<div class="field"> <div class="field">
<div class="ui top attached tabular menu" data-write="write" data-preview="preview" data-diff="diff"> <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="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}} {{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> <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}} {{end}}

View file

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

View file

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