Web editor: improve edit file
This commit is contained in:
parent
7115e3a4d5
commit
ba27d71abe
|
@ -426,14 +426,9 @@ file_view_raw = View Raw
|
|||
file_permalink = Permalink
|
||||
file_too_large = This file is too large to be shown
|
||||
|
||||
cancel_lower = cancel
|
||||
or = or
|
||||
upload_files = Upload files
|
||||
edit_file = Edit file
|
||||
unable_to_update_file = Unable to update this file, error occurred
|
||||
filename_help = To add directory, just type it and press /. To remove a directory, go to the beginning of the field and press backspace.
|
||||
new_branch = new branch
|
||||
editor.new_file = New file
|
||||
editor.edit_file = Edit file
|
||||
editor.preview_changes = Preview Changes
|
||||
editor.cannot_edit_non_text_files = Cannot edit non-text files
|
||||
editor.edit_this_file = Edit this file
|
||||
editor.must_be_on_a_branch = You must be on a branch to make or propose changes to this file
|
||||
|
@ -441,6 +436,10 @@ editor.fork_before_edit = You must fork this repository before editing the file
|
|||
editor.delete_this_file = Delete this file
|
||||
editor.must_have_write_access = You must have write access to make or propose changes to this file
|
||||
editor.file_delete_success = File '%s' has been deleted successfully!
|
||||
editor.name_your_file = Name your file...
|
||||
editor.filename_help = To add directory, just type it and press /. To remove a directory, go to the beginning of the field and press backspace.
|
||||
editor.or = or
|
||||
editor.cancel_lower = cancel
|
||||
editor.commit_changes = Commit Changes
|
||||
editor.add_tmpl = Add '%s/<filename>'
|
||||
editor.add = Add '%s'
|
||||
|
@ -458,14 +457,11 @@ editor.filename_is_a_directory = The filename '%s' is an existing directory in t
|
|||
editor.file_editing_no_longer_exists = The file '%s' you are editing no longer exists in the repository.
|
||||
editor.file_changed_while_editing = File content has been changed since you started editing. <a target="_blank" href="%s">Click here</a> to see what have been changed or <strong>press commit again</strong> to overwrite those changes.
|
||||
editor.file_already_exists = A file with name '%s' already exists in this repository.
|
||||
editor.failed_to_upload_files = An error occurred while updating file: %v
|
||||
editor.no_changes_to_show = There are no changes to show.
|
||||
upload_files = Upload files
|
||||
upload_file = Upload file
|
||||
add_files_to_dir = Add files to %s
|
||||
add_subdir = Add subdirectory...
|
||||
name_your_file = Name your file...
|
||||
copy_file_path_to_clipboard = Copy file path to clipboard
|
||||
preview_changes = Preview Changes
|
||||
|
||||
commits.commits = Commits
|
||||
commits.search = Search commits
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -20,7 +20,7 @@ import (
|
|||
|
||||
const (
|
||||
COMMITS base.TplName = "repo/commits"
|
||||
DIFF base.TplName = "repo/diff"
|
||||
DIFF base.TplName = "repo/diff/page"
|
||||
)
|
||||
|
||||
func RefCommits(ctx *context.Context) {
|
||||
|
|
|
@ -22,7 +22,6 @@ import (
|
|||
const (
|
||||
EDIT_FILE base.TplName = "repo/editor/edit"
|
||||
EDIT_DIFF_PREVIEW base.TplName = "repo/editor/diff_preview"
|
||||
NEW_DIFF_PREVIEW base.TplName = "repo/editor/diff_preview_new"
|
||||
DELETE_FILE base.TplName = "repo/editor/delete"
|
||||
)
|
||||
|
||||
|
@ -289,15 +288,9 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
|
|||
|
||||
entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treePath)
|
||||
if err != nil {
|
||||
if git.IsErrNotExist(err) {
|
||||
ctx.Data["FileContent"] = content
|
||||
ctx.HTML(200, NEW_DIFF_PREVIEW)
|
||||
} else {
|
||||
ctx.Error(500, "GetTreeEntryByPath: "+err.Error())
|
||||
}
|
||||
ctx.Error(500, "GetTreeEntryByPath: "+err.Error())
|
||||
return
|
||||
}
|
||||
if entry.IsDir() {
|
||||
} else if entry.IsDir() {
|
||||
ctx.Error(422)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -52,7 +52,6 @@
|
|||
</h4>
|
||||
</div>
|
||||
{{else}}
|
||||
{{$highlightClass := $file.GetHighlightClass}}
|
||||
<div class="diff-file-box diff-box file-content {{TabSizeClass $.Editorconfig $file.Name}}" id="diff-{{.Index}}">
|
||||
<h4 class="ui top attached normal header">
|
||||
<div class="diff-counter count ui left">
|
||||
|
@ -90,6 +89,7 @@
|
|||
<table>
|
||||
<tbody>
|
||||
{{if $.IsSplitStyle}}
|
||||
{{$highlightClass := $file.GetHighlightClass}}
|
||||
{{range $j, $section := $file.Sections}}
|
||||
{{range $k, $line := $section.Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
|
||||
|
@ -109,27 +109,7 @@
|
|||
{{end}}
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{range $j, $section := $file.Sections}}
|
||||
{{range $k, $line := $section.Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
|
||||
{{if eq .GetType 4}}
|
||||
<td colspan="2" class="lines-num">
|
||||
{{/* {{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}} */}}
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-num lines-num-new">
|
||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||
</td>
|
||||
{{end}}
|
||||
<td class="lines-code">
|
||||
<pre><code class="{{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{template "repo/diff/section_unified" .}}
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
|
@ -39,7 +39,7 @@
|
|||
</div>
|
||||
{{end}}
|
||||
|
||||
{{template "repo/diff_box" .}}
|
||||
{{template "repo/diff/box" .}}
|
||||
</div>
|
||||
</div>
|
||||
{{template "base/footer" .}}
|
|
@ -0,0 +1,23 @@
|
|||
{{$file := .}}
|
||||
{{$highlightClass := $file.GetHighlightClass}}
|
||||
{{range $j, $section := $file.Sections}}
|
||||
{{range $k, $line := $section.Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
|
||||
{{if eq .GetType 4}}
|
||||
<td colspan="2" class="lines-num">
|
||||
{{/* {{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}} */}}
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $file.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-num lines-num-new">
|
||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $file.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||
</td>
|
||||
{{end}}
|
||||
<td class="lines-code">
|
||||
<pre><code class="{{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{end}}
|
|
@ -1,29 +1,10 @@
|
|||
{{$highlightClass := .File.GetHighlightClass}}
|
||||
<div class="diff-file-box diff-box file-content" id="diff-{{.Index}}">
|
||||
<div class="diff-file-box">
|
||||
<div class="ui attached table segment">
|
||||
<div class="file-body file-code code-view code-diff">
|
||||
<table>
|
||||
<tbody>
|
||||
{{range $j, $section := .File.Sections}}
|
||||
{{range $k, $line := $section.Lines}}
|
||||
<tr class="{{DiffLineTypeToStr .GetType}}-code nl-{{$k}} ol-{{$k}}">
|
||||
{{if eq .GetType 4}}
|
||||
<td colspan="2" class="lines-num">
|
||||
{{/* {{if gt $j 0}}<span class="fold octicon octicon-fold"></span>{{end}} */}}
|
||||
</td>
|
||||
{{else}}
|
||||
<td class="lines-num lines-num-old">
|
||||
<span rel="{{if $line.LeftIdx}}diff-{{Sha1 $.File.Name}}L{{$line.LeftIdx}}{{end}}">{{if $line.LeftIdx}}{{$line.LeftIdx}}{{end}}</span>
|
||||
</td>
|
||||
<td class="lines-num lines-num-new">
|
||||
<span rel="{{if $line.RightIdx}}diff-{{Sha1 $.File.Name}}R{{$line.RightIdx}}{{end}}">{{if $line.RightIdx}}{{$line.RightIdx}}{{end}}</span>
|
||||
</td>
|
||||
{{end}}
|
||||
<td class="lines-code">
|
||||
<pre><code class="{{if $highlightClass}}language-{{$highlightClass}}{{else}}nohighlight{{end}}">{{$section.GetComputedInlineDiffFor $line}}</code></pre>
|
||||
</td>
|
||||
</tr>
|
||||
{{end}}
|
||||
{{with .File}}
|
||||
{{template "repo/diff/section_unified" .}}
|
||||
{{end}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<div id="file-content" class="ui attached table segment">
|
||||
<div class="file-view code-view has-emoji">
|
||||
<table>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="lines-num"></td>
|
||||
<td class="lines-code"><pre><code><ol class="linenums">{{.FileContent}}</ol></code></pre></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -1,9 +1,9 @@
|
|||
{{template "base/head" .}}
|
||||
<div class="repository file editor">
|
||||
<div class="repository file editor edit">
|
||||
{{template "repo/header" .}}
|
||||
<div class="ui container">
|
||||
{{template "base/alert" .}}
|
||||
<form class="ui edit form" action="{{EscapePound $.Link}}" method="post">
|
||||
<form class="ui edit form" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
<input type="hidden" name="last_commit" value="{{.last_commit}}">
|
||||
<div class="ui secondary menu">
|
||||
|
@ -15,24 +15,23 @@
|
|||
{{range $i, $v := .TreeNames}}
|
||||
<div class="divider"> / </div>
|
||||
{{if eq $i $l}}
|
||||
<input id="file-name" value="{{$v}}" placeholder="{{$.i18n.Tr "repo.name_your_file"}}" required autofocus>
|
||||
<span class="octicon octicon-info poping up" data-content="{{$.i18n.Tr "repo.filename_help"}}" data-position="bottom center" data-variation="tiny"></span>
|
||||
<input id="file-name" value="{{$v}}" placeholder="{{$.i18n.Tr "repo.editor.name_your_file"}}" required autofocus>
|
||||
<span class="octicon octicon-info poping up" data-content="{{$.i18n.Tr "repo.editor.filename_help"}}" data-position="bottom center" data-variation="tiny inverted"></span>
|
||||
{{else}}
|
||||
<span class="section"><a href="{{EscapePound $.BranchLink}}/{{EscapePound $v}}">{{$v}}</a></span>
|
||||
{{end}}
|
||||
{{end}}
|
||||
<!-- <button class="clipboard-tree-name octicon octicon-clippy poping up" type="button" data-content="{{.i18n.Tr "repo.copy_file_path_to_clipboard"}}" data-position="bottom center" data-variation="tiny inverted"></button> -->
|
||||
<span class="repo-edit-file-cancel">{{.i18n.Tr "repo.or"}} <a href="{{EscapePound $.BranchLink}}{{if not .IsNewFile}}/{{EscapePound .TreePath}}{{end}}">{{.i18n.Tr "repo.cancel_lower"}}</a></span>
|
||||
<span>{{.i18n.Tr "repo.editor.or"}} <a href="{{EscapePound $.BranchLink}}{{if not .IsNewFile}}/{{EscapePound .TreePath}}{{end}}">{{.i18n.Tr "repo.editor.cancel_lower"}}</a></span>
|
||||
<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<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"><i class="octicon octicon-code"></i> {{if .IsNewFile}}{{.i18n.Tr "repo.new_file"}}{{else}}{{.i18n.Tr "repo.edit_file"}}{{end}}</a>
|
||||
<a class="active item" data-tab="write"><i class="octicon octicon-code"></i> {{if .IsNewFile}}{{.i18n.Tr "repo.editor.new_file"}}{{else}}{{.i18n.Tr "repo.editor.edit_file"}}{{end}}</a>
|
||||
{{if not .IsNewFile}}
|
||||
<a class="item" data-tab="preview" data-url="{{AppSubUrl}}/api/v1/markdown" data-context="{{.RepoLink}}" data-preview-file-modes="{{.PreviewableFileModes}}"><i class="octicon octicon-eye"></i> {{.i18n.Tr "repo.release.preview"}}</a>
|
||||
<a class="item" data-tab="diff" data-url="{{.RepoLink}}/_preview/{{.BranchName}}/{{.TreePath}}" data-context="{{.BranchLink}}"><i class="octicon octicon-diff"></i> {{.i18n.Tr "repo.preview_changes"}}</a>
|
||||
<a class="item" data-tab="diff" data-url="{{.RepoLink}}/_preview/{{.BranchName}}/{{.TreePath}}" data-context="{{.BranchLink}}"><i class="octicon octicon-diff"></i> {{.i18n.Tr "repo.editor.preview_changes"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
<div class="ui bottom attached active tab segment" data-tab="write">
|
||||
|
|
|
@ -57,7 +57,7 @@
|
|||
{{else}}
|
||||
{{template "repo/issue/new_form" .}}
|
||||
{{template "repo/commits_table" .}}
|
||||
{{template "repo/diff_box" .}}
|
||||
{{template "repo/diff/box" .}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
{{template "repo/issue/view_title" .}}
|
||||
{{template "repo/pulls/tab_menu" .}}
|
||||
<div class="ui bottom attached tab pull segment active">
|
||||
{{template "repo/diff_box" .}}
|
||||
{{template "repo/diff/box" .}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue