@ -90,6 +90,44 @@ func Profile(ctx *context.Context) {
tab := ctx . Query ( "tab" )
ctx . Data [ "TabName" ] = tab
page := ctx . QueryInt ( "page" )
if page <= 0 {
page = 1
}
var (
repos [ ] * models . Repository
count int64
orderBy string
)
ctx . Data [ "SortType" ] = ctx . Query ( "sort" )
switch ctx . Query ( "sort" ) {
case "newest" :
orderBy = "created_unix DESC"
case "oldest" :
orderBy = "created_unix ASC"
case "recentupdate" :
orderBy = "updated_unix DESC"
case "leastupdate" :
orderBy = "updated_unix ASC"
case "reversealphabetically" :
orderBy = "name DESC"
case "alphabetically" :
orderBy = "name ASC"
default :
ctx . Data [ "SortType" ] = "recentupdate"
orderBy = "updated_unix DESC"
}
// set default sort value if sort is empty.
if ctx . Query ( "sort" ) == "" {
ctx . Data [ "SortType" ] = "recentupdate"
}
keyword := strings . Trim ( ctx . Query ( "q" ) , " " )
ctx . Data [ "Keyword" ] = keyword
switch tab {
case "activity" :
retrieveFeeds ( ctx , ctxUser , - 1 , 0 , ! showPrivate )
@ -97,66 +135,39 @@ func Profile(ctx *context.Context) {
return
}
case "stars" :
page := ctx . QueryInt ( "page" )
if page <= 0 {
page = 1
}
repos , err := ctxUser . GetStarredRepos ( showPrivate , page , setting . UI . User . RepoPagingNum , "" )
if err != nil {
ctx . Handle ( 500 , "GetStarredRepos" , err )
return
}
ctx . Data [ "PageIsProfileStarList" ] = true
if len ( keyword ) == 0 {
repos , err = ctxUser . GetStarredRepos ( showPrivate , page , setting . UI . User . RepoPagingNum , orderBy )
if err != nil {
ctx . Handle ( 500 , "GetStarredRepos" , err )
return
}
counts , err := ctxUser . GetStarredRepoCount ( showPrivate )
if err != nil {
ctx . Handle ( 500 , "GetStarredRepoCount" , err )
return
count , err = ctxUser . GetStarredRepoCount ( showPrivate )
if err != nil {
ctx . Handle ( 500 , "GetStarredRepoCount" , err )
return
}
} else {
repos , count , err = models . SearchRepositoryByName ( & models . SearchRepoOptions {
Keyword : keyword ,
OwnerID : ctxUser . ID ,
OrderBy : orderBy ,
Private : showPrivate ,
Page : page ,
PageSize : setting . UI . User . RepoPagingNum ,
Starred : true ,
} )
if err != nil {
ctx . Handle ( 500 , "SearchRepositoryByName" , err )
return
}
}
ctx . Data [ "Repos" ] = repos
ctx . Data [ "Page" ] = paginater . New ( int ( counts ) , setting . UI . User . RepoPagingNum , page , 5 )
ctx . Data [ "Total" ] = int ( counts )
ctx . Data [ "Tabs" ] = "stars"
ctx . Data [ "Page" ] = paginater . New ( int ( count ) , setting . UI . User . RepoPagingNum , page , 5 )
ctx . Data [ "Total" ] = count
default :
page := ctx . QueryInt ( "page" )
if page <= 0 {
page = 1
}
var (
repos [ ] * models . Repository
count int64
err error
orderBy string
)
ctx . Data [ "SortType" ] = ctx . Query ( "sort" )
switch ctx . Query ( "sort" ) {
case "newest" :
orderBy = "created_unix DESC"
case "oldest" :
orderBy = "created_unix ASC"
case "recentupdate" :
orderBy = "updated_unix DESC"
case "leastupdate" :
orderBy = "updated_unix ASC"
case "reversealphabetically" :
orderBy = "name DESC"
case "alphabetically" :
orderBy = "name ASC"
default :
ctx . Data [ "SortType" ] = "recentupdate"
orderBy = "updated_unix DESC"
}
// set default sort value if sort is empty.
if ctx . Query ( "sort" ) == "" {
ctx . Data [ "SortType" ] = "recentupdate"
}
keyword := strings . Trim ( ctx . Query ( "q" ) , " " )
ctx . Data [ "Keyword" ] = keyword
if len ( keyword ) == 0 {
var total int
repos , err = models . GetUserRepositories ( ctxUser . ID , showPrivate , page , setting . UI . User . RepoPagingNum , orderBy )