@ -90,6 +90,44 @@ func Profile(ctx *context.Context) {
tab := ctx . Query ( "tab" )
tab := ctx . Query ( "tab" )
ctx . Data [ "TabName" ] = 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 {
switch tab {
case "activity" :
case "activity" :
retrieveFeeds ( ctx , ctxUser , - 1 , 0 , ! showPrivate )
retrieveFeeds ( ctx , ctxUser , - 1 , 0 , ! showPrivate )
@ -97,66 +135,39 @@ func Profile(ctx *context.Context) {
return
return
}
}
case "stars" :
case "stars" :
page := ctx . QueryInt ( "page" )
ctx . Data [ "PageIsProfileStarList" ] = true
if page <= 0 {
if len ( keyword ) == 0 {
page = 1
repos , err = ctxUser . GetStarredRepos ( showPrivate , page , setting . UI . User . RepoPagingNum , orderBy )
}
if err != nil {
ctx . Handle ( 500 , "GetStarredRepos" , err )
repos , err := ctxUser . GetStarredRepos ( showPrivate , page , setting . UI . User . RepoPagingNum , "" )
return
if err != nil {
}
ctx . Handle ( 500 , "GetStarredRepos" , err )
return
}
counts , err := ctxUser . GetStarredRepoCount ( showPrivate )
count , err = ctxUser . GetStarredRepoCount ( showPrivate )
if err != nil {
if err != nil {
ctx . Handle ( 500 , "GetStarredRepoCount" , err )
ctx . Handle ( 500 , "GetStarredRepoCount" , err )
return
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 [ "Repos" ] = repos
ctx . Data [ "Page" ] = paginater . New ( int ( counts ) , setting . UI . User . RepoPagingNum , page , 5 )
ctx . Data [ "Page" ] = paginater . New ( int ( count ) , setting . UI . User . RepoPagingNum , page , 5 )
ctx . Data [ "Total" ] = int ( counts )
ctx . Data [ "Total" ] = count
ctx . Data [ "Tabs" ] = "stars"
default :
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 {
if len ( keyword ) == 0 {
var total int
var total int
repos , err = models . GetUserRepositories ( ctxUser . ID , showPrivate , page , setting . UI . User . RepoPagingNum , orderBy )
repos , err = models . GetUserRepositories ( ctxUser . ID , showPrivate , page , setting . UI . User . RepoPagingNum , orderBy )