mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-21 17:34:24 +01:00
Fix data-context + Remove RelativePath attributes
This commit is contained in:
parent
1c3faf8adb
commit
3086165b7f
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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}}
|
||||
|
|
4
templates/swagger/v1_json.tmpl
generated
4
templates/swagger/v1_json.tmpl
generated
|
@ -24338,10 +24338,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"
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Reference in a new issue