diff --git a/models/issue.go b/models/issue.go index d17bc2073..14191afdd 100644 --- a/models/issue.go +++ b/models/issue.go @@ -816,6 +816,7 @@ type IssuesOptions struct { IsPull bool Labels string SortType string + Keyword string } // Issues returns a list of issues by given conditions. @@ -882,6 +883,10 @@ func Issues(opts *IssuesOptions) ([]*Issue, error) { } } + if len(opts.Keyword) > 0 { + sess.And("(LOWER(name) LIKE LOWER(?) OR LOWER(content) LIKE LOWER(?))", "%"+opts.Keyword+"%", "%"+opts.Keyword+"%") + } + issues := make([]*Issue, 0, setting.UI.IssuePagingNum) if err := sess.Find(&issues); err != nil { return nil, fmt.Errorf("Find: %v", err) @@ -1102,6 +1107,7 @@ type IssueStatsOptions struct { AssigneeID int64 FilterMode FilterMode IsPull bool + Keyword string } // GetIssueStats returns issue statistic information by given conditions. @@ -1126,6 +1132,10 @@ func GetIssueStats(opts *IssueStatsOptions) *IssueStats { sess.And("assignee_id = ?", opts.AssigneeID) } + if len(opts.Keyword) > 0 { + sess.And("(LOWER(name) LIKE LOWER(?) OR LOWER(content) LIKE LOWER(?))", "%"+opts.Keyword+"%", "%"+opts.Keyword+"%") + } + return sess } diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 83a6c3545..19681a063 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -109,6 +109,7 @@ func Issues(ctx *context.Context) { if !com.IsSliceContainsStr(types, viewType) { viewType = "all" } + keyword := ctx.Query("q") // Must sign in to see issues about you. if viewType != "all" && !ctx.IsSigned { @@ -150,6 +151,7 @@ func Issues(ctx *context.Context) { AssigneeID: assigneeID, FilterMode: filterMode, IsPull: isPullList, + Keyword: keyword, }) page := ctx.QueryInt("page") @@ -178,6 +180,7 @@ func Issues(ctx *context.Context) { IsPull: isPullList, Labels: selectLabels, SortType: sortType, + Keyword: keyword, }) if err != nil { ctx.Handle(500, "Issues", err) @@ -238,6 +241,7 @@ func Issues(ctx *context.Context) { } else { ctx.Data["State"] = "open" } + ctx.Data["Keyword"] = keyword ctx.HTML(200, ISSUES) } diff --git a/templates/repo/issue/list.tmpl b/templates/repo/issue/list.tmpl index d00c9aea2..5e47d5f23 100644 --- a/templates/repo/issue/list.tmpl +++ b/templates/repo/issue/list.tmpl @@ -14,15 +14,19 @@
+{{$.i18n.Tr "repo.issues.opened_by" $timeStr .Poster.HomeLink .Poster.Name | Safe}} {{if .Milestone}} - + {{.Milestone.Name}} {{end}} @@ -132,17 +136,17 @@ {{if gt .TotalPages 1}}