mirror of
https://codeberg.org/forgejo/forgejo
synced 2024-11-28 20:56:11 +01:00
Fix data-context + Remove RelativePath attributes
This commit is contained in:
parent
a625a0b307
commit
a057b7f582
|
@ -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
|
||||||
|
|
|
@ -42,13 +42,12 @@ func Markup(ctx *context.APIContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
re := common.Renderer{
|
re := common.Renderer{
|
||||||
Mode: form.Mode,
|
Mode: form.Mode,
|
||||||
Text: form.Text,
|
Text: form.Text,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
re.RenderMarkup(ctx.Base, ctx.Repo)
|
re.RenderMarkup(ctx.Base, ctx.Repo)
|
||||||
|
|
|
@ -19,8 +19,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type Renderer struct {
|
type Renderer struct {
|
||||||
Mode, Text, URLPrefix, FilePath, BranchPath, RelativePath string
|
Mode, Text, URLPrefix, FilePath, BranchPath string
|
||||||
IsWiki bool
|
IsWiki bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderMarkup renders markup text for the /markup and /markdown endpoints
|
// 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":
|
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))
|
||||||
|
|
|
@ -16,13 +16,12 @@ func Markup(ctx *context.Context) {
|
||||||
form := web.GetForm(ctx).(*api.MarkupOption)
|
form := web.GetForm(ctx).(*api.MarkupOption)
|
||||||
|
|
||||||
re := common.Renderer{
|
re := common.Renderer{
|
||||||
Mode: form.Mode,
|
Mode: form.Mode,
|
||||||
Text: form.Text,
|
Text: form.Text,
|
||||||
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,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
re.RenderMarkup(ctx.Base, ctx.Repo)
|
re.RenderMarkup(ctx.Base, ctx.Repo)
|
||||||
|
|
|
@ -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}}
|
||||||
|
|
4
templates/swagger/v1_json.tmpl
generated
4
templates/swagger/v1_json.tmpl
generated
|
@ -24335,10 +24335,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"
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
Loading…
Reference in a new issue