Browse Source

Minor fix for #2710

Unknwon 6 years ago
parent
commit
d320915ad2
9 changed files with 254 additions and 245 deletions
  1. 9 11
      README.md
  2. 1 1
      README_ZH.md
  3. 1 1
      docker/README.md
  4. 1 1
      gogs.go
  5. 0 229
      models/issue.go
  6. 234 0
      models/issue_label.go
  7. 4 1
      public/css/gogs.css
  8. 3 0
      public/less/_repository.less
  9. 1 1
      templates/.VERSION

File diff suppressed because it is too large
+ 9 - 11
README.md


+ 1 - 1
README_ZH.md

@@ -12,7 +12,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自
 - 有关基本用法和变更日志,请通过 [使用手册](http://gogs.io/docs/intro/) 查看。
 - 您可以到 [Trello Board](https://trello.com/b/uxAoeLUl/gogs-go-git-service) 跟随开发团队的脚步。
 - 想要先睹为快?直接去 [在线体验](https://try.gogs.io/gogs/gogs) 。
-- 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.html) 页面获取帮助。
+- 使用过程中遇到问题?尝试从 [故障排查](http://gogs.io/docs/intro/troubleshooting.html) 页面或 [用户论坛](https://discuss.gogs.io/) 获取帮助。
 - 希望帮助多国语言界面的翻译吗?请立即访问 [详情页面](http://gogs.io/docs/features/i18n.html)!
 
 ## 功能特性

+ 1 - 1
docker/README.md

@@ -1,6 +1,6 @@
 # Docker for Gogs
 
-Visit [Docker Hub](https://hub.docker.com/r/gogs/gogs/) or [Quay](https://quay.io/repository/gogs/gogs) see all available tags.
+Visit [Docker Hub](https://hub.docker.com/r/gogs/gogs/) see all available tags.
 
 ## Usage
 

+ 1 - 1
gogs.go

@@ -17,7 +17,7 @@ import (
 	"github.com/gogits/gogs/modules/setting"
 )
 
-const APP_VER = "0.8.45.0225"
+const APP_VER = "0.8.46.0227"
 
 func init() {
 	runtime.GOMAXPROCS(runtime.NumCPU())

+ 0 - 229
models/issue.go

@@ -8,12 +8,10 @@ import (
 	"bytes"
 	"errors"
 	"fmt"
-	"html/template"
 	"io"
 	"mime/multipart"
 	"os"
 	"path"
-	"strconv"
 	"strings"
 	"time"
 
@@ -936,233 +934,6 @@ func UpdateIssueUsersByMentions(uids []int64, iid int64) error {
 	return nil
 }
 
-// .____          ___.          .__
-// |    |   _____ \_ |__   ____ |  |
-// |    |   \__  \ | __ \_/ __ \|  |
-// |    |___ / __ \| \_\ \  ___/|  |__
-// |_______ (____  /___  /\___  >____/
-//         \/    \/    \/     \/
-
-// Label represents a label of repository for issues.
-type Label struct {
-	ID              int64 `xorm:"pk autoincr"`
-	RepoID          int64 `xorm:"INDEX"`
-	Name            string
-	Color           string `xorm:"VARCHAR(7)"`
-	NumIssues       int
-	NumClosedIssues int
-	NumOpenIssues   int  `xorm:"-"`
-	IsChecked       bool `xorm:"-"`
-}
-
-// CalOpenIssues calculates the open issues of label.
-func (m *Label) CalOpenIssues() {
-	m.NumOpenIssues = m.NumIssues - m.NumClosedIssues
-}
-
-// ForegroundColor calculates the text color for labels based
-// on their background color
-func (l *Label) ForegroundColor() template.CSS {
-	if strings.HasPrefix(l.Color, "#") {
-		if color, err := strconv.ParseUint(l.Color[1:], 16, 64); err == nil {
-			r := float32(0xFF & (color >> 16))
-			g := float32(0xFF & (color >> 8))
-			b := float32(0xFF & color)
-			luminance := (0.2126*r + 0.7152*g + 0.0722*b) / 255
-
-			if luminance < 0.5 {
-				return template.CSS("rgba(255,255,255,.8)")
-			}
-		}
-	}
-
-	// default to black
-	return template.CSS("rgba(0,0,0,.8)")
-}
-
-// NewLabel creates new label of repository.
-func NewLabel(l *Label) error {
-	_, err := x.Insert(l)
-	return err
-}
-
-func getLabelByID(e Engine, id int64) (*Label, error) {
-	if id <= 0 {
-		return nil, ErrLabelNotExist{id}
-	}
-
-	l := &Label{ID: id}
-	has, err := x.Get(l)
-	if err != nil {
-		return nil, err
-	} else if !has {
-		return nil, ErrLabelNotExist{l.ID}
-	}
-	return l, nil
-}
-
-// GetLabelByID returns a label by given ID.
-func GetLabelByID(id int64) (*Label, error) {
-	return getLabelByID(x, id)
-}
-
-// GetLabelsByRepoID returns all labels that belong to given repository by ID.
-func GetLabelsByRepoID(repoID int64) ([]*Label, error) {
-	labels := make([]*Label, 0, 10)
-	return labels, x.Where("repo_id=?", repoID).Find(&labels)
-}
-
-func getLabelsByIssueID(e Engine, issueID int64) ([]*Label, error) {
-	issueLabels, err := getIssueLabels(e, issueID)
-	if err != nil {
-		return nil, fmt.Errorf("getIssueLabels: %v", err)
-	}
-
-	var label *Label
-	labels := make([]*Label, 0, len(issueLabels))
-	for idx := range issueLabels {
-		label, err = getLabelByID(e, issueLabels[idx].LabelID)
-		if err != nil && !IsErrLabelNotExist(err) {
-			return nil, fmt.Errorf("getLabelByID: %v", err)
-		}
-		labels = append(labels, label)
-	}
-	return labels, nil
-}
-
-// GetLabelsByIssueID returns all labels that belong to given issue by ID.
-func GetLabelsByIssueID(issueID int64) ([]*Label, error) {
-	return getLabelsByIssueID(x, issueID)
-}
-
-func updateLabel(e Engine, l *Label) error {
-	_, err := e.Id(l.ID).AllCols().Update(l)
-	return err
-}
-
-// UpdateLabel updates label information.
-func UpdateLabel(l *Label) error {
-	return updateLabel(x, l)
-}
-
-// DeleteLabel delete a label of given repository.
-func DeleteLabel(repoID, labelID int64) error {
-	l, err := GetLabelByID(labelID)
-	if err != nil {
-		if IsErrLabelNotExist(err) {
-			return nil
-		}
-		return err
-	}
-
-	sess := x.NewSession()
-	defer sessionRelease(sess)
-	if err = sess.Begin(); err != nil {
-		return err
-	}
-
-	if _, err = x.Where("label_id=?", labelID).Delete(new(IssueLabel)); err != nil {
-		return err
-	} else if _, err = sess.Delete(l); err != nil {
-		return err
-	}
-	return sess.Commit()
-}
-
-// .___                            .____          ___.          .__
-// |   | ______ ________ __   ____ |    |   _____ \_ |__   ____ |  |
-// |   |/  ___//  ___/  |  \_/ __ \|    |   \__  \ | __ \_/ __ \|  |
-// |   |\___ \ \___ \|  |  /\  ___/|    |___ / __ \| \_\ \  ___/|  |__
-// |___/____  >____  >____/  \___  >_______ (____  /___  /\___  >____/
-//          \/     \/            \/        \/    \/    \/     \/
-
-// IssueLabel represetns an issue-lable relation.
-type IssueLabel struct {
-	ID      int64 `xorm:"pk autoincr"`
-	IssueID int64 `xorm:"UNIQUE(s)"`
-	LabelID int64 `xorm:"UNIQUE(s)"`
-}
-
-func hasIssueLabel(e Engine, issueID, labelID int64) bool {
-	has, _ := e.Where("issue_id=? AND label_id=?", issueID, labelID).Get(new(IssueLabel))
-	return has
-}
-
-// HasIssueLabel returns true if issue has been labeled.
-func HasIssueLabel(issueID, labelID int64) bool {
-	return hasIssueLabel(x, issueID, labelID)
-}
-
-func newIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) {
-	if _, err = e.Insert(&IssueLabel{
-		IssueID: issue.ID,
-		LabelID: label.ID,
-	}); err != nil {
-		return err
-	}
-
-	label.NumIssues++
-	if issue.IsClosed {
-		label.NumClosedIssues++
-	}
-	return updateLabel(e, label)
-}
-
-// NewIssueLabel creates a new issue-label relation.
-func NewIssueLabel(issue *Issue, label *Label) (err error) {
-	sess := x.NewSession()
-	defer sessionRelease(sess)
-	if err = sess.Begin(); err != nil {
-		return err
-	}
-
-	if err = newIssueLabel(sess, issue, label); err != nil {
-		return err
-	}
-
-	return sess.Commit()
-}
-
-func getIssueLabels(e Engine, issueID int64) ([]*IssueLabel, error) {
-	issueLabels := make([]*IssueLabel, 0, 10)
-	return issueLabels, e.Where("issue_id=?", issueID).Asc("label_id").Find(&issueLabels)
-}
-
-// GetIssueLabels returns all issue-label relations of given issue by ID.
-func GetIssueLabels(issueID int64) ([]*IssueLabel, error) {
-	return getIssueLabels(x, issueID)
-}
-
-func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) {
-	if _, err = e.Delete(&IssueLabel{
-		IssueID: issue.ID,
-		LabelID: label.ID,
-	}); err != nil {
-		return err
-	}
-
-	label.NumIssues--
-	if issue.IsClosed {
-		label.NumClosedIssues--
-	}
-	return updateLabel(e, label)
-}
-
-// DeleteIssueLabel deletes issue-label relation.
-func DeleteIssueLabel(issue *Issue, label *Label) (err error) {
-	sess := x.NewSession()
-	defer sessionRelease(sess)
-	if err = sess.Begin(); err != nil {
-		return err
-	}
-
-	if err = deleteIssueLabel(sess, issue, label); err != nil {
-		return err
-	}
-
-	return sess.Commit()
-}
-
 //    _____  .__.__                   __
 //   /     \ |__|  |   ____   _______/  |_  ____   ____   ____
 //  /  \ /  \|  |  | _/ __ \ /  ___/\   __\/  _ \ /    \_/ __ \

+ 234 - 0
models/issue_label.go

@@ -0,0 +1,234 @@
+// Copyright 2016 The Gogs Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package models
+
+import (
+	"fmt"
+	"html/template"
+	"strconv"
+	"strings"
+
+	"github.com/go-xorm/xorm"
+)
+
+// Label represents a label of repository for issues.
+type Label struct {
+	ID              int64 `xorm:"pk autoincr"`
+	RepoID          int64 `xorm:"INDEX"`
+	Name            string
+	Color           string `xorm:"VARCHAR(7)"`
+	NumIssues       int
+	NumClosedIssues int
+	NumOpenIssues   int  `xorm:"-"`
+	IsChecked       bool `xorm:"-"`
+}
+
+// CalOpenIssues calculates the open issues of label.
+func (m *Label) CalOpenIssues() {
+	m.NumOpenIssues = m.NumIssues - m.NumClosedIssues
+}
+
+// ForegroundColor calculates the text color for labels based
+// on their background color.
+func (l *Label) ForegroundColor() template.CSS {
+	if strings.HasPrefix(l.Color, "#") {
+		if color, err := strconv.ParseUint(l.Color[1:], 16, 64); err == nil {
+			r := float32(0xFF & (color >> 16))
+			g := float32(0xFF & (color >> 8))
+			b := float32(0xFF & color)
+			luminance := (0.2126*r + 0.7152*g + 0.0722*b) / 255
+
+			if luminance < 0.5 {
+				return template.CSS("#fff")
+			}
+		}
+	}
+
+	// default to black
+	return template.CSS("#000")
+}
+
+// NewLabel creates new label of repository.
+func NewLabel(l *Label) error {
+	_, err := x.Insert(l)
+	return err
+}
+
+func getLabelByID(e Engine, id int64) (*Label, error) {
+	if id <= 0 {
+		return nil, ErrLabelNotExist{id}
+	}
+
+	l := &Label{ID: id}
+	has, err := x.Get(l)
+	if err != nil {
+		return nil, err
+	} else if !has {
+		return nil, ErrLabelNotExist{l.ID}
+	}
+	return l, nil
+}
+
+// GetLabelByID returns a label by given ID.
+func GetLabelByID(id int64) (*Label, error) {
+	return getLabelByID(x, id)
+}
+
+// GetLabelsByRepoID returns all labels that belong to given repository by ID.
+func GetLabelsByRepoID(repoID int64) ([]*Label, error) {
+	labels := make([]*Label, 0, 10)
+	return labels, x.Where("repo_id=?", repoID).Find(&labels)
+}
+
+func getLabelsByIssueID(e Engine, issueID int64) ([]*Label, error) {
+	issueLabels, err := getIssueLabels(e, issueID)
+	if err != nil {
+		return nil, fmt.Errorf("getIssueLabels: %v", err)
+	}
+
+	var label *Label
+	labels := make([]*Label, 0, len(issueLabels))
+	for idx := range issueLabels {
+		label, err = getLabelByID(e, issueLabels[idx].LabelID)
+		if err != nil && !IsErrLabelNotExist(err) {
+			return nil, fmt.Errorf("getLabelByID: %v", err)
+		}
+		labels = append(labels, label)
+	}
+	return labels, nil
+}
+
+// GetLabelsByIssueID returns all labels that belong to given issue by ID.
+func GetLabelsByIssueID(issueID int64) ([]*Label, error) {
+	return getLabelsByIssueID(x, issueID)
+}
+
+func updateLabel(e Engine, l *Label) error {
+	_, err := e.Id(l.ID).AllCols().Update(l)
+	return err
+}
+
+// UpdateLabel updates label information.
+func UpdateLabel(l *Label) error {
+	return updateLabel(x, l)
+}
+
+// DeleteLabel delete a label of given repository.
+func DeleteLabel(repoID, labelID int64) error {
+	l, err := GetLabelByID(labelID)
+	if err != nil {
+		if IsErrLabelNotExist(err) {
+			return nil
+		}
+		return err
+	}
+
+	sess := x.NewSession()
+	defer sessionRelease(sess)
+	if err = sess.Begin(); err != nil {
+		return err
+	}
+
+	if _, err = x.Where("label_id=?", labelID).Delete(new(IssueLabel)); err != nil {
+		return err
+	} else if _, err = sess.Delete(l); err != nil {
+		return err
+	}
+	return sess.Commit()
+}
+
+// .___                            .____          ___.          .__
+// |   | ______ ________ __   ____ |    |   _____ \_ |__   ____ |  |
+// |   |/  ___//  ___/  |  \_/ __ \|    |   \__  \ | __ \_/ __ \|  |
+// |   |\___ \ \___ \|  |  /\  ___/|    |___ / __ \| \_\ \  ___/|  |__
+// |___/____  >____  >____/  \___  >_______ (____  /___  /\___  >____/
+//          \/     \/            \/        \/    \/    \/     \/
+
+// IssueLabel represetns an issue-lable relation.
+type IssueLabel struct {
+	ID      int64 `xorm:"pk autoincr"`
+	IssueID int64 `xorm:"UNIQUE(s)"`
+	LabelID int64 `xorm:"UNIQUE(s)"`
+}
+
+func hasIssueLabel(e Engine, issueID, labelID int64) bool {
+	has, _ := e.Where("issue_id=? AND label_id=?", issueID, labelID).Get(new(IssueLabel))
+	return has
+}
+
+// HasIssueLabel returns true if issue has been labeled.
+func HasIssueLabel(issueID, labelID int64) bool {
+	return hasIssueLabel(x, issueID, labelID)
+}
+
+func newIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) {
+	if _, err = e.Insert(&IssueLabel{
+		IssueID: issue.ID,
+		LabelID: label.ID,
+	}); err != nil {
+		return err
+	}
+
+	label.NumIssues++
+	if issue.IsClosed {
+		label.NumClosedIssues++
+	}
+	return updateLabel(e, label)
+}
+
+// NewIssueLabel creates a new issue-label relation.
+func NewIssueLabel(issue *Issue, label *Label) (err error) {
+	sess := x.NewSession()
+	defer sessionRelease(sess)
+	if err = sess.Begin(); err != nil {
+		return err
+	}
+
+	if err = newIssueLabel(sess, issue, label); err != nil {
+		return err
+	}
+
+	return sess.Commit()
+}
+
+func getIssueLabels(e Engine, issueID int64) ([]*IssueLabel, error) {
+	issueLabels := make([]*IssueLabel, 0, 10)
+	return issueLabels, e.Where("issue_id=?", issueID).Asc("label_id").Find(&issueLabels)
+}
+
+// GetIssueLabels returns all issue-label relations of given issue by ID.
+func GetIssueLabels(issueID int64) ([]*IssueLabel, error) {
+	return getIssueLabels(x, issueID)
+}
+
+func deleteIssueLabel(e *xorm.Session, issue *Issue, label *Label) (err error) {
+	if _, err = e.Delete(&IssueLabel{
+		IssueID: issue.ID,
+		LabelID: label.ID,
+	}); err != nil {
+		return err
+	}
+
+	label.NumIssues--
+	if issue.IsClosed {
+		label.NumClosedIssues--
+	}
+	return updateLabel(e, label)
+}
+
+// DeleteIssueLabel deletes issue-label relation.
+func DeleteIssueLabel(issue *Issue, label *Label) (err error) {
+	sess := x.NewSession()
+	defer sessionRelease(sess)
+	if err = sess.Begin(); err != nil {
+		return err
+	}
+
+	if err = deleteIssueLabel(sess, issue, label); err != nil {
+		return err
+	}
+
+	return sess.Commit()
+}

+ 4 - 1
public/css/gogs.css

@@ -1477,7 +1477,7 @@ footer .container .links > *:first-child {
   background-color: #fff;
 }
 .repository.view.issue .comment-list .comment .content > .bottom.segment a:before {
-  content: "";
+  content: ' ';
   display: inline-block;
   height: 100%;
   vertical-align: middle;
@@ -1601,6 +1601,9 @@ footer .container .links > *:first-child {
 .repository .label.list .item a.open-issues {
   margin-right: 30px;
 }
+.repository .label.list .item .ui.label {
+  font-size: 1em;
+}
 .repository .milestone.list {
   list-style: none;
   padding-top: 15px;

+ 3 - 0
public/less/_repository.less

@@ -553,6 +553,9 @@
 					margin-right: 30px;
 				}
 			}
+			.ui.label {
+				font-size: 1em;
+			}
 		}
 	}
 

+ 1 - 1
templates/.VERSION

@@ -1 +1 @@
-0.8.45.0225
+0.8.46.0227