Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Upstream
Gitea
Commits
6e171c52
Commit
6e171c52
authored
8 years ago
by
Unknwon
Browse files
Options
Download
Email Patches
Plain Diff
Web editor: improve edit file tooltip
parent
f0b5c3b9
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
conf/locale/locale_en-US.ini
+4
-4
conf/locale/locale_en-US.ini
modules/bindata/bindata.go
+2
-2
modules/bindata/bindata.go
routers/repo/view.go
+39
-53
routers/repo/view.go
templates/repo/view_file.tmpl
+7
-7
templates/repo/view_file.tmpl
templates/repo/view_list.tmpl
+1
-1
templates/repo/view_list.tmpl
with
53 additions
and
67 deletions
+53
-67
conf/locale/locale_en-US.ini
View file @
6e171c52
...
...
@@ -436,17 +436,17 @@ commit_changes = Commit Changes
default_commit_message
=
Add an optional extended description...
last_commit_info
=
%s edited this file %s
delete_this_file
=
Delete this file
edit_this_file
=
Edit this file
edit_file
=
Edit file
delete_confirm_message
=
Are you sure you want to delete this file?
delete_commit_message
=
Write a note about this delete (optional)
unable_to_update_file
=
Unable to update this file, error occurred
must_be_on_branch
=
You must be on a branch to make or propose changes to this file
must_be_writer
=
You must have write access to make or propose changes to this file
cannot_edit_binary_files
=
Cannot edit binary files
filename_help
=
To add directory, just type it and press /. To remove a directory, go to the beginning of the field and press backspace.
fork_before_edit
=
You must fork this before editing
new_branch
=
new branch
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
editor.fork_before_edit
=
You must fork this repository before editing the file
editor.file_delete_success
=
File '%s' has been deleted successfully!
editor.commit_directly_to_this_branch
=
Commit directly to the <strong class="branch-name">%s</strong> branch.
editor.create_new_branch
=
Create a <strong>new branch</strong> for this commit and start a pull request.
...
...
This diff is collapsed.
Click to expand it.
modules/bindata/bindata.go
View file @
6e171c52
This diff is collapsed.
Click to expand it.
routers/repo/view.go
View file @
6e171c52
...
...
@@ -24,7 +24,6 @@ import (
"github.com/gogits/gogs/modules/setting"
"github.com/gogits/gogs/modules/template"
"github.com/gogits/gogs/modules/template/highlight"
"strconv"
)
const
(
...
...
@@ -46,33 +45,18 @@ func Home(ctx *context.Context) {
userName
:=
ctx
.
Repo
.
Owner
.
Name
repoName
:=
ctx
.
Repo
.
Repository
.
Name
repoLink
:=
ctx
.
Repo
.
RepoLink
branchLink
:=
ctx
.
Repo
.
RepoLink
+
"/src/"
+
branchName
treeLink
:=
branchLink
rawLink
:=
ctx
.
Repo
.
RepoLink
+
"/raw/"
+
branchName
editLink
:=
ctx
.
Repo
.
RepoLink
+
"/_edit/"
+
branchName
newFileLink
:=
ctx
.
Repo
.
RepoLink
+
"/_new/"
+
branchName
forkLink
:=
setting
.
AppSubUrl
+
"/repo/fork/"
+
strconv
.
FormatInt
(
ctx
.
Repo
.
Repository
.
ID
,
10
)
uploadFileLink
:=
ctx
.
Repo
.
RepoLink
+
"/upload/"
+
branchName
// newFileLink := ctx.Repo.RepoLink + "/_new/" + branchName
// uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
// Get tree path
treename
:=
ctx
.
Repo
.
TreePath
if
len
(
treename
)
>
0
{
if
treename
[
len
(
treename
)
-
1
]
==
'/'
{
ctx
.
Redirect
(
repoLink
+
"/src/"
+
branchName
+
"/"
+
treename
[
:
len
(
treename
)
-
1
])
return
}
treeLink
+=
"/"
+
treename
}
treePath
:=
treename
if
len
(
treePath
)
!=
0
{
treePath
=
treePath
+
"/"
treePath
:=
ctx
.
Repo
.
TreePath
if
len
(
treePath
)
>
0
{
treeLink
+=
"/"
+
treePath
}
entry
,
err
:=
ctx
.
Repo
.
Commit
.
GetTreeEntryByPath
(
tree
name
)
entry
,
err
:=
ctx
.
Repo
.
Commit
.
GetTreeEntryByPath
(
tree
Path
)
if
err
!=
nil
{
if
git
.
IsErrNotExist
(
err
)
{
ctx
.
Handle
(
404
,
"GetTreeEntryByPath"
,
err
)
...
...
@@ -94,7 +78,7 @@ func Home(ctx *context.Context) {
ctx
.
Data
[
"IsFile"
]
=
true
ctx
.
Data
[
"FileName"
]
=
blob
.
Name
()
ctx
.
Data
[
"HighlightClass"
]
=
highlight
.
FileNameToHighlightClass
(
blob
.
Name
())
ctx
.
Data
[
"FileLink"
]
=
rawLink
+
"/"
+
tree
name
ctx
.
Data
[
"FileLink"
]
=
rawLink
+
"/"
+
tree
Path
buf
:=
make
([]
byte
,
1024
)
n
,
_
:=
dataRc
.
Read
(
buf
)
...
...
@@ -107,25 +91,30 @@ func Home(ctx *context.Context) {
_
,
isPDFFile
:=
base
.
IsPDFFile
(
buf
)
ctx
.
Data
[
"IsFileText"
]
=
isTextFile
// Assume file is not editable first.
if
!
isTextFile
{
ctx
.
Data
[
"EditFileTooltip"
]
=
ctx
.
Tr
(
"repo.editor.cannot_edit_non_text_files"
)
}
switch
{
case
isPDFFile
:
ctx
.
Data
[
"IsPDFFile"
]
=
true
ctx
.
Data
[
"FileEditLinkTooltip"
]
=
ctx
.
Tr
(
"repo.cannot_edit_binary_files"
)
case
isImageFile
:
ctx
.
Data
[
"IsImageFile"
]
=
true
ctx
.
Data
[
"FileEditLinkTooltip"
]
=
ctx
.
Tr
(
"repo.cannot_edit_binary_files"
)
case
isTextFile
:
if
blob
.
Size
()
>=
setting
.
UI
.
MaxDisplayFileSize
{
ctx
.
Data
[
"IsFileTooLarge"
]
=
true
}
else
{
ctx
.
Data
[
"IsFileTooLarge"
]
=
false
d
,
_
:=
ioutil
.
ReadAll
(
dataRc
)
buf
=
append
(
buf
,
d
...
)
readmeExist
:=
markdown
.
IsMarkdownFile
(
blob
.
Name
())
||
markdown
.
IsReadmeFile
(
blob
.
Name
())
isMarkdown
:=
readmeExist
||
markdown
.
IsMarkdownFile
(
blob
.
Name
())
ctx
.
Data
[
"ReadmeExist"
]
=
readmeExist
isMarkdown
:=
markdown
.
IsMarkdownFile
(
blob
.
Name
())
ctx
.
Data
[
"IsMarkdown"
]
=
isMarkdown
if
isMarkdown
{
readmeExist
:=
isMarkdown
||
markdown
.
IsReadmeFile
(
blob
.
Name
())
ctx
.
Data
[
"ReadmeExist"
]
=
readmeExist
if
readmeExist
{
// TODO: don't need to render if it's a README but not Markdown file.
ctx
.
Data
[
"FileContent"
]
=
string
(
markdown
.
Render
(
buf
,
path
.
Dir
(
treeLink
),
ctx
.
Repo
.
Repository
.
ComposeMetas
()))
}
else
{
// Building code view blocks with line number on server side.
...
...
@@ -153,22 +142,19 @@ func Home(ctx *context.Context) {
ctx
.
Data
[
"LineNums"
]
=
gotemplate
.
HTML
(
output
.
String
())
}
}
if
ctx
.
Repo
.
IsWriter
()
&&
ctx
.
Repo
.
IsViewBranch
{
ctx
.
Data
[
"FileEditLink"
]
=
editLink
+
"/"
+
treename
ctx
.
Data
[
"FileEditLinkTooltip"
]
=
ctx
.
Tr
(
"repo.edit_this_file"
)
}
else
{
if
!
ctx
.
Repo
.
IsViewBranch
{
ctx
.
Data
[
"FileEditLinkTooltip"
]
=
ctx
.
Tr
(
"repo.must_be_on_branch"
)
}
else
if
!
ctx
.
Repo
.
IsWriter
()
{
ctx
.
Data
[
"FileEditLink"
]
=
forkLink
ctx
.
Data
[
"FileEditLinkTooltip"
]
=
ctx
.
Tr
(
"repo.fork_before_edit"
)
}
ctx
.
Data
[
"CanEditFile"
]
=
true
ctx
.
Data
[
"EditFileTooltip"
]
=
ctx
.
Tr
(
"repo.editor.edit_this_file"
)
}
else
if
!
ctx
.
Repo
.
IsViewBranch
{
ctx
.
Data
[
"EditFileTooltip"
]
=
ctx
.
Tr
(
"repo.editor.must_be_on_a_branch"
)
}
else
if
!
ctx
.
Repo
.
IsWriter
()
{
ctx
.
Data
[
"EditFileTooltip"
]
=
ctx
.
Tr
(
"repo.editor.fork_before_edit"
)
}
default
:
ctx
.
Data
[
"FileEditLinkTooltip"
]
=
ctx
.
Tr
(
"repo.cannot_edit_binary_files"
)
}
if
ctx
.
Repo
.
IsWriter
()
&&
ctx
.
Repo
.
IsViewBranch
{
ctx
.
Data
[
"CanDeleteFile"
]
=
true
ctx
.
Data
[
"FileDeleteLinkTooltip"
]
=
ctx
.
Tr
(
"repo.delete_this_file"
)
}
else
{
if
!
ctx
.
Repo
.
IsViewBranch
{
...
...
@@ -180,7 +166,7 @@ func Home(ctx *context.Context) {
}
else
{
// Directory and file list.
tree
,
err
:=
ctx
.
Repo
.
Commit
.
SubTree
(
tree
name
)
tree
,
err
:=
ctx
.
Repo
.
Commit
.
SubTree
(
tree
Path
)
if
err
!=
nil
{
ctx
.
Handle
(
404
,
"SubTree"
,
err
)
return
...
...
@@ -224,7 +210,7 @@ func Home(ctx *context.Context) {
}
ctx
.
Data
[
"FileSize"
]
=
readmeFile
.
Size
()
ctx
.
Data
[
"FileLink"
]
=
rawLink
+
"/"
+
tree
name
ctx
.
Data
[
"FileLink"
]
=
rawLink
+
"/"
+
tree
Path
_
,
isTextFile
:=
base
.
IsTextFile
(
buf
)
ctx
.
Data
[
"FileIsText"
]
=
isTextFile
ctx
.
Data
[
"FileName"
]
=
readmeFile
.
Name
()
...
...
@@ -254,12 +240,12 @@ func Home(ctx *context.Context) {
}
ctx
.
Data
[
"LastCommit"
]
=
lastCommit
ctx
.
Data
[
"LastCommitUser"
]
=
models
.
ValidateCommitWithEmail
(
lastCommit
)
if
ctx
.
Repo
.
IsWriter
()
&&
ctx
.
Repo
.
IsViewBranch
{
ctx
.
Data
[
"NewFileLink"
]
=
newFileLink
+
"/"
+
tree
name
if
setting
.
Repository
.
Upload
.
Enabled
{
ctx
.
Data
[
"UploadFileLink"
]
=
uploadFileLink
+
"/"
+
tree
name
}
}
//
if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch {
//
ctx.Data["NewFileLink"] = newFileLink + "/" + tree
Path
//
if setting.Repository.Upload.Enabled {
//
ctx.Data["UploadFileLink"] = uploadFileLink + "/" + tree
Path
//
}
//
}
}
ctx
.
Data
[
"Username"
]
=
userName
...
...
@@ -274,8 +260,8 @@ func Home(ctx *context.Context) {
var
treenames
[]
string
paths
:=
make
([]
string
,
0
)
if
len
(
tree
name
)
>
0
{
treenames
=
strings
.
Split
(
tree
name
,
"/"
)
if
len
(
tree
Path
)
>
0
{
treenames
=
strings
.
Split
(
tree
Path
,
"/"
)
for
i
:=
range
treenames
{
paths
=
append
(
paths
,
strings
.
Join
(
treenames
[
0
:
i
+
1
],
"/"
))
}
...
...
@@ -287,9 +273,9 @@ func Home(ctx *context.Context) {
}
ctx
.
Data
[
"Paths"
]
=
paths
ctx
.
Data
[
"TreeName"
]
=
treename
ctx
.
Data
[
"Treenames"
]
=
treenames
ctx
.
Data
[
"TreePath"
]
=
treePath
ctx
.
Data
[
"TreeLink"
]
=
treeLink
ctx
.
Data
[
"Treenames"
]
=
treenames
ctx
.
Data
[
"BranchLink"
]
=
branchLink
ctx
.
HTML
(
200
,
HOME
)
}
...
...
This diff is collapsed.
Click to expand it.
templates/repo/view_file.tmpl
View file @
6e171c52
...
...
@@ -15,18 +15,18 @@
<div class="ui right file-actions">
<div class="ui buttons">
{{if not .IsViewCommit}}
<a class="ui button" href="{{.RepoLink}}/src/{{.CommitID}}/{{EscapePound .Tree
Name
}}">{{.i18n.Tr "repo.file_permalink"}}</a>
<a class="ui button" href="{{.RepoLink}}/src/{{.CommitID}}/{{EscapePound .Tree
Path
}}">{{.i18n.Tr "repo.file_permalink"}}</a>
{{end}}
<a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{EscapePound .Tree
Name
}}">{{.i18n.Tr "repo.file_history"}}</a>
<a class="ui button" href="{{.RepoLink}}/commits/{{EscapePound .BranchName}}/{{EscapePound .Tree
Path
}}">{{.i18n.Tr "repo.file_history"}}</a>
<a class="ui button" href="{{EscapePound .FileLink}}">{{.i18n.Tr "repo.file_raw"}}</a>
</div>
{{if .
FileEditLink
}}
<a href="{{
EscapePound $.FileEditLink
}}"><i class="poping up octicon octicon-pencil btn-octicon" data-content="{{.File
EditLink
Tooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
{{if .
CanEditFile
}}
<a href="{{
.RepoLink}}/_edit/{{EscapePound .BranchName}}/{{EscapePound .TreePath
}}"><i class="poping up octicon octicon-pencil btn-octicon" data-content="{{.
Edit
FileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
{{else}}
<i class="octicon btn-octicon octicon-pencil poping up disabled" data-content="{{.File
EditLink
Tooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
<i class="octicon btn-octicon octicon-pencil poping up disabled" data-content="{{.
Edit
FileTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
{{end}}
{{if
and .IsViewBranch .IsRepositoryWriter
}}
<form id="delete-file-form" class="ui form inline-form" action="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{.Tree
Name
}}" method="post">
{{if
.CanDeleteFile
}}
<form id="delete-file-form" class="ui form inline-form" action="{{.RepoLink}}/_delete/{{EscapePound .BranchName}}/{{.Tree
Path
}}" method="post">
{{.CsrfTokenHtml}}
<button onclick="submitDeleteForm()" class="octicon octicon-trashcan btn-octicon btn-octicon-danger poping up" type="button" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></button>
<input type="hidden" id="delete-message" name="commit_message" value="">
...
...
This diff is collapsed.
Click to expand it.
templates/repo/view_list.tmpl
View file @
6e171c52
...
...
@@ -40,7 +40,7 @@
{{else}}
<td class="name">
<span class="octicon octicon-file-{{if or $entry.IsDir}}directory{{else}}text{{end}}"></span>
<a href="{{EscapePound $.
Branch
Link}}/{{EscapePound
$.TreePath}}{{EscapePound
$entry.Name}}">{{$entry.Name}}</a>
<a href="{{EscapePound $.
Tree
Link}}/{{EscapePound $entry.Name}}">{{$entry.Name}}</a>
</td>
{{end}}
<td class="message collapsing has-emoji">
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment