From bb5791255867a71c11a77b639db050ad09c597a4 Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Fri, 22 Jul 2016 14:02:18 -0600 Subject: [PATCH] Update for using CodeMirror mode addon --- public/css/gogs.css | 4 ++++ public/js/gogs.js | 1 - routers/repo/view.go | 12 +++++++++++- templates/base/head.tmpl | 9 +++++++-- templates/repo/edit.tmpl | 1 - templates/repo/view_file.tmpl | 4 ++-- 6 files changed, 24 insertions(+), 7 deletions(-) diff --git a/public/css/gogs.css b/public/css/gogs.css index 32bd795fa..f11d08ead 100644 --- a/public/css/gogs.css +++ b/public/css/gogs.css @@ -2728,6 +2728,10 @@ footer .ui.language .menu { .btn-octicon-danger:hover { color: #bd2c00; } +.btn-octicon.disabled { + color: #bbb; + cursor: default; +} .inline-form { display: inline-block; } diff --git a/public/js/gogs.js b/public/js/gogs.js index ff011034c..c1493a72b 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -694,7 +694,6 @@ function initEditor() { if (!editArea.length) return; - CodeMirror.modeURL = editArea.data("mode-url"); mdFileExtensions = editArea.data("md-file-extensions").split(","); lineWrapExtensions = editArea.data("line-wrap-extensions").split(","); diff --git a/routers/repo/view.go b/routers/repo/view.go index bf18abfca..c45d90ede 100644 --- a/routers/repo/view.go +++ b/routers/repo/view.go @@ -50,6 +50,7 @@ func Home(ctx *context.Context) { treeLink := branchLink rawLink := ctx.Repo.RepoLink + "/raw/" + branchName editLink := ctx.Repo.RepoLink + "/edit/" + branchName + deleteLink := ctx.Repo.RepoLink + "/delete/" + branchName forkLink := setting.AppSubUrl + "/repo/fork/" + strconv.FormatInt(ctx.Repo.Repository.ID, 10) newFileLink := ctx.Repo.RepoLink + "/new/" + branchName uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName @@ -150,7 +151,16 @@ func Home(ctx *context.Context) { default: ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.cannot_edit_binary_files") } - + if ctx.Repo.IsWriter() && ctx.Repo.IsViewBranch { + ctx.Data["FileDeleteLink"] = deleteLink + "/" + treename + ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.delete_this_file") + } else { + if ! ctx.Repo.IsViewBranch { + ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_on_branch") + } else if ! ctx.Repo.IsWriter() { + ctx.Data["FileDeleteLinkTooltip"] = ctx.Tr("repo.must_be_writer") + } + } } } else { // Directory and file list. diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 00f01c9ec..6ab493f2b 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -24,8 +24,13 @@ {{if .RequireSimpleMDE}} - - + + + {{end}} diff --git a/templates/repo/edit.tmpl b/templates/repo/edit.tmpl index 650496f58..ba75a988b 100644 --- a/templates/repo/edit.tmpl +++ b/templates/repo/edit.tmpl @@ -37,7 +37,6 @@ diff --git a/templates/repo/view_file.tmpl b/templates/repo/view_file.tmpl index cb60a6844..7133df052 100644 --- a/templates/repo/view_file.tmpl +++ b/templates/repo/view_file.tmpl @@ -23,7 +23,7 @@ {{if .FileEditLink}} {{else}} - + {{end}} {{if .FileDeleteLink}}
@@ -32,7 +32,7 @@
{{else}} - + {{end}} {{end}}