瀏覽代碼

Added Donate Button

Yoginth 7 年之前
父節點
當前提交
1b66e2a7b0
共有 5 個文件被更改,包括 22 次插入12 次删除
  1. 13 11
      models/repo.go
  2. 1 0
      pkg/form/repo.go
  3. 1 0
      routes/repo/setting.go
  4. 3 1
      templates/repo/header.tmpl
  5. 4 0
      templates/repo/settings/options.tmpl

+ 13 - 11
models/repo.go

@@ -3,6 +3,13 @@ package models
 import (
 	"bytes"
 	"fmt"
+	"gitote/gitote/models/errors"
+	"gitote/gitote/pkg/avatar"
+	"gitote/gitote/pkg/bindata"
+	"gitote/gitote/pkg/markup"
+	"gitote/gitote/pkg/process"
+	"gitote/gitote/pkg/setting"
+	"gitote/gitote/pkg/sync"
 	"image"
 	_ "image/jpeg"
 	"image/png"
@@ -19,20 +26,11 @@ import (
 	"github.com/go-xorm/xorm"
 	"github.com/mcuadros/go-version"
 	"github.com/nfnt/resize"
+	git "gitlab.com/gitote/git-module"
+	api "gitlab.com/gitote/go-gitote-client"
 	"gitlab.com/yoginth/cae/zip"
 	log "gopkg.in/clog.v1"
 	"gopkg.in/ini.v1"
-
-	git "gitlab.com/gitote/git-module"
-	api "gitlab.com/gitote/go-gitote-client"
-
-	"gitote/gitote/models/errors"
-	"gitote/gitote/pkg/avatar"
-	"gitote/gitote/pkg/bindata"
-	"gitote/gitote/pkg/markup"
-	"gitote/gitote/pkg/process"
-	"gitote/gitote/pkg/setting"
-	"gitote/gitote/pkg/sync"
 )
 
 // REPO_AVATAR_URL_PREFIX is used to identify a URL is to access repository avatar.
@@ -152,6 +150,7 @@ type Repository struct {
 	Name            string `xorm:"INDEX NOT NULL"`
 	Description     string `xorm:"VARCHAR(512)"`
 	Website         string
+	Donate          string
 	DefaultBranch   string
 	Size            int64 `xorm:"NOT NULL DEFAULT 0"`
 	UseCustomAvatar bool
@@ -1404,6 +1403,9 @@ func updateRepository(e Engine, repo *Repository, visibilityChanged bool) (err e
 	if len(repo.Website) > 255 {
 		repo.Website = repo.Website[:255]
 	}
+	if len(repo.Donate) > 255 {
+		repo.Donate = repo.Donate[:255]
+	}
 
 	if _, err = e.ID(repo.ID).AllCols().Update(repo); err != nil {
 		return fmt.Errorf("update: %v", err)

+ 1 - 0
pkg/form/repo.go

@@ -72,6 +72,7 @@ type RepoSetting struct {
 	RepoName      string `binding:"Required;AlphaDashDot;MaxSize(100)"`
 	Description   string `binding:"MaxSize(512)"`
 	Website       string `binding:"Url;MaxSize(100)"`
+	Donate        string `binding:"Url;MaxSize(100)"`
 	Branch        string
 	Interval      int
 	MirrorAddress string

+ 1 - 0
routes/repo/setting.go

@@ -79,6 +79,7 @@ func SettingsPost(c *context.Context, f form.RepoSetting) {
 
 		repo.Description = f.Description
 		repo.Website = f.Website
+		repo.Donate = f.Donate
 
 		// Visibility of forked repository is forced sync with base repository.
 		if repo.IsFork {

+ 3 - 1
templates/repo/header.tmpl

@@ -85,10 +85,12 @@
 				</a>
 			{{end}}
 			{{if .IsBeta}}
-				<a class="{{if .PageIsWiki}}active{{end}} item" href="{{.RepoLink}}/wiki">
+			{{if .Repository.Donate}}
+				<a class="item" href="{{.Repository.Donate}}" target="_blank">
 					<i class="menu-icon octicon">💸</i> {{.i18n.Tr "repo.donate"}}
 				</a>
 			{{end}}
+			{{end}}
 			{{if .IsRepositoryAdmin}}
 				<div class="right menu">
 					<a class="{{if .PageIsSettings}}active{{end}} item" href="{{.RepoLink}}/settings">

+ 4 - 0
templates/repo/settings/options.tmpl

@@ -27,6 +27,10 @@
 							<label for="website">{{.i18n.Tr "repo.settings.site"}}</label>
 							<input id="website" name="website" type="url" value="{{.Repository.Website}}">
 						</div>
+						<div class="field {{if .Err_Donate}}error{{end}}">
+							<label for="donate">{{.i18n.Tr "repo.donate"}}</label>
+							<input id="donate" name="donate" type="url" value="{{.Repository.Donate}}">
+						</div>
 
 						{{if not .Repository.IsFork}}
 							<div class="inline field">