Browse Source

Web editor: improve code quality

Unknwon 3 years ago
parent
commit
f8a48ffaad

+ 1 - 1
README.md

@@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
3 3
 
4 4
 ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
5 5
 
6
-##### Current tip version: 0.9.84 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
6
+##### Current tip version: 0.9.85 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
7 7
 
8 8
 | Web | UI  | Preview  |
9 9
 |:-------------:|:-------:|:-------:|

+ 1 - 0
conf/locale/locale_en-US.ini

@@ -447,6 +447,7 @@ cannot_edit_binary_files = Cannot edit binary files
447 447
 filename_help = To add directory, just type it and press /. To remove a directory, go to the beginning of the field and press backspace.
448 448
 fork_before_edit = You must fork this before editing
449 449
 new_branch = new branch
450
+editor.file_delete_success = File '%s' has been deleted successfully!
450 451
 editor.commit_directly_to_this_branch = Commit directly to the <strong class="branch-name">%s</strong> branch.
451 452
 editor.create_new_branch = Create a <strong>new branch</strong> for this commit and start a pull request.
452 453
 editor.filename_cannot_be_empty = Filename cannot be empty.

+ 1 - 1
gogs.go

@@ -17,7 +17,7 @@ import (
17 17
 	"github.com/gogits/gogs/modules/setting"
18 18
 )
19 19
 
20
-const APP_VER = "0.9.84.0824"
20
+const APP_VER = "0.9.85.0824"
21 21
 
22 22
 func init() {
23 23
 	runtime.GOMAXPROCS(runtime.NumCPU())

+ 3 - 3
models/repo.go

@@ -2260,7 +2260,7 @@ func (repo *Repository) GetForks() ([]*Repository, error) {
2260 2260
 //
2261 2261
 
2262 2262
 // uploadRepoFiles uploads new files to repository.
2263
-func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, treeName, message string, uuids []string) (err error) {
2263
+func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, treePath, message string, uuids []string) (err error) {
2264 2264
 	repoWorkingPool.CheckIn(com.ToStr(repo.ID))
2265 2265
 	defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
2266 2266
 
@@ -2276,7 +2276,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
2276 2276
 		repo.CheckoutNewBranch(oldBranchName, branchName)
2277 2277
 	}
2278 2278
 
2279
-	dirPath := path.Join(localPath, treeName)
2279
+	dirPath := path.Join(localPath, treePath)
2280 2280
 	os.MkdirAll(dirPath, os.ModePerm)
2281 2281
 
2282 2282
 	// Copy uploaded files into repository.
@@ -2298,7 +2298,7 @@ func (repo *Repository) UploadRepoFiles(doer *User, oldBranchName, branchName, t
2298 2298
 	}
2299 2299
 
2300 2300
 	if len(message) == 0 {
2301
-		message = "Add files to '" + treeName + "'"
2301
+		message = "Add files to '" + treePath + "'"
2302 2302
 	}
2303 2303
 
2304 2304
 	if err = git.AddChanges(localPath, true); err != nil {

+ 3 - 3
models/repo_editor.go

@@ -173,7 +173,7 @@ func (repo *Repository) UpdateRepoFile(doer *User, opts UpdateRepoFileOptions) (
173 173
 }
174 174
 
175 175
 // GetDiffPreview produces and returns diff result of a file which is not yet committed.
176
-func (repo *Repository) GetDiffPreview(branch, treeName, content string) (diff *Diff, err error) {
176
+func (repo *Repository) GetDiffPreview(branch, treePath, content string) (diff *Diff, err error) {
177 177
 	repoWorkingPool.CheckIn(com.ToStr(repo.ID))
178 178
 	defer repoWorkingPool.CheckOut(com.ToStr(repo.ID))
179 179
 
@@ -184,13 +184,13 @@ func (repo *Repository) GetDiffPreview(branch, treeName, content string) (diff *
184 184
 	}
185 185
 
186 186
 	localPath := repo.LocalCopyPath()
187
-	filePath := path.Join(localPath, treeName)
187
+	filePath := path.Join(localPath, treePath)
188 188
 	os.MkdirAll(filepath.Dir(filePath), os.ModePerm)
189 189
 	if err = ioutil.WriteFile(filePath, []byte(content), 0666); err != nil {
190 190
 		return nil, fmt.Errorf("WriteFile: %v", err)
191 191
 	}
192 192
 
193
-	cmd := exec.Command("git", "diff", treeName)
193
+	cmd := exec.Command("git", "diff", treePath)
194 194
 	cmd.Dir = localPath
195 195
 	cmd.Stderr = os.Stderr
196 196
 

+ 1 - 1
modules/auth/repo_form.go

@@ -278,7 +278,7 @@ func (f *NewWikiForm) Validate(ctx *macaron.Context, errs binding.Errors) bindin
278 278
 //         \/      \/
279 279
 
280 280
 type EditRepoFileForm struct {
281
-	TreeName      string `binding:"Required;MaxSize(500)"`
281
+	TreePath      string `binding:"Required;MaxSize(500)"`
282 282
 	Content       string `binding:"Required"`
283 283
 	CommitSummary string `binding:"MaxSize(100)`
284 284
 	CommitMessage string

File diff suppressed because it is too large
+ 2 - 2
modules/bindata/bindata.go


+ 4 - 4
modules/context/repo.go

@@ -41,14 +41,14 @@ type Repository struct {
41 41
 	GitRepo      *git.Repository
42 42
 	BranchName   string
43 43
 	TagName      string
44
-	TreeName     string
44
+	TreePath     string
45 45
 	CommitID     string
46 46
 	RepoLink     string
47 47
 	CloneLink    models.CloneLink
48 48
 	CommitsCount int64
49 49
 	Mirror       *models.Mirror
50 50
 
51
-	PullRequest *PullRequest
51
+	PullRequest  *PullRequest
52 52
 }
53 53
 
54 54
 // IsOwner returns true if current user is the owner of repository.
@@ -384,7 +384,7 @@ func RepoRef() macaron.Handler {
384 384
 				if ctx.Repo.GitRepo.IsBranchExist(refName) ||
385 385
 					ctx.Repo.GitRepo.IsTagExist(refName) {
386 386
 					if i < len(parts)-1 {
387
-						ctx.Repo.TreeName = strings.Join(parts[i+1:], "/")
387
+						ctx.Repo.TreePath = strings.Join(parts[i+1:], "/")
388 388
 					}
389 389
 					hasMatched = true
390 390
 					break
@@ -392,7 +392,7 @@ func RepoRef() macaron.Handler {
392 392
 			}
393 393
 			if !hasMatched && len(parts[0]) == 40 {
394 394
 				refName = parts[0]
395
-				ctx.Repo.TreeName = strings.Join(parts[1:], "/")
395
+				ctx.Repo.TreePath = strings.Join(parts[1:], "/")
396 396
 			}
397 397
 
398 398
 			if ctx.Repo.GitRepo.IsBranchExist(refName) {

+ 1 - 1
public/js/gogs.js

@@ -779,7 +779,7 @@ function initEditor() {
779 779
         });
780 780
         if ($(this).val())
781 781
             parts.push($(this).val());
782
-        $('#tree-name').val(parts.join('/'));
782
+        $('#tree_path').val(parts.join('/'));
783 783
     }).trigger('keyup');
784 784
 
785 785
     var $editArea = $('.repository.editor textarea#edit_area');

+ 1 - 1
routers/api/v1/repo/file.go

@@ -19,7 +19,7 @@ func GetRawFile(ctx *context.APIContext) {
19 19
 		return
20 20
 	}
21 21
 
22
-	blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreeName)
22
+	blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
23 23
 	if err != nil {
24 24
 		if git.IsErrNotExist(err) {
25 25
 			ctx.Status(404)

+ 3 - 3
routers/repo/commit.go

@@ -25,9 +25,9 @@ const (
25 25
 
26 26
 func RefCommits(ctx *context.Context) {
27 27
 	switch {
28
-	case len(ctx.Repo.TreeName) == 0:
28
+	case len(ctx.Repo.TreePath) == 0:
29 29
 		Commits(ctx)
30
-	case ctx.Repo.TreeName == "search":
30
+	case ctx.Repo.TreePath == "search":
31 31
 		SearchCommits(ctx)
32 32
 	default:
33 33
 		FileHistory(ctx)
@@ -104,7 +104,7 @@ func SearchCommits(ctx *context.Context) {
104 104
 func FileHistory(ctx *context.Context) {
105 105
 	ctx.Data["IsRepoToolbarCommits"] = true
106 106
 
107
-	fileName := ctx.Repo.TreeName
107
+	fileName := ctx.Repo.TreePath
108 108
 	if len(fileName) == 0 {
109 109
 		Commits(ctx)
110 110
 		return

+ 3 - 3
routers/repo/download.go

@@ -25,7 +25,7 @@ func ServeData(ctx *context.Context, name string, reader io.Reader) error {
25 25
 	if !isTextFile {
26 26
 		_, isImageFile := base.IsImageFile(buf)
27 27
 		if !isImageFile {
28
-			ctx.Resp.Header().Set("Content-Disposition", "attachment; filename=\""+path.Base(ctx.Repo.TreeName)+"\"")
28
+			ctx.Resp.Header().Set("Content-Disposition", "attachment; filename=\""+path.Base(ctx.Repo.TreePath)+"\"")
29 29
 			ctx.Resp.Header().Set("Content-Transfer-Encoding", "binary")
30 30
 		}
31 31
 	} else if !ctx.QueryBool("render") {
@@ -42,11 +42,11 @@ func ServeBlob(ctx *context.Context, blob *git.Blob) error {
42 42
 		return err
43 43
 	}
44 44
 
45
-	return ServeData(ctx, ctx.Repo.TreeName, dataRc)
45
+	return ServeData(ctx, ctx.Repo.TreePath, dataRc)
46 46
 }
47 47
 
48 48
 func SingleDownload(ctx *context.Context) {
49
-	blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreeName)
49
+	blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath)
50 50
 	if err != nil {
51 51
 		if git.IsErrNotExist(err) {
52 52
 			ctx.Handle(404, "GetBlobByPath", nil)

+ 35 - 37
routers/repo/editor.go

@@ -32,15 +32,14 @@ func editFile(ctx *context.Context, isNewFile bool) {
32 32
 	ctx.Data["RequireSimpleMDE"] = true
33 33
 
34 34
 	branchLink := ctx.Repo.RepoLink + "/src/" + ctx.Repo.BranchName
35
-	treeName := ctx.Repo.TreeName
36 35
 
37 36
 	var treeNames []string
38
-	if len(treeName) > 0 {
39
-		treeNames = strings.Split(treeName, "/")
37
+	if len(ctx.Repo.TreePath) > 0 {
38
+		treeNames = strings.Split(ctx.Repo.TreePath, "/")
40 39
 	}
41 40
 
42 41
 	if !isNewFile {
43
-		entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treeName)
42
+		entry, err := ctx.Repo.Commit.GetTreeEntryByPath(ctx.Repo.TreePath)
44 43
 		if err != nil {
45 44
 			if git.IsErrNotExist(err) {
46 45
 				ctx.Handle(404, "GetTreeEntryByPath", err)
@@ -83,7 +82,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
83 82
 		buf = append(buf, d...)
84 83
 		if err, content := template.ToUTF8WithErr(buf); err != nil {
85 84
 			if err != nil {
86
-				log.Error(4, "Convert content encoding: %s", err)
85
+				log.Error(4, "ToUTF8WithErr: %v", err)
87 86
 			}
88 87
 			ctx.Data["FileContent"] = string(buf)
89 88
 		} else {
@@ -93,7 +92,7 @@ func editFile(ctx *context.Context, isNewFile bool) {
93 92
 		treeNames = append(treeNames, "") // Append empty string to allow user name the new file.
94 93
 	}
95 94
 
96
-	ctx.Data["TreeName"] = treeName
95
+	ctx.Data["TreePath"] = ctx.Repo.TreePath
97 96
 	ctx.Data["TreeNames"] = treeNames
98 97
 	ctx.Data["BranchLink"] = branchLink
99 98
 	ctx.Data["commit_summary"] = ""
@@ -125,7 +124,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
125 124
 	oldBranchName := ctx.Repo.BranchName
126 125
 	branchName := oldBranchName
127 126
 	branchLink := ctx.Repo.RepoLink + "/src/" + branchName
128
-	oldTreeName := ctx.Repo.TreeName
127
+	oldTreePath := ctx.Repo.TreePath
129 128
 	content := form.Content
130 129
 	commitChoice := form.CommitChoice
131 130
 	lastCommit := form.LastCommit
@@ -135,16 +134,14 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
135 134
 		branchName = form.NewBranchName
136 135
 	}
137 136
 
138
-	treeName := form.TreeName
139
-	treeName = strings.Trim(treeName, " ")
140
-	treeName = strings.Trim(treeName, "/")
137
+	form.TreePath = strings.Trim(form.TreePath, " /")
141 138
 
142 139
 	var treeNames []string
143
-	if len(treeName) > 0 {
144
-		treeNames = strings.Split(treeName, "/")
140
+	if len(form.TreePath) > 0 {
141
+		treeNames = strings.Split(form.TreePath, "/")
145 142
 	}
146 143
 
147
-	ctx.Data["TreeName"] = treeName
144
+	ctx.Data["TreePath"] = form.TreePath
148 145
 	ctx.Data["TreeNames"] = treeNames
149 146
 	ctx.Data["BranchLink"] = branchLink
150 147
 	ctx.Data["FileContent"] = content
@@ -162,24 +159,24 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
162 159
 		return
163 160
 	}
164 161
 
165
-	if len(treeName) == 0 {
166
-		ctx.Data["Err_Filename"] = true
162
+	if len(form.TreePath) == 0 {
163
+		ctx.Data["Err_TreePath"] = true
167 164
 		ctx.RenderWithErr(ctx.Tr("repo.editor.filename_cannot_be_empty"), EDIT, &form)
168 165
 		return
169 166
 	}
170 167
 
171 168
 	if oldBranchName != branchName {
172 169
 		if _, err := ctx.Repo.Repository.GetBranch(branchName); err == nil {
173
-			ctx.Data["Err_Branchname"] = true
170
+			ctx.Data["Err_NewBranchName"] = true
174 171
 			ctx.RenderWithErr(ctx.Tr("repo.editor.branch_already_exists", branchName), EDIT, &form)
175 172
 			return
176 173
 		}
177 174
 	}
178 175
 
179
-	var treepath string
176
+	var newTreePath string
180 177
 	for index, part := range treeNames {
181
-		treepath = path.Join(treepath, part)
182
-		entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treepath)
178
+		newTreePath = path.Join(newTreePath, part)
179
+		entry, err := ctx.Repo.Commit.GetTreeEntryByPath(newTreePath)
183 180
 		if err != nil {
184 181
 			if git.IsErrNotExist(err) {
185 182
 				// Means there is no item with that name, so we're good
@@ -191,13 +188,13 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
191 188
 		}
192 189
 		if index != len(treeNames)-1 {
193 190
 			if !entry.IsDir() {
194
-				ctx.Data["Err_Filename"] = true
191
+				ctx.Data["Err_TreePath"] = true
195 192
 				ctx.RenderWithErr(ctx.Tr("repo.editor.directory_is_a_file", part), EDIT, &form)
196 193
 				return
197 194
 			}
198 195
 		} else {
199 196
 			if entry.IsDir() {
200
-				ctx.Data["Err_Filename"] = true
197
+				ctx.Data["Err_TreePath"] = true
201 198
 				ctx.RenderWithErr(ctx.Tr("repo.editor.filename_is_a_directory", part), EDIT, &form)
202 199
 				return
203 200
 			}
@@ -205,11 +202,11 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
205 202
 	}
206 203
 
207 204
 	if !isNewFile {
208
-		_, err := ctx.Repo.Commit.GetTreeEntryByPath(oldTreeName)
205
+		_, err := ctx.Repo.Commit.GetTreeEntryByPath(oldTreePath)
209 206
 		if err != nil {
210 207
 			if git.IsErrNotExist(err) {
211
-				ctx.Data["Err_Filename"] = true
212
-				ctx.RenderWithErr(ctx.Tr("repo.editor.file_editing_no_longer_exists", oldTreeName), EDIT, &form)
208
+				ctx.Data["Err_TreePath"] = true
209
+				ctx.RenderWithErr(ctx.Tr("repo.editor.file_editing_no_longer_exists", oldTreePath), EDIT, &form)
213 210
 			} else {
214 211
 				ctx.Handle(500, "GetTreeEntryByPath", err)
215 212
 			}
@@ -223,7 +220,7 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
223 220
 			}
224 221
 
225 222
 			for _, file := range files {
226
-				if file == treeName {
223
+				if file == form.TreePath {
227 224
 					ctx.RenderWithErr(ctx.Tr("repo.editor.file_changed_while_editing", ctx.Repo.RepoLink+"/compare/"+lastCommit+"..."+ctx.Repo.CommitID), EDIT, &form)
228 225
 					return
229 226
 				}
@@ -231,9 +228,9 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
231 228
 		}
232 229
 	}
233 230
 
234
-	if oldTreeName != treeName {
231
+	if oldTreePath != form.TreePath {
235 232
 		// We have a new filename (rename or completely new file) so we need to make sure it doesn't already exist, can't clobber.
236
-		entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treeName)
233
+		entry, err := ctx.Repo.Commit.GetTreeEntryByPath(form.TreePath)
237 234
 		if err != nil {
238 235
 			if !git.IsErrNotExist(err) {
239 236
 				ctx.Handle(500, "GetTreeEntryByPath", err)
@@ -241,8 +238,8 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
241 238
 			}
242 239
 		}
243 240
 		if entry != nil {
244
-			ctx.Data["Err_Filename"] = true
245
-			ctx.RenderWithErr(ctx.Tr("repo.editor.file_already_exists", treeName), EDIT, &form)
241
+			ctx.Data["Err_TreePath"] = true
242
+			ctx.RenderWithErr(ctx.Tr("repo.editor.file_already_exists", form.TreePath), EDIT, &form)
246 243
 			return
247 244
 		}
248 245
 	}
@@ -252,9 +249,9 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
252 249
 		message = strings.TrimSpace(form.CommitSummary)
253 250
 	} else {
254 251
 		if isNewFile {
255
-			message = ctx.Tr("repo.editor.add", treeName)
252
+			message = ctx.Tr("repo.editor.add", form.TreePath)
256 253
 		} else {
257
-			message = ctx.Tr("repo.editor.update", treeName)
254
+			message = ctx.Tr("repo.editor.update", form.TreePath)
258 255
 		}
259 256
 	}
260 257
 
@@ -267,18 +264,18 @@ func editFilePost(ctx *context.Context, form auth.EditRepoFileForm, isNewFile bo
267 264
 		LastCommitID: lastCommit,
268 265
 		OldBranch:    oldBranchName,
269 266
 		NewBranch:    branchName,
270
-		OldTreeName:  oldTreeName,
271
-		NewTreeName:  treeName,
267
+		OldTreeName:  oldTreePath,
268
+		NewTreeName:  form.TreePath,
272 269
 		Message:      message,
273 270
 		Content:      content,
274 271
 		IsNewFile:    isNewFile,
275 272
 	}); err != nil {
276
-		ctx.Data["Err_Filename"] = true
273
+		ctx.Data["Err_TreePath"] = true
277 274
 		ctx.RenderWithErr(ctx.Tr("repo.editor.failed_to_update_file", err), EDIT, &form)
278 275
 		return
279 276
 	}
280 277
 
281
-	ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + treeName)
278
+	ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + form.TreePath)
282 279
 }
283 280
 
284 281
 func EditFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
@@ -290,7 +287,7 @@ func NewFilePost(ctx *context.Context, form auth.EditRepoFileForm) {
290 287
 }
291 288
 
292 289
 func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
293
-	treeName := ctx.Repo.TreeName
290
+	treeName := ctx.Repo.TreePath
294 291
 	content := form.Content
295 292
 
296 293
 	entry, err := ctx.Repo.Commit.GetTreeEntryByPath(treeName)
@@ -325,7 +322,7 @@ func DiffPreviewPost(ctx *context.Context, form auth.EditPreviewDiffForm) {
325 322
 
326 323
 func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
327 324
 	branchName := ctx.Repo.BranchName
328
-	treeName := ctx.Repo.TreeName
325
+	treeName := ctx.Repo.TreePath
329 326
 
330 327
 	if ctx.HasError() {
331 328
 		ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName + "/" + treeName)
@@ -342,5 +339,6 @@ func DeleteFilePost(ctx *context.Context, form auth.DeleteRepoFileForm) {
342 339
 		return
343 340
 	}
344 341
 
342
+	ctx.Flash.Success(ctx.Tr("repo.editor.file_delete_success", treeName))
345 343
 	ctx.Redirect(ctx.Repo.RepoLink + "/src/" + branchName)
346 344
 }

+ 4 - 10
routers/repo/issue.go

@@ -331,6 +331,8 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleFiles
331 331
 func NewIssue(ctx *context.Context) {
332 332
 	ctx.Data["Title"] = ctx.Tr("repo.issues.new")
333 333
 	ctx.Data["PageIsIssueList"] = true
334
+	ctx.Data["RequireHighlightJS"] = true
335
+	ctx.Data["RequireSimpleMDE"] = true
334 336
 	setTemplateIfExists(ctx, ISSUE_TEMPLATE_KEY, IssueTemplateCandidates)
335 337
 	renderAttachmentSettings(ctx)
336 338
 
@@ -339,10 +341,6 @@ func NewIssue(ctx *context.Context) {
339 341
 		return
340 342
 	}
341 343
 
342
-	ctx.Data["RequireHighlightJS"] = true
343
-	ctx.Data["RequireSimpleMDE"] = true
344
-	ctx.Data["RepoName"] = ctx.Repo.Repository.Name
345
-
346 344
 	ctx.HTML(200, ISSUE_NEW)
347 345
 }
348 346
 
@@ -403,7 +401,6 @@ func ValidateRepoMetas(ctx *context.Context, form auth.CreateIssueForm) ([]int64
403 401
 func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
404 402
 	ctx.Data["Title"] = ctx.Tr("repo.issues.new")
405 403
 	ctx.Data["PageIsIssueList"] = true
406
-	ctx.Data["RepoName"] = ctx.Repo.Repository.Name
407 404
 	ctx.Data["RequireHighlightJS"] = true
408 405
 	ctx.Data["RequireSimpleMDE"] = true
409 406
 	renderAttachmentSettings(ctx)
@@ -493,6 +490,8 @@ func UploadIssueAttachment(ctx *context.Context) {
493 490
 }
494 491
 
495 492
 func ViewIssue(ctx *context.Context) {
493
+	ctx.Data["RequireHighlightJS"] = true
494
+	ctx.Data["RequireSimpleMDE"] = true
496 495
 	ctx.Data["RequireDropzone"] = true
497 496
 	renderAttachmentSettings(ctx)
498 497
 
@@ -637,11 +636,6 @@ func ViewIssue(ctx *context.Context) {
637 636
 	ctx.Data["Issue"] = issue
638 637
 	ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))
639 638
 	ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login?redirect_to=" + ctx.Data["Link"].(string)
640
-
641
-	ctx.Data["RequireHighlightJS"] = true
642
-	ctx.Data["RequireSimpleMDE"] = true
643
-	ctx.Data["RepoName"] = ctx.Repo.Repository.Name
644
-
645 639
 	ctx.HTML(200, ISSUE_VIEW)
646 640
 }
647 641
 

+ 1 - 1
routers/repo/upload.go

@@ -39,7 +39,7 @@ func UploadFile(ctx *context.Context) {
39 39
 	repoName := ctx.Repo.Repository.Name
40 40
 	branchName := ctx.Repo.BranchName
41 41
 	branchLink := ctx.Repo.RepoLink + "/src/" + branchName
42
-	treeName := ctx.Repo.TreeName
42
+	treeName := ctx.Repo.TreePath
43 43
 
44 44
 	treeNames := []string{""}
45 45
 	if len(treeName) > 0 {

+ 1 - 1
routers/repo/view.go

@@ -56,7 +56,7 @@ func Home(ctx *context.Context) {
56 56
 	uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
57 57
 
58 58
 	// Get tree path
59
-	treename := ctx.Repo.TreeName
59
+	treename := ctx.Repo.TreePath
60 60
 
61 61
 	if len(treename) > 0 {
62 62
 		if treename[len(treename)-1] == '/' {

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
1
-0.9.84.0824
1
+0.9.85.0824

+ 8 - 8
templates/repo/editor/edit.tmpl

@@ -8,7 +8,7 @@
8 8
 			<input type="hidden" name="last_commit" value="{{.last_commit}}">
9 9
 			<div class="ui secondary menu">
10 10
 				<div class="fitted item treepath">
11
-					<div class="ui breadcrumb field {{if .Err_Filename}}error{{end}}">
11
+					<div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}">
12 12
 						<a class="section" href="{{EscapePound $.BranchLink}}">{{.Repository.Name}}</a>
13 13
 						{{ $n := len .TreeNames}}
14 14
 						{{ $l := Subtract $n 1}}
@@ -22,8 +22,8 @@
22 22
 							{{end}}
23 23
 						{{end}}
24 24
 						<!-- <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> -->
25
-						<span class="repo-edit-file-cancel">{{.i18n.Tr "repo.or"}} <a href="{{EscapePound $.BranchLink}}{{if not .IsNewFile}}/{{EscapePound $.TreeName}}{{end}}">{{.i18n.Tr "repo.cancel_lower"}}</a></span>
26
-						<input type="hidden" id="tree-name" name="tree_name" value="{{.TreeName}}" required>
25
+						<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>
26
+						<input type="hidden" id="tree_path" name="tree_path" value="{{.TreePath}}" required>
27 27
 					</div>
28 28
 				</div>
29 29
 			</div>
@@ -32,11 +32,11 @@
32 32
 					<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>
33 33
 					{{if not .IsNewFile}}
34 34
 					<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>
35
-					<a class="item" data-tab="diff" data-url="{{.RepoLink}}/_preview/{{.BranchName}}/{{.TreeName}}" data-context="{{.BranchLink}}"><i class="octicon octicon-diff"></i> {{.i18n.Tr "repo.preview_changes"}}</a>
35
+					<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>
36 36
 					{{end}}
37 37
 				</div>
38 38
 				<div class="ui bottom attached active tab segment" data-tab="write">
39
-					<textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreeName}}"
39
+					<textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreePath}}"
40 40
 						data-url="{{AppSubUrl}}/api/v1/markdown"
41 41
 						data-context="{{.RepoLink}}"
42 42
 						data-markdown-file-exts="{{.MarkdownFileExts}}"
@@ -55,7 +55,7 @@
55 55
 				<div class="commit-form">
56 56
 					<h3>{{.i18n.Tr "repo.commit_changes"}}</h3>
57 57
 					<div class="field">
58
-						<input name="commit_summary" placeholder="{{if .IsNewFile}}{{.i18n.Tr "repo.add"}} '{{.TreeName}}/<filename>'{{else}}{{.i18n.Tr "repo.update"}} '{{.TreeName}}'{{end}}" value="{{.commit_summary}}">
58
+						<input name="commit_summary" placeholder="{{if .IsNewFile}}{{.i18n.Tr "repo.add"}} '{{.TreePath}}/<filename>'{{else}}{{.i18n.Tr "repo.update"}} '{{.TreePath}}'{{end}}" value="{{.commit_summary}}">
59 59
 					</div>
60 60
 					<div class="field">
61 61
 						<textarea name="commit_message" placeholder="{{.i18n.Tr "repo.default_commit_message"}}" rows="5">{{.commit_message}}</textarea>
@@ -80,7 +80,7 @@
80 80
 							</div>
81 81
 						</div>
82 82
 						<div class="quick-pull-branch-name {{if not (eq .commit_choice "commit-to-new-branch")}}hide{{end}}">
83
-							<div class="new-branch-name-input{{if .Err_Branchname}} error{{end}}">
83
+							<div class="new-branch-name-input{{if .Err_NewBranchName}} error{{end}}">
84 84
 								<i class="octicon octicon-git-branch" height="16" width="10"></i>
85 85
 								<input type="text" name="new_branch_name" value="{{.new_branch_name}}" class="form-control input-contrast mr-2 js-quick-pull-new-branch-name" placeholder="New branch name…">
86 86
 								<span class="text-muted js-quick-pull-normalization-info"></span>
@@ -91,7 +91,7 @@
91 91
 				<button type="submit" class="ui green button">
92 92
 					{{.i18n.Tr "repo.commit_changes"}}
93 93
 				</button>
94
-				<a class="ui button red" href="{{EscapePound $.BranchLink}}/{{EscapePound $.TreeName}}">{{.i18n.Tr "repo.cancel"}}</a>
94
+				<a class="ui button red" href="{{EscapePound $.BranchLink}}/{{EscapePound .TreePath}}">{{.i18n.Tr "repo.cancel"}}</a>
95 95
 			</div>
96 96
 		</form>
97 97
 	</div>

+ 1 - 0
templates/repo/home.tmpl

@@ -2,6 +2,7 @@
2 2
 <div class="repository file list">
3 3
 	{{template "repo/header" .}}
4 4
 	<div class="ui container">
5
+		{{template "base/alert" .}}
5 6
 		<p id="repo-desc">
6 7
 			{{if .Repository.DescriptionHtml}}<span class="description has-emoji">{{.Repository.DescriptionHtml}}</span>{{else}}<span class="no-description text-italic">{{.i18n.Tr "repo.no_desc"}}</span>{{end}}
7 8
 			<a class="link" href="{{.Repository.Website}}">{{.Repository.Website}}</a>