From 9a4050f1e839af1bd072aff9ac5fc69e650747c8 Mon Sep 17 00:00:00 2001 From: silverwind Date: Mon, 28 Dec 2020 19:30:06 +0100 Subject: [PATCH] Consolidate clone button templates (#14023) The four clone button templates are pretty much identical except the one in a non-empty repo had a few features which the others lacked. Consolidate them in a single shared template which also makes the JS that remembers protocol work on them all. Co-authored-by: techknowlogick --- templates/repo/clone_buttons.tmpl | 35 +++++++++++++++++++++++++++++++ templates/repo/empty.tmpl | 21 +------------------ templates/repo/home.tmpl | 35 +------------------------------ templates/repo/wiki/revision.tmpl | 23 ++------------------ templates/repo/wiki/view.tmpl | 21 +------------------ 5 files changed, 40 insertions(+), 95 deletions(-) create mode 100644 templates/repo/clone_buttons.tmpl diff --git a/templates/repo/clone_buttons.tmpl b/templates/repo/clone_buttons.tmpl new file mode 100644 index 000000000..92195283c --- /dev/null +++ b/templates/repo/clone_buttons.tmpl @@ -0,0 +1,35 @@ +{{if not $.DisableHTTP}} + +{{end}} +{{if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}} + +{{end}} +{{if not $.DisableHTTP}} + +{{else if and (not .DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}} + +{{end}} +{{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}} + +{{end}} +{{if not (and $.DisableHTTP $.DisableSSH)}} + +{{end}} diff --git a/templates/repo/empty.tmpl b/templates/repo/empty.tmpl index b5a39d0a9..7dae7c012 100644 --- a/templates/repo/empty.tmpl +++ b/templates/repo/empty.tmpl @@ -18,26 +18,7 @@

{{.i18n.Tr "repo.clone_this_repo"}} {{.i18n.Tr "repo.clone_helper" "http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository" | Str2html}}

- {{if not $.DisableHTTP}} - - {{end}} - {{if not $.DisableSSH}} - - {{end}} - {{if not $.DisableHTTP}} - - {{else}} - - {{end}} - {{if not (and $.DisableHTTP $.DisableSSH)}} - - {{end}} + {{template "repo/clone_buttons" .}}
diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 80187a2fb..4d8d28921 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -106,43 +106,10 @@ {{end}}
- {{if eq $n 0}}
- {{if not $.DisableHTTP}} - - {{end}} - {{if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}} - - {{end}} - {{if not $.DisableHTTP}} - - {{else if and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH)}} - - {{end}} - - {{if or (not $.DisableHTTP) (and (not $.DisableSSH) (or $.IsSigned $.ExposeAnonSSH))}} - - {{end}} + {{template "repo/clone_buttons" .}}