From d56801930668597bb8329978e384e61c0bd314ac Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Mon, 1 Feb 2016 16:30:28 +0000 Subject: [PATCH 1/2] Remember last selected clone protocol, and establish uniform order (https, ssh) --- public/js/gogs.js | 14 ++++++++++++++ templates/repo/bare.tmpl | 10 +++++----- templates/repo/home.tmpl | 2 +- templates/repo/wiki/view.tmpl | 10 +++++----- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/public/js/gogs.js b/public/js/gogs.js index f979df0762..df48c7dbe9 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -434,12 +434,14 @@ function initRepository() { $('#repo-clone-url').val($(this).data('link')); $(this).addClass('blue'); $('#repo-clone-https').removeClass('blue'); + localStorage.setItem('repo-clone-protocol', 'ssh'); }); $('#repo-clone-https').click(function () { $('.clone-url').text($(this).data('link')); $('#repo-clone-url').val($(this).data('link')); $(this).addClass('blue'); $('#repo-clone-ssh').removeClass('blue'); + localStorage.setItem('repo-clone-protocol', 'https'); }); $('#repo-clone-url').click(function () { $(this).select(); @@ -1035,4 +1037,16 @@ $(window).load(function () { } }).trigger('hashchange'); } + + // Repo clone url. + if ($('#repo-clone-url').length > 0) { + switch (localStorage.getItem('repo-clone-protocol')) { + case 'ssh': + $('#repo-clone-ssh').click(); + break; + default: + $('#repo-clone-https').click(); + break; + } + } }); diff --git a/templates/repo/bare.tmpl b/templates/repo/bare.tmpl index 936ed859a6..63baea16ac 100644 --- a/templates/repo/bare.tmpl +++ b/templates/repo/bare.tmpl @@ -16,15 +16,15 @@

{{.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 $.DisableSSH}} - {{end}} - - + diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 2e5c7e0841..208b3ad3f4 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -35,7 +35,7 @@ {{if eq $n 0}}
- {{if not $.DisableSSH}} diff --git a/templates/repo/wiki/view.tmpl b/templates/repo/wiki/view.tmpl index 050c34b0a9..c1b6c6f72d 100644 --- a/templates/repo/wiki/view.tmpl +++ b/templates/repo/wiki/view.tmpl @@ -29,15 +29,15 @@
+ {{if not $.DisableSSH}} - {{end}} - - + From 84749736a81ea768e30aaa312d729c165dc1017d Mon Sep 17 00:00:00 2001 From: Florian Kaiser Date: Mon, 1 Feb 2016 20:42:10 +0000 Subject: [PATCH 2/2] Select HTTPS if remembered clone protocol is SSH but SSH is disabled now --- public/js/gogs.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/public/js/gogs.js b/public/js/gogs.js index df48c7dbe9..cee2a6a845 100644 --- a/public/js/gogs.js +++ b/public/js/gogs.js @@ -1042,7 +1042,9 @@ $(window).load(function () { if ($('#repo-clone-url').length > 0) { switch (localStorage.getItem('repo-clone-protocol')) { case 'ssh': - $('#repo-clone-ssh').click(); + if ($('#repo-clone-ssh').click().length === 0) { + $('#repo-clone-https').click(); + }; break; default: $('#repo-clone-https').click();