Merge branch 'master' into master

This commit is contained in:
kolaente 2018-01-03 16:26:09 +01:00 committed by GitHub
commit 0016a3e1a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 52 additions and 2 deletions

View File

@ -252,7 +252,7 @@ be reviewed by two maintainers and must pass the automatic tests.
Code that you contribute should use the standard copyright header:
```
// Copyright 2017 The Gitea Authors. All rights reserved.
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
```

View File

@ -7,6 +7,7 @@ package models
import (
"fmt"
"path"
"regexp"
"sort"
"strings"
@ -54,6 +55,19 @@ type Issue struct {
Reactions ReactionList `xorm:"-"`
}
var (
issueTasksPat *regexp.Regexp
issueTasksDonePat *regexp.Regexp
)
const issueTasksRegexpStr = `(^\s*-\s\[[\sx]\]\s)|(\n\s*-\s\[[\sx]\]\s)`
const issueTasksDoneRegexpStr = `(^\s*-\s\[[x]\]\s)|(\n\s*-\s\[[x]\]\s)`
func init() {
issueTasksPat = regexp.MustCompile(issueTasksRegexpStr)
issueTasksDonePat = regexp.MustCompile(issueTasksDoneRegexpStr)
}
func (issue *Issue) loadRepo(e Engine) (err error) {
if issue.Repo == nil {
issue.Repo, err = getRepositoryByID(e, issue.RepoID)
@ -741,6 +755,7 @@ func AddDeletePRBranchComment(doer *User, repo *Repository, issueID int64, branc
func (issue *Issue) ChangeContent(doer *User, content string) (err error) {
oldContent := issue.Content
issue.Content = content
if err = UpdateIssueCols(issue, "content"); err != nil {
return fmt.Errorf("UpdateIssueCols: %v", err)
}
@ -818,6 +833,16 @@ func (issue *Issue) ChangeAssignee(doer *User, assigneeID int64) (err error) {
return nil
}
// GetTasks returns the amount of tasks in the issues content
func (issue *Issue) GetTasks() int {
return len(issueTasksPat.FindAllStringIndex(issue.Content, -1))
}
// GetTasksDone returns the amount of completed tasks in the issues content
func (issue *Issue) GetTasksDone() int {
return len(issueTasksDonePat.FindAllStringIndex(issue.Content, -1))
}
// NewIssueOptions represents the options of a new issue.
type NewIssueOptions struct {
Repo *Repository

View File

@ -1310,6 +1310,7 @@ auths.attribute_mail=Email
auths.attributes_in_bind=Извлечение атрибутов в виде Bind DN
auths.filter=Фильтр пользователя
auths.admin_filter=Фильтр администратора
auths.ms_ad_sa=Атрибуты поиска MS AD
auths.smtp_auth=Тип аутентификации SMTP
auths.smtphost=Узел SMTP
auths.smtpport=SMTP-порт

File diff suppressed because one or more lines are too long

View File

@ -1491,6 +1491,20 @@
.desc {
padding-top: 5px;
color: #999;
.progress-bar {
width: 80px;
height: 6px;
display: inline-block;
background-color: #eee;
overflow: hidden;
border-radius: 3px;
vertical-align: middle !important;
.progress {
background-color: #ccc;
display: block;
height: 100%;
}
}
a.milestone {
padding-left: 5px;
color: #999!important;

View File

@ -200,6 +200,11 @@
<p class="desc">
{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}}
{{$tasks := .GetTasks}}
{{if gt $tasks 0}}
{{$tasksDone := .GetTasksDone}}
<span class="octicon octicon-checklist"></span> {{$tasksDone}} / {{$tasks}} <span class="progress-bar"><span class="progress" style="width:calc(100% * {{$tasksDone}} / {{$tasks}});"></span></span>
{{end}}
{{if .Milestone}}
<a class="milestone" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{.Milestone.ID}}&assignee={{$.AssigneeID}}">
<span class="octicon octicon-milestone"></span> {{.Milestone.Name}}

View File

@ -87,6 +87,11 @@
<img class="ui avatar image" src="{{.Assignee.RelAvatarLink}}">
</a>
{{end}}
{{$tasks := .GetTasks}}
{{if gt $tasks 0}}
{{$tasksDone := .GetTasksDone}}
<span class="octicon octicon-checklist"></span> {{$tasksDone}} / {{$tasks}} <span class="progress-bar"><span class="progress" style="width:calc(100% * {{$tasksDone}} / {{$tasks}});"></span></span>
{{end}}
</p>
</li>
{{end}}