new commits table
This commit is contained in:
parent
d7c3c79c00
commit
aa65761d81
14 changed files with 163 additions and 90 deletions
|
@ -166,6 +166,13 @@ type Repository struct {
|
||||||
Updated time.Time `xorm:"UPDATED"`
|
Updated time.Time `xorm:"UPDATED"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
|
||||||
|
switch colName {
|
||||||
|
case "updated":
|
||||||
|
repo.Updated = regulateTimeZone(repo.Updated)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (repo *Repository) getOwner(e Engine) (err error) {
|
func (repo *Repository) getOwner(e Engine) (err error) {
|
||||||
if repo.Owner == nil {
|
if repo.Owner == nil {
|
||||||
repo.Owner, err = getUserByID(e, repo.OwnerID)
|
repo.Owner, err = getUserByID(e, repo.OwnerID)
|
||||||
|
|
|
@ -275,9 +275,11 @@ func (repo *Repository) searchCommits(id sha1, keyword string) (*list.List, erro
|
||||||
return parsePrettyFormatLog(repo, stdout)
|
return parsePrettyFormatLog(repo, stdout)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var CommitsRangeSize = 50
|
||||||
|
|
||||||
func (repo *Repository) commitsByRange(id sha1, page int) (*list.List, error) {
|
func (repo *Repository) commitsByRange(id sha1, page int) (*list.List, error) {
|
||||||
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", id.String(),
|
stdout, stderr, err := com.ExecCmdDirBytes(repo.Path, "git", "log", id.String(),
|
||||||
"--skip="+com.ToStr((page-1)*50), "--max-count=50", prettyLogFormat)
|
"--skip="+com.ToStr((page-1)*CommitsRangeSize), "--max-count="+com.ToStr(CommitsRangeSize), prettyLogFormat)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New(string(stderr))
|
return nil, errors.New(string(stderr))
|
||||||
}
|
}
|
||||||
|
|
2
public/css/gogs.min.css
vendored
2
public/css/gogs.min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
.admin {
|
.admin {
|
||||||
padding-top: 15px;
|
padding-top: 15px;
|
||||||
padding-bottom: @footer-margin * 3;
|
padding-bottom: @footer-margin * 2;
|
||||||
|
|
||||||
.table.segment {
|
.table.segment {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
|
@ -92,6 +92,13 @@ img {
|
||||||
&.small {
|
&.small {
|
||||||
font-size: 0.75em;
|
font-size: 0.75em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.truncate {
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.message {
|
.message {
|
||||||
|
|
|
@ -9,7 +9,11 @@
|
||||||
.ui.attached.header {
|
.ui.attached.header {
|
||||||
background: #f0f0f0;
|
background: #f0f0f0;
|
||||||
.right {
|
.right {
|
||||||
margin-top: -6px;
|
margin-top: -5px;
|
||||||
|
.button {
|
||||||
|
padding: 8px 10px;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.repository {
|
.repository {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
.home {
|
.home {
|
||||||
padding-bottom: @footer-margin * 3;
|
padding-bottom: @footer-margin * 2;
|
||||||
.logo {
|
.logo {
|
||||||
max-width: 250px;
|
max-width: 250px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.install {
|
.install {
|
||||||
padding-top: 45px;
|
padding-top: 45px;
|
||||||
padding-bottom: @footer-margin * 3;
|
padding-bottom: @footer-margin * 2;
|
||||||
form {
|
form {
|
||||||
@input-padding: 320px !important;
|
@input-padding: 320px !important;
|
||||||
label {
|
label {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
@mega-octicon-width: 30px;
|
@mega-octicon-width: 30px;
|
||||||
|
|
||||||
padding-top: 15px;
|
padding-top: 15px;
|
||||||
padding-bottom: @footer-margin * 3;
|
padding-bottom: @footer-margin * 2;
|
||||||
|
|
||||||
.head {
|
.head {
|
||||||
.column {
|
.column {
|
||||||
|
@ -424,6 +424,52 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.commits {
|
||||||
|
.header {
|
||||||
|
.ui.right {
|
||||||
|
.search {
|
||||||
|
input {
|
||||||
|
font-weight: normal;
|
||||||
|
padding: 5px 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
float: right;
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-top: 1px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.commits.table {
|
||||||
|
font-size: 13px;
|
||||||
|
th, td {
|
||||||
|
&:first-child {
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
line-height: 15px;
|
||||||
|
}
|
||||||
|
.author {
|
||||||
|
min-width: 180px;
|
||||||
|
}
|
||||||
|
.sha {
|
||||||
|
a {
|
||||||
|
font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
|
||||||
|
font-size: 14px;
|
||||||
|
padding: 6px 10px 4px 10px;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.message span {
|
||||||
|
max-width: 500px;
|
||||||
|
}
|
||||||
|
.date {
|
||||||
|
width: 120px;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.ui.comments {
|
.ui.comments {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.user {
|
.user {
|
||||||
padding-top: 15px;
|
padding-top: 15px;
|
||||||
padding-bottom: @footer-margin * 3;
|
padding-bottom: @footer-margin * 2;
|
||||||
|
|
||||||
&.settings {
|
&.settings {
|
||||||
.key.list {
|
.key.list {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"path"
|
"path"
|
||||||
|
|
||||||
"github.com/Unknwon/com"
|
"github.com/Unknwon/com"
|
||||||
|
"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"
|
||||||
|
@ -44,7 +45,7 @@ func RenderIssueLinks(oldCommits *list.List, repoLink string) *list.List {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Commits(ctx *middleware.Context) {
|
func Commits(ctx *middleware.Context) {
|
||||||
ctx.Data["IsRepoToolbarCommits"] = true
|
ctx.Data["PageIsCommits"] = true
|
||||||
|
|
||||||
userName := ctx.Repo.Owner.Name
|
userName := ctx.Repo.Owner.Name
|
||||||
repoName := ctx.Repo.Repository.Name
|
repoName := ctx.Repo.Repository.Name
|
||||||
|
@ -64,19 +65,11 @@ func Commits(ctx *middleware.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate and validate page number.
|
page := ctx.QueryInt("page")
|
||||||
page, _ := com.StrTo(ctx.Query("p")).Int()
|
if page <= 1 {
|
||||||
if page < 1 {
|
|
||||||
page = 1
|
page = 1
|
||||||
}
|
}
|
||||||
lastPage := page - 1
|
ctx.Data["Page"] = paginater.New(commitsCount, git.CommitsRangeSize, page, 5)
|
||||||
if lastPage < 0 {
|
|
||||||
lastPage = 0
|
|
||||||
}
|
|
||||||
nextPage := page + 1
|
|
||||||
if page*50 > commitsCount {
|
|
||||||
nextPage = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Both `git log branchName` and `git log commitId` work.
|
// Both `git log branchName` and `git log commitId` work.
|
||||||
commits, err := ctx.Repo.Commit.CommitsByRange(page)
|
commits, err := ctx.Repo.Commit.CommitsByRange(page)
|
||||||
|
@ -91,14 +84,11 @@ func Commits(ctx *middleware.Context) {
|
||||||
ctx.Data["Username"] = userName
|
ctx.Data["Username"] = userName
|
||||||
ctx.Data["Reponame"] = repoName
|
ctx.Data["Reponame"] = repoName
|
||||||
ctx.Data["CommitCount"] = commitsCount
|
ctx.Data["CommitCount"] = commitsCount
|
||||||
ctx.Data["LastPageNum"] = lastPage
|
|
||||||
ctx.Data["NextPageNum"] = nextPage
|
|
||||||
ctx.HTML(200, COMMITS)
|
ctx.HTML(200, COMMITS)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SearchCommits(ctx *middleware.Context) {
|
func SearchCommits(ctx *middleware.Context) {
|
||||||
ctx.Data["IsSearchPage"] = true
|
ctx.Data["PageIsCommits"] = true
|
||||||
ctx.Data["IsRepoToolbarCommits"] = true
|
|
||||||
|
|
||||||
keyword := ctx.Query("q")
|
keyword := ctx.Query("q")
|
||||||
if len(keyword) == 0 {
|
if len(keyword) == 0 {
|
||||||
|
@ -253,7 +243,7 @@ func Diff(ctx *middleware.Context) {
|
||||||
ctx.Data["Parents"] = parents
|
ctx.Data["Parents"] = parents
|
||||||
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
|
||||||
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId)
|
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", commitId)
|
||||||
if (commit.ParentCount() > 0) {
|
if commit.ParentCount() > 0 {
|
||||||
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0])
|
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "src", parents[0])
|
||||||
}
|
}
|
||||||
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId)
|
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(userName, repoName, "raw", commitId)
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
{{template "ng/base/head" .}}
|
{{template "base/head" .}}
|
||||||
{{template "ng/base/header" .}}
|
<div class="repository commits">
|
||||||
<div id="repo-wrapper">
|
{{template "repo/header" .}}
|
||||||
{{template "repo/header_old" .}}
|
<div class="ui container">
|
||||||
<div class="container clear">
|
|
||||||
{{template "repo/commits_table" .}}
|
{{template "repo/commits_table" .}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "ng/base/footer" .}}
|
{{template "base/footer" .}}
|
||||||
|
|
|
@ -1,48 +1,66 @@
|
||||||
<div id="commits-list">
|
<h4 class="ui top attached header">
|
||||||
<div class="panel panel-radius">
|
{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}
|
||||||
<div class="panel-header">
|
{{if .PageIsCommits}}
|
||||||
{{if not .IsDiffCompare}}
|
<div class="ui right">
|
||||||
<form class="search pull-right" action="{{.RepoLink}}/commits/{{.BranchName}}/search" method="get" id="commits-search-form">
|
<form action="{{.RepoLink}}/commits/{{.BranchName}}/search">
|
||||||
<input class="ipt ipt-radius" type="search" name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" />
|
<div class="ui tiny search input">
|
||||||
<button class="btn btn-black btn-small btn-radius">{{.i18n.Tr "repo.commits.find"}}</button>
|
<input name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" autofocus>
|
||||||
</form>
|
|
||||||
{{end}}
|
|
||||||
<h4>{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}</h4>
|
|
||||||
</div>
|
</div>
|
||||||
<table class="panel-body table commit-list table-striped">
|
<button class="ui black tiny button" data-panel="#add-deploy-key-panel">{{.i18n.Tr "repo.commits.find"}}</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
</h4>
|
||||||
|
<div class="ui attached table segment">
|
||||||
|
<table class="ui very basic striped commits table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="author">{{.i18n.Tr "repo.commits.author"}}</th>
|
<th>{{.i18n.Tr "repo.commits.author"}}</th>
|
||||||
<th class="sha">SHA1</th>
|
<th>SHA1</th>
|
||||||
<th class="message">{{.i18n.Tr "repo.commits.message"}}</th>
|
<th>{{.i18n.Tr "repo.commits.message"}}</th>
|
||||||
<th class="date">{{.i18n.Tr "repo.commits.date"}}</th>
|
<th>{{.i18n.Tr "repo.commits.date"}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{ $username := .Username}}
|
{{ $username := .Username}}
|
||||||
{{ $reponame := .Reponame}}
|
{{ $reponame := .Reponame}}
|
||||||
{{$r := List .Commits}}
|
{{ $r:= List .Commits}}
|
||||||
{{range $r}}
|
{{range $r}}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="author">
|
<td class="author">
|
||||||
{{if .User}}
|
{{if .User}}
|
||||||
<img class="avatar-20" src="{{.User.AvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
|
<img class="ui avatar image" src="{{.User.AvatarLink}}" alt=""/> <a href="{{AppSubUrl}}/{{.User.Name}}">{{.Author.Name}}</a>
|
||||||
{{else}}
|
{{else}}
|
||||||
<img class="avatar-20" src="{{AvatarLink .Author.Email}}" alt=""/> {{.Author.Name}}
|
<img class="ui avatar image" src="{{AvatarLink .Author.Email}}" alt=""/> {{.Author.Name}}
|
||||||
{{end}}
|
{{end}}
|
||||||
</td>
|
</td>
|
||||||
<td class="sha"><a rel="nofollow" class="label label-green" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
<td class="sha"><a rel="nofollow" class="ui green label" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
|
||||||
<td class="message"><span class="text-truncate">{{RenderCommitMessage .Summary $.RepoLink}}</span></td>
|
<td class="message"><span class="text truncate">{{RenderCommitMessage .Summary $.RepoLink}}</span></td>
|
||||||
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
<td class="date">{{TimeSince .Author.When $.Lang}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{end}}
|
{{end}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
|
||||||
{{if and (not .IsSearchPage) (not .IsDiffCompare)}}
|
|
||||||
<ul class="pagination">
|
|
||||||
{{if .LastPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.LastPageNum}}" rel="nofollow">« {{.i18n.Tr "repo.commits.newer"}}</a></li>{{end}}
|
|
||||||
{{if .NextPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.NextPageNum}}" rel="nofollow">» {{.i18n.Tr "repo.commits.older"}}</a></li>{{end}}
|
|
||||||
</ul>
|
|
||||||
{{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="{{$.RepoLink}}/commits/{{$.BranchName}}{{if $.FileName}}/{{$.FileName}}{{end}}?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="{{$.RepoLink}}/commits/{{$.BranchName}}{{if $.FileName}}/{{$.FileName}}{{end}}?page={{.Num}}"{{end}}>{{.Num}}</a>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
<a class="{{if not .HasNext}}disabled{{end}} item" {{if .HasNext}}href="{{$.RepoLink}}/commits/{{$.BranchName}}{{if $.FileName}}/{{$.FileName}}{{end}}?page={{.Next}}"{{end}}>
|
||||||
|
{{$.i18n.Tr "repo.issues.next"}} <i class="icon right arrow"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
|
@ -1,8 +1,7 @@
|
||||||
{{template "ng/base/head" .}}
|
{{template "base/head" .}}
|
||||||
{{template "ng/base/header" .}}
|
<div class="repository diff">
|
||||||
<div id="repo-wrapper">
|
{{template "repo/header" .}}
|
||||||
{{template "repo/header_old" .}}
|
<div class="ui container">
|
||||||
<div class="container clear" id="diff-page">
|
|
||||||
{{if .IsDiffCompare }}
|
{{if .IsDiffCompare }}
|
||||||
<div class="panel panel-info panel-radius compare-head-box">
|
<div class="panel panel-info panel-radius compare-head-box">
|
||||||
<div class="panel-header">
|
<div class="panel-header">
|
||||||
|
@ -10,9 +9,9 @@
|
||||||
<h4><a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="label label-green">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="label label-green">{{ShortSha .AfterCommitId}}</a></h4>
|
<h4><a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="label label-green">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="label label-green">{{ShortSha .AfterCommitId}}</a></h4>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body compare">
|
<div class="panel-body compare">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{template "repo/commits_table" .}}
|
{{template "repo/commits_table" .}}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="panel panel-info panel-radius diff-head-box">
|
<div class="panel panel-info panel-radius diff-head-box">
|
||||||
<div class="panel-header">
|
<div class="panel-header">
|
||||||
|
@ -42,6 +41,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if .DiffNotAvailable}}
|
{{if .DiffNotAvailable}}
|
||||||
<h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
|
<h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -131,4 +131,4 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{template "ng/base/footer" .}}
|
{{template "base/footer" .}}
|
||||||
|
|
Loading…
Reference in a new issue