From 5bbeeb0f1b5cecb67e1527410a45fb65df0096d1 Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 23 Sep 2014 15:30:04 -0400 Subject: [PATCH] Page: Commits and fix #249 --- conf/locale/locale_en-US.ini | 9 +++++++ conf/locale/locale_zh-CN.ini | 9 +++++++ models/repo.go | 14 ++++++++++ models/user.go | 29 +++++++++++++++++++++ public/ng/css/gogs.css | 26 +++++++++++++++++++ public/ng/css/ui.css | 4 +++ public/ng/less/gogs/base.less | 5 ++++ public/ng/less/gogs/repository.less | 33 +++++++++++++++++++----- public/ng/less/ui/label.less | 8 +++--- routers/repo/commit.go | 4 ++- templates/admin/user/list.tmpl | 4 +-- templates/repo/commits.tmpl | 15 ++++++----- templates/repo/commits_table.tmpl | 40 ++++++++++++++--------------- 13 files changed, 160 insertions(+), 40 deletions(-) diff --git a/conf/locale/locale_en-US.ini b/conf/locale/locale_en-US.ini index b241e45dd..15d8028c4 100644 --- a/conf/locale/locale_en-US.ini +++ b/conf/locale/locale_en-US.ini @@ -258,6 +258,15 @@ issues = Issues commits = Commits releases = Releases +commits.commits = Commits +commits.search = Search commits +commits.find = Find +commits.author = Author +commits.message = Message +commits.date = Date +commits.older = Older +commits.newer = Newer + settings = Settings settings.options = Options settings.collaboration = Collaboration diff --git a/conf/locale/locale_zh-CN.ini b/conf/locale/locale_zh-CN.ini index 2957cf908..e479f5cdf 100644 --- a/conf/locale/locale_zh-CN.ini +++ b/conf/locale/locale_zh-CN.ini @@ -258,6 +258,15 @@ issues = 工单管理 commits = 提交历史 releases = 版本发布 +commits.commits = 次代码提交 +commits.search = 搜索提交历史 +commits.find = 查找 +commits.author = 作者 +commits.message = 备注 +commits.date = 提交日期 +commits.older = 更旧的提交 +commits.newer = 更新的提交 + settings = 仓库设置 settings.options = 基本设置 settings.collaboration = 管理协作者 diff --git a/models/repo.go b/models/repo.go index ccfaae2ca..c0a581b9a 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1081,6 +1081,13 @@ func SearchRepositoryByName(opt SearchOption) (repos []*Repository, err error) { return repos, err } +// __ __ __ .__ +// / \ / \_____ _/ |_ ____ | |__ +// \ \/\/ /\__ \\ __\/ ___\| | \ +// \ / / __ \| | \ \___| Y \ +// \__/\ / (____ /__| \___ >___| / +// \/ \/ \/ \/ + // Watch is connection request for receiving repository notifycation. type Watch struct { Id int64 @@ -1151,6 +1158,13 @@ func NotifyWatchers(act *Action) error { return nil } +// _________ __ +// / _____// |______ _______ +// \_____ \\ __\__ \\_ __ \ +// / \| | / __ \| | \/ +// /_______ /|__| (____ /__| +// \/ \/ + type Star struct { Id int64 Uid int64 `xorm:"UNIQUE(s)"` diff --git a/models/user.go b/models/user.go index 46e1b1554..c09a77265 100644 --- a/models/user.go +++ b/models/user.go @@ -5,6 +5,7 @@ package models import ( + "container/list" "crypto/sha256" "encoding/hex" "errors" @@ -513,6 +514,34 @@ func GetUserIdsByNames(names []string) []int64 { return ids } +// UserCommit represtns a commit with validation of user. +type UserCommit struct { + UserName string + *git.Commit +} + +// ValidCommitsWithEmails checks if authors' e-mails of commits are correcponding to users. +func ValidCommitsWithEmails(oldCommits *list.List) *list.List { + newCommits := list.New() + e := oldCommits.Front() + for e != nil { + c := e.Value.(*git.Commit) + + uname := "" + u, err := GetUserByEmail(c.Author.Email) + if err == nil { + uname = u.Name + } + + newCommits.PushBack(UserCommit{ + UserName: uname, + Commit: c, + }) + e = e.Next() + } + return newCommits +} + // GetUserByEmail returns the user object by given e-mail if exists. func GetUserByEmail(email string) (*User, error) { if len(email) == 0 { diff --git a/public/ng/css/gogs.css b/public/ng/css/gogs.css index d11ae959d..662a737f1 100644 --- a/public/ng/css/gogs.css +++ b/public/ng/css/gogs.css @@ -20,6 +20,11 @@ img.avatar-16 { height: 16px; vertical-align: middle; } +img.avatar-20 { + width: 20px; + height: 20px; + vertical-align: middle; +} img.avatar-24 { width: 24px; height: 24px; @@ -1446,6 +1451,27 @@ The register and sign-in page style width: 100%; list-style: none; } +#commits-list { + padding-top: 20px; +} +.commit-list th { + background-color: #FFF; + line-height: 28px !important; +} +.commit-list .date { + width: 120px; +} +.commit-list .author { + padding-left: 20px; + min-width: 180px; +} +.commit-list .author img { + margin-top: -4px; +} +.commit-list .sha a { + font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace; + font-size: 14px; +} #admin-wrapper, #setting-wrapper { padding-bottom: 100px; diff --git a/public/ng/css/ui.css b/public/ng/css/ui.css index 5dc3cc040..bd2eb4c93 100644 --- a/public/ng/css/ui.css +++ b/public/ng/css/ui.css @@ -732,6 +732,10 @@ ul.menu-radius > li:last-child > a { .label-green { background-color: #65ad4e; } +.label-green:hover { + background-color: #71bf57; + color: #FFF; +} .label-orange { background-color: #df7514; } diff --git a/public/ng/less/gogs/base.less b/public/ng/less/gogs/base.less index 47d8b1b65..4319a56ee 100644 --- a/public/ng/less/gogs/base.less +++ b/public/ng/less/gogs/base.less @@ -30,6 +30,11 @@ img.avatar-16 { height: 16px; vertical-align: middle; } +img.avatar-20 { + width: 20px; + height: 20px; + vertical-align: middle; +} img.avatar-24 { width: 24px; height: 24px; diff --git a/public/ng/less/gogs/repository.less b/public/ng/less/gogs/repository.less index d98249136..7d6cdd0a5 100644 --- a/public/ng/less/gogs/repository.less +++ b/public/ng/less/gogs/repository.less @@ -6,14 +6,12 @@ /* repository main */ #repo-wrapper { - padding-bottom: 100px; + padding-bottom: 100px; } #repo-header { - height: 69px; - border-bottom: 1px solid@repoHeaderBorderColor; - - background-color: @repoHeaderBgColor; - + height: 69px; + border-bottom: 1px solid@repoHeaderBorderColor; + background-color: @repoHeaderBgColor; } #repo-header-name { line-height: 66px; @@ -494,4 +492,27 @@ .setting-list { width: 100%; list-style: none; +} +#commits-list { + padding-top: 20px; +} +.commit-list { + th { + background-color: #FFF; + line-height: 28px !important; + } + .date { + width: 120px; + } + .author { + padding-left: 20px; + min-width: 180px; + img { + margin-top: -4px; + } + } + .sha a { + font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace; + font-size: 14px; + } } \ No newline at end of file diff --git a/public/ng/less/ui/label.less b/public/ng/less/ui/label.less index a2a8a6790..21a4c82d3 100644 --- a/public/ng/less/ui/label.less +++ b/public/ng/less/ui/label.less @@ -16,11 +16,13 @@ .label-gray { background-color: @labelGrayColor; } - .label-green { - background-color: @labelGreenColor; + background-color: @labelGreenColor; + &:hover { + background-color: @btnHoverGreenColor; + color: #FFF; + } } - .label-orange { background-color: @labelOrangeColor; } diff --git a/routers/repo/commit.go b/routers/repo/commit.go index 218cae7be..c23fdfe7c 100644 --- a/routers/repo/commit.go +++ b/routers/repo/commit.go @@ -56,12 +56,14 @@ func Commits(ctx *middleware.Context) { } // Both `git log branchName` and `git log commitId` work. - ctx.Data["Commits"], err = ctx.Repo.Commit.CommitsByRange(page) + commits, err := ctx.Repo.Commit.CommitsByRange(page) if err != nil { ctx.Handle(500, "CommitsByRange", err) return } + commits = models.ValidCommitsWithEmails(commits) + ctx.Data["Commits"] = commits ctx.Data["Username"] = userName ctx.Data["Reponame"] = repoName ctx.Data["CommitCount"] = commitsCount diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index 1092539ec..a09863ae6 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -45,8 +45,8 @@ {{if or .LastPageNum .NextPageNum}} {{end}} diff --git a/templates/repo/commits.tmpl b/templates/repo/commits.tmpl index e7518e983..2f68f1e01 100644 --- a/templates/repo/commits.tmpl +++ b/templates/repo/commits.tmpl @@ -1,8 +1,9 @@ -{{template "base/head" .}} -{{template "base/navbar" .}} -{{template "repo/nav" .}} -{{template "repo/toolbar" .}} -
- {{template "repo/commits_table" .}} +{{template "ng/base/head" .}} +{{template "ng/base/header" .}} +
+ {{template "repo/header" .}} +
+ {{template "repo/commits_table" .}} +
-{{template "base/footer" .}} +{{template "ng/base/footer" .}} diff --git a/templates/repo/commits_table.tmpl b/templates/repo/commits_table.tmpl index cb2ed5d0c..032299b10 100644 --- a/templates/repo/commits_table.tmpl +++ b/templates/repo/commits_table.tmpl @@ -1,23 +1,19 @@ -
-
-
-