Browse Source

Update for using CodeMirror mode addon

pull/3287/head
Richard Mahn 9 years ago
parent
commit
bb57912558
  1. 4
      public/css/gogs.css
  2. 1
      public/js/gogs.js
  3. 12
      routers/repo/view.go
  4. 9
      templates/base/head.tmpl
  5. 1
      templates/repo/edit.tmpl
  6. 4
      templates/repo/view_file.tmpl

4
public/css/gogs.css

@ -2728,6 +2728,10 @@ footer .ui.language .menu {
.btn-octicon-danger:hover { .btn-octicon-danger:hover {
color: #bd2c00; color: #bd2c00;
} }
.btn-octicon.disabled {
color: #bbb;
cursor: default;
}
.inline-form { .inline-form {
display: inline-block; display: inline-block;
} }

1
public/js/gogs.js

@ -694,7 +694,6 @@ function initEditor() {
if (!editArea.length) if (!editArea.length)
return; return;
CodeMirror.modeURL = editArea.data("mode-url");
mdFileExtensions = editArea.data("md-file-extensions").split(","); mdFileExtensions = editArea.data("md-file-extensions").split(",");
lineWrapExtensions = editArea.data("line-wrap-extensions").split(","); lineWrapExtensions = editArea.data("line-wrap-extensions").split(",");

12
routers/repo/view.go

@ -50,6 +50,7 @@ func Home(ctx *context.Context) {
treeLink := branchLink treeLink := branchLink
rawLink := ctx.Repo.RepoLink + "/raw/" + branchName rawLink := ctx.Repo.RepoLink + "/raw/" + branchName
editLink := ctx.Repo.RepoLink + "/edit/" + 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) forkLink := setting.AppSubUrl + "/repo/fork/" + strconv.FormatInt(ctx.Repo.Repository.ID, 10)
newFileLink := ctx.Repo.RepoLink + "/new/" + branchName newFileLink := ctx.Repo.RepoLink + "/new/" + branchName
uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName uploadFileLink := ctx.Repo.RepoLink + "/upload/" + branchName
@ -150,7 +151,16 @@ func Home(ctx *context.Context) {
default: default:
ctx.Data["FileEditLinkTooltip"] = ctx.Tr("repo.cannot_edit_binary_files") 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 { } else {
// Directory and file list. // Directory and file list.

9
templates/base/head.tmpl

@ -24,8 +24,13 @@
{{if .RequireSimpleMDE}} {{if .RequireSimpleMDE}}
<link rel="stylesheet" href="{{AppSubUrl}}/plugins/simplemde-1.10.1/simplemde.min.css"> <link rel="stylesheet" href="{{AppSubUrl}}/plugins/simplemde-1.10.1/simplemde.min.css">
<script src="{{AppSubUrl}}/plugins/simplemde-1.10.1/simplemde.min.js"></script> <script src="{{AppSubUrl}}/plugins/simplemde-1.10.1/simplemde.min.js"></script>
<script src="{{AppSubUrl}}/plugins/simplemde-1.10.1/loadmode.js"></script> <script src="{{AppSubUrl}}/plugins/codemirror-5.17.0/addon/mode/loadmode.js"></script>
<script src="{{AppSubUrl}}/plugins/simplemde-1.10.1/mode/meta.js"></script> <script src="{{AppSubUrl}}/plugins/codemirror-5.17.0/mode/meta.js"></script>
<script>
$(document).ready(function(){
CodeMirror.modeURL = "{{AppSubUrl}}/plugins/codemirror-5.17.0/mode/%N/%N.js";
});
</script>
{{end}} {{end}}
<!-- Stylesheet --> <!-- Stylesheet -->

1
templates/repo/edit.tmpl

@ -37,7 +37,6 @@
<textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreeName}}" <textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreeName}}"
data-url="{{AppSubUrl}}/api/v1/markdown" data-url="{{AppSubUrl}}/api/v1/markdown"
data-context="{{.RepoLink}}" data-context="{{.RepoLink}}"
data-mode-url="{{AppSubUrl}}/plugins/simplemde/mode/%N/%N.js"
data-md-file-extensions="{{.MdFileExtensions}}" data-md-file-extensions="{{.MdFileExtensions}}"
data-line-wrap-extensions="{{.LineWrapExtensions}}"> data-line-wrap-extensions="{{.LineWrapExtensions}}">
{{.FileContent}}</textarea required> {{.FileContent}}</textarea required>

4
templates/repo/view_file.tmpl

@ -23,7 +23,7 @@
{{if .FileEditLink}} {{if .FileEditLink}}
<a href="{{EscapePound $.FileEditLink}}"><i class="poping up octicon octicon-pencil btn-octicon" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a> <a href="{{EscapePound $.FileEditLink}}"><i class="poping up octicon octicon-pencil btn-octicon" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i></a>
{{else}} {{else}}
<i class="icon octicon octicon-pencil poping up disabled" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i> <i class="octicon btn-octicon octicon-pencil poping up disabled" data-content="{{.FileEditLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
{{end}} {{end}}
{{if .FileDeleteLink}} {{if .FileDeleteLink}}
<form id="delete-file-form" class="ui form inline-form" action="{{EscapePound $.FileDeleteLink}}" method="post"> <form id="delete-file-form" class="ui form inline-form" action="{{EscapePound $.FileDeleteLink}}" method="post">
@ -32,7 +32,7 @@
<input type="hidden" id="delete-message" name="commit_message" value=""> <input type="hidden" id="delete-message" name="commit_message" value="">
</form> </form>
{{else}} {{else}}
<i class="icon octicon octicon-trashcan poping up disabled" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i> <i class="octicon btn-octicon octicon-trashcan poping up disabled" data-content="{{.FileDeleteLinkTooltip}}" data-position="bottom center" data-variation="tiny inverted"></i>
{{end}} {{end}}
</div> </div>
{{end}} {{end}}

Loading…
Cancel
Save