فهرست منبع

[GINR] Add gin cli command to download buttons

cgars 8 سال پیش
والد
کامیت
5a0613af59
3فایلهای تغییر یافته به همراه17 افزوده شده و 2 حذف شده
  1. 2 0
      models/repo.go
  2. 12 2
      public/js/gogs.js
  3. 3 0
      templates/repo/home.tmpl

+ 2 - 0
models/repo.go

@@ -603,6 +603,7 @@ type CloneLink struct {
 	SSH   string
 	HTTPS string
 	Git   string
+	Gin   string
 }
 
 // ComposeHTTPSCloneURL returns HTTPS clone URL based on given owner and repository name.
@@ -624,6 +625,7 @@ func (repo *Repository) cloneLink(isWiki bool) *CloneLink {
 		cl.SSH = fmt.Sprintf("%s@%s:/%s/%s.git", setting.RunUser, setting.SSH.Domain, repo.Owner.Name, repoName)
 	}
 	cl.HTTPS = ComposeHTTPSCloneURL(repo.Owner.Name, repoName)
+	cl.Gin = fmt.Sprintf("gin get %s/%s", repo.Owner.Name, repoName)
 	return cl
 }
 

+ 12 - 2
public/js/gogs.js

@@ -482,6 +482,7 @@ function initRepository() {
         $('#repo-clone-url').val($(this).data('link'));
         $(this).addClass('blue');
         $('#repo-clone-https').removeClass('blue');
+		$('#repo-clone-gin').removeClass('blue');
         localStorage.setItem('repo-clone-protocol', 'ssh');
     });
     $('#repo-clone-https').click(function () {
@@ -489,8 +490,17 @@ function initRepository() {
         $('#repo-clone-url').val($(this).data('link'));
         $(this).addClass('blue');
         $('#repo-clone-ssh').removeClass('blue');
+		$('#repo-clone-gin').removeClass('blue');
         localStorage.setItem('repo-clone-protocol', 'https');
     });
+	$('#repo-clone-gin').click(function () {
+		$('.clone-url').text($(this).data('link'));
+		$('#repo-clone-url').val($(this).data('link'));
+		$(this).addClass('blue');
+		$('#repo-clone-ssh').removeClass('blue');
+		$('#repo-clone-https').removeClass('blue');
+		localStorage.setItem('repo-clone-protocol', 'gin');
+	});
     $('#repo-clone-url').click(function () {
         $(this).select();
     });
@@ -1143,8 +1153,8 @@ function initWebhookSettings() {
 $(document).ready(function () {
     csrf = $('meta[name=_csrf]').attr("content");
     suburl = $('meta[name=_suburl]').attr("content");
-    
-    // Set cursor to the end of autofocus input string
+
+	// Set cursor to the end of autofocus input string
     $('input[autofocus]').each(function () {
         $(this).val($(this).val());
     })

+ 3 - 0
templates/repo/home.tmpl

@@ -66,6 +66,9 @@
 				<!-- Only show colne panel in repository home page -->
 				{{if eq $n 0}}
 					<div class="ui action small input" id="clone-panel">
+						<button class="ui basic clone button" id="repo-clone-gin" data-link="{{.CloneLink.Gin}}">
+							GIN
+						</button>
 						{{if not $.DisableHTTP}}
 							<button class="ui basic clone button" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">
 								{{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}