Browse Source

repo/settings: improve Git hook editor

pull/3422/merge
Unknwon 8 years ago
parent
commit
e1dcd11051
No known key found for this signature in database
GPG Key ID: 25B575AE3213B2B3
  1. 3
      routers/repo/setting.go
  2. 12
      templates/repo/settings/githook_edit.tmpl

3
routers/repo/setting.go

@ -499,6 +499,7 @@ func SettingsGitHooks(ctx *context.Context) {
func SettingsGitHooksEdit(ctx *context.Context) { func SettingsGitHooksEdit(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings.githooks") ctx.Data["Title"] = ctx.Tr("repo.settings.githooks")
ctx.Data["PageIsSettingsGitHooks"] = true ctx.Data["PageIsSettingsGitHooks"] = true
ctx.Data["RequireSimpleMDE"] = true
name := ctx.Params(":name") name := ctx.Params(":name")
hook, err := ctx.Repo.GitRepo.GetHook(name) hook, err := ctx.Repo.GitRepo.GetHook(name)
@ -530,7 +531,7 @@ func SettingsGitHooksEditPost(ctx *context.Context) {
ctx.Handle(500, "hook.Update", err) ctx.Handle(500, "hook.Update", err)
return return
} }
ctx.Redirect(ctx.Repo.RepoLink + "/settings/hooks/git") ctx.Redirect(ctx.Data["Link"].(string))
} }
func SettingsDeployKeys(ctx *context.Context) { func SettingsDeployKeys(ctx *context.Context) {

12
templates/repo/settings/githook_edit.tmpl

@ -16,11 +16,11 @@
{{with .Hook}} {{with .Hook}}
<div class="inline field"> <div class="inline field">
<label>{{$.i18n.Tr "repo.settings.githook_name"}}</label> <label>{{$.i18n.Tr "repo.settings.githook_name"}}</label>
<span>{{.Name}}</span> <span><code>{{.Name}}</code></span>
</div> </div>
<div class="field"> <div class="field">
<label for="content">{{$.i18n.Tr "repo.settings.githook_content"}}</label> <label for="content">{{$.i18n.Tr "repo.settings.githook_content"}}</label>
<textarea id="content" name="content" rows="20" wrap="off" autofocus>{{if .IsActive}}{{.Content}}{{else}}{{.Sample}}{{end}}</textarea> <textarea id="content" name="content" wrap="off" autofocus>{{if .IsActive}}{{.Content}}{{else}}{{.Sample}}{{end}}</textarea>
</div> </div>
<div class="inline field"> <div class="inline field">
@ -33,4 +33,12 @@
</div> </div>
</div> </div>
</div> </div>
<script>
CodeMirror.autoLoadMode(CodeMirror.fromTextArea($('#content')[0], {
lineNumbers: true,
mode: 'shell'
}), "shell");
</script>
{{template "base/footer" .}} {{template "base/footer" .}}

Loading…
Cancel
Save