@@ -23,14 +23,17 @@ const (
2323
2424// RepoSearchOptions when calling search repositories 
2525type  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 
3132}
3233
3334// 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. 
3437func  RenderRepoSearch (ctx  * context.Context , opts  * RepoSearchOptions ) {
3538	// Sitemap index for sitemap paths 
3639	page  :=  int (ctx .ParamsInt64 ("idx" ))
@@ -48,11 +51,10 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
4851	}
4952
5053	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 
5658	)
5759
5860	ctx .Data ["SortType" ] =  ctx .FormString ("sort" )
@@ -84,11 +86,9 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
8486		orderBy  =  db .SearchOrderByRecentUpdated 
8587	}
8688
87- 	onlyShowRelevant  =  ! ctx .FormBool (relevantReposOnlyParam )
88- 
8989	keyword  :=  ctx .FormTrim ("q" )
9090
91- 	ctx .Data ["OnlyShowRelevant" ] =  onlyShowRelevant 
91+ 	ctx .Data ["OnlyShowRelevant" ] =  opts . OnlyShowRelevant 
9292
9393	topicOnly  :=  ctx .FormBool ("topic" )
9494	ctx .Data ["TopicOnly" ] =  topicOnly 
@@ -111,7 +111,7 @@ func RenderRepoSearch(ctx *context.Context, opts *RepoSearchOptions) {
111111		TopicOnly :          topicOnly ,
112112		Language :           language ,
113113		IncludeDescription : setting .UI .SearchRepoDescription ,
114- 		OnlyShowRelevant :   onlyShowRelevant ,
114+ 		OnlyShowRelevant :   opts . OnlyShowRelevant ,
115115	})
116116	if  err  !=  nil  {
117117		ctx .ServerError ("SearchRepository" , err )
@@ -158,9 +158,10 @@ func Repos(ctx *context.Context) {
158158	}
159159
160160	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 ),
165166	})
166167}
0 commit comments