From b30d744e0986dcf716d4f57dac8c72a494bb226b Mon Sep 17 00:00:00 2001 From: Konctantin Date: Fri, 15 Nov 2019 09:56:06 +0300 Subject: [PATCH] Githook highlighter (#8932) * Add code highlighter to GitHook edit Signed-off-by: Konctantin * Fix indentation Signed-off-by: Konctantin * Resolve merge conflict Signed-off-by: gawrilyako@gmail.com * Resolve merge conflict Signed-off-by: gawrilyako@gmail.com * Fix pre-build drone event Signed-off-by: Konctantin --- routers/repo/setting.go | 1 + web_src/js/index.js | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/routers/repo/setting.go b/routers/repo/setting.go index fa215357d..a9f090d6d 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -707,6 +707,7 @@ func GitHooks(ctx *context.Context) { func GitHooksEdit(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("repo.settings.githooks") ctx.Data["PageIsSettingsGitHooks"] = true + ctx.Data["RequireSimpleMDE"] = true name := ctx.Params(":name") hook, err := ctx.Repo.GitRepo.GetHook(name) diff --git a/web_src/js/index.js b/web_src/js/index.js index 69d2aafcc..e25568d9b 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1499,6 +1499,17 @@ function initUserSettings() { } } +function initGithook() { + if ($('.edit.githook').length === 0) { + return; + } + + CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], { + lineNumbers: true, + mode: 'shell' + }), 'shell'); +} + function initWebhook() { if ($('.new.webhook').length === 0) { return; @@ -2296,6 +2307,7 @@ $(document).ready(() => { initEditForm(); initEditor(); initOrganization(); + initGithook(); initWebhook(); initAdmin(); initCodeView();