@@ -23,14 +23,17 @@ const (
23
23
24
24
// RepoSearchOptions when calling search repositories
25
25
type RepoSearchOptions struct {
26
- OwnerID int64
27
- Private bool
28
- Restricted bool
29
- PageSize int
30
- TplName base.TplName
26
+ OwnerID int64
27
+ Private bool
28
+ Restricted bool
29
+ PageSize int
30
+ OnlyShowRelevant bool
31
+ TplName base.TplName
31
32
}
32
33
33
34
// RenderRepoSearch render repositories search page
35
+ // This function is also used to render the Admin Repository Management page.
36
+ // The isAdmin param should be set to true when rendering the Admin page.
34
37
func RenderRepoSearch (ctx * context.Context , opts * RepoSearchOptions ) {
35
38
// Sitemap index for sitemap paths
36
39
page := int (ctx .ParamsInt64 ("idx" ))
@@ -48,11 +51,10 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
48
51
}
49
52
50
53
var (
51
- repos []* repo_model.Repository
52
- count int64
53
- err error
54
- orderBy db.SearchOrderBy
55
- onlyShowRelevant bool
54
+ repos []* repo_model.Repository
55
+ count int64
56
+ err error
57
+ orderBy db.SearchOrderBy
56
58
)
57
59
58
60
ctx .Data ["SortType" ] = ctx .FormString ("sort" )
@@ -84,11 +86,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
84
86
orderBy = db .SearchOrderByRecentUpdated
85
87
}
86
88
87
- onlyShowRelevant = ! ctx .FormBool (relevantReposOnlyParam )
88
-
89
89
keyword := ctx .FormTrim ("q" )
90
90
91
- ctx .Data ["OnlyShowRelevant" ] = onlyShowRelevant
91
+ ctx .Data ["OnlyShowRelevant" ] = opts . OnlyShowRelevant
92
92
93
93
topicOnly := ctx .FormBool ("topic" )
94
94
ctx .Data ["TopicOnly" ] = topicOnly
@@ -111,7 +111,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
111
111
TopicOnly : topicOnly ,
112
112
Language : language ,
113
113
IncludeDescription : setting .UI .SearchRepoDescription ,
114
- OnlyShowRelevant : onlyShowRelevant ,
114
+ OnlyShowRelevant : opts . OnlyShowRelevant ,
115
115
})
116
116
if err != nil {
117
117
ctx .ServerError ("SearchRepository" , err )
@@ -158,9 +158,10 @@ func Repos(ctx *context.Context) {
158
158
}
159
159
160
160
RenderRepoSearch (ctx , & RepoSearchOptions {
161
- PageSize : setting .UI .ExplorePagingNum ,
162
- OwnerID : ownerID ,
163
- Private : ctx .Doer != nil ,
164
- TplName : tplExploreRepos ,
161
+ PageSize : setting .UI .ExplorePagingNum ,
162
+ OwnerID : ownerID ,
163
+ Private : ctx .Doer != nil ,
164
+ TplName : tplExploreRepos ,
165
+ OnlyShowRelevant : ! ctx .FormBool (relevantReposOnlyParam ),
165
166
})
166
167
}
0 commit comments