mirror of https://github.com/gogs/gogs.git
Update for using CodeMirror mode addon
parent
d10d128c51
commit
bb57912558
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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(",");
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -24,8 +24,13 @@
|
|||
{{if .RequireSimpleMDE}}
|
||||
<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/loadmode.js"></script>
|
||||
<script src="{{AppSubUrl}}/plugins/simplemde-1.10.1/mode/meta.js"></script>
|
||||
<script src="{{AppSubUrl}}/plugins/codemirror-5.17.0/addon/mode/loadmode.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}}
|
||||
|
||||
<!-- Stylesheet -->
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
<textarea id="edit_area" name="content" data-id="repo-{{.Repository.Name}}-{{.TreeName}}"
|
||||
data-url="{{AppSubUrl}}/api/v1/markdown"
|
||||
data-context="{{.RepoLink}}"
|
||||
data-mode-url="{{AppSubUrl}}/plugins/simplemde/mode/%N/%N.js"
|
||||
data-md-file-extensions="{{.MdFileExtensions}}"
|
||||
data-line-wrap-extensions="{{.LineWrapExtensions}}">
|
||||
{{.FileContent}}</textarea required>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
{{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>
|
||||
{{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}}
|
||||
{{if .FileDeleteLink}}
|
||||
<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="">
|
||||
</form>
|
||||
{{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}}
|
||||
</div>
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in New Issue