minor fixes on #1551

This commit is contained in:
Unknwon 2015-09-01 07:04:35 -04:00
parent 67f07e21f5
commit 7714e792a4
10 changed files with 322 additions and 734 deletions

View File

@ -13,6 +13,8 @@ ROOT =
SCRIPT_TYPE = bash SCRIPT_TYPE = bash
[ui] [ui]
; Number of repositories that are showed in one explore page
EXPLORE_PAGING_NUM = 20
; Number of issues that are showed in one page ; Number of issues that are showed in one page
ISSUE_PAGING_NUM = 10 ISSUE_PAGING_NUM = 10

View File

@ -1105,9 +1105,9 @@ func GetRepositories(uid int64, private bool) ([]*Repository, error) {
} }
// GetRecentUpdatedRepositories returns the list of repositories that are recently updated. // GetRecentUpdatedRepositories returns the list of repositories that are recently updated.
func GetRecentUpdatedRepositories(num int) (repos []*Repository, err error) { func GetRecentUpdatedRepositories(page int) (repos []*Repository, err error) {
err = x.Where("is_private=?", false).Limit(num).Desc("updated").Find(&repos) return repos, x.Limit(setting.ExplorePagingNum, (page-1)*setting.ExplorePagingNum).
return repos, err Where("is_private=?", false).Limit(setting.ExplorePagingNum).Desc("updated").Find(&repos)
} }
// GetRepositoryCount returns the total number of repositories of user. // GetRepositoryCount returns the total number of repositories of user.

File diff suppressed because one or more lines are too long

View File

@ -91,6 +91,7 @@ var (
AnsiCharset string AnsiCharset string
// UI settings. // UI settings.
ExplorePagingNum int
IssuePagingNum int IssuePagingNum int
// Picture settings. // Picture settings.
@ -352,6 +353,7 @@ func NewConfigContext() {
AnsiCharset = sec.Key("ANSI_CHARSET").MustString("") AnsiCharset = sec.Key("ANSI_CHARSET").MustString("")
// UI settings. // UI settings.
ExplorePagingNum = Cfg.Section("ui").Key("EXPLORE_PAGING_NUM").MustInt(20)
IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10) IssuePagingNum = Cfg.Section("ui").Key("ISSUE_PAGING_NUM").MustInt(10)
sec = Cfg.Section("picture") sec = Cfg.Section("picture")

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,30 @@
.explore { .explore {
padding-top: 15px; padding-top: 15px;
padding-bottom: @footer-margin * 2;
&.repositories {
.ui.repository.list {
.item {
border-top: 1px solid #eee;
padding-top: 25px;
padding-bottom: 25px;
.ui.header {
font-size: 1.5rem;
padding-bottom: 10px;
.metas {
color: #888;
font-size: 13px;
font-weight: normal;
span:not(:last-child) {
margin-right: 5px;
}
}
}
.time {
font-size: 12px;
color: #808080;
}
}
}
}
} }

View File

@ -7,6 +7,8 @@ package routers
import ( import (
"fmt" "fmt"
"github.com/Unknwon/paginater"
"github.com/gogits/gogs/models" "github.com/gogits/gogs/models"
"github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/base"
"github.com/gogits/gogs/modules/middleware" "github.com/gogits/gogs/modules/middleware"
@ -50,7 +52,14 @@ func Explore(ctx *middleware.Context) {
ctx.Data["Title"] = ctx.Tr("explore") ctx.Data["Title"] = ctx.Tr("explore")
ctx.Data["PageIsExploreRepositories"] = true ctx.Data["PageIsExploreRepositories"] = true
repos, err := models.GetRecentUpdatedRepositories(20) page := ctx.QueryInt("page")
if page <= 1 {
page = 1
}
ctx.Data["Page"] = paginater.New(int(models.CountRepositories()), setting.ExplorePagingNum, page, 5)
repos, err := models.GetRecentUpdatedRepositories(page)
if err != nil { if err != nil {
ctx.Handle(500, "GetRecentUpdatedRepositories", err) ctx.Handle(500, "GetRecentUpdatedRepositories", err)
return return

View File

@ -1,32 +1,47 @@
{{template "base/head" .}} {{template "base/head" .}}
<div class="explore"> <div class="explore repositories">
<div class="ui container"> <div class="ui container">
<div class="ui grid"> <div class="ui grid">
{{template "explore/nav" .}} {{template "explore/navbar" .}}
<div class="twelve wide column content"> <div class="twelve wide column content">
<h4 class="ui top attached header"> <div class="ui repository list">
{{.i18n.Tr "explore.repos"}}
</h4>
<div class="ui attached segment">
{{range $i, $v := .Repos}} {{range $i, $v := .Repos}}
<div class="item"> <div class="item">
<div class="ui right"> <div class="ui header">
<span class="text grey right"><i class="octicon octicon-star"></i> {{.NumStars}}</li> </span>
<span class="text grey right"><i class="octicon octicon-git-branch"></i> {{.NumForks}}</li></span>
</div>
<h2>
<a href="{{AppSubUrl}}/{{.Owner.Name}}/{{.Name}}">{{.Owner.Name}} / {{.Name}}</a> <a href="{{AppSubUrl}}/{{.Owner.Name}}/{{.Name}}">{{.Owner.Name}} / {{.Name}}</a>
</h2>
<p class="org-repo-description">{{.Description}}</p> <div class="ui right metas">
<p class="org-repo-updated">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}</p> <span class="text grey"><i class="octicon octicon-star"></i> {{.NumStars}}</span>
<span class="text grey"><i class="octicon octicon-git-branch"></i> {{.NumForks}}</span>
</div>
</div>
{{if .Description}}<p>{{.Description}}</p>{{end}}
<p class="time">{{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Updated $.i18n.Lang}}</p>
</div> </div>
{{if not (eq 1 (len $.Repos))}}
{{if not $i}}
<div class="ui divider"></div>
{{end}}
{{end}}
{{end}} {{end}}
</div> </div>
{{with .Page}}
{{if gt .TotalPages 1}}
<div class="center page buttons">
<div class="ui borderless pagination menu">
<a class="{{if not .HasPrevious}}disabled{{end}} item" {{if .HasPrevious}}href="{{$.Link}}?page={{.Previous}}"{{end}}>
<i class="left arrow icon"></i> {{$.i18n.Tr "repo.issues.previous"}}
</a>
{{range .Pages}}
{{if eq .Num -1}}
<a class="disabled item">...</a>
{{else}}
<a class="{{if .IsCurrent}}active{{end}} item" {{if not .IsCurrent}}href="{{$.Link}}?page={{.Num}}"{{end}}>{{.Num}}</a>
{{end}}
{{end}}
<a class="{{if not .HasNext}}disabled{{end}} item" {{if .HasNext}}href="{{$.Link}}?page={{.Next}}"{{end}}>
{{$.i18n.Tr "repo.issues.next"}} <i class="icon right arrow"></i>
</a>
</div>
</div>
{{end}}
{{end}}
</div> </div>
</div> </div>
</div> </div>