]> source.dussan.org Git - gitea.git/commitdiff
Page: Commits and fix #249
authorUnknwon <joe2010xtmf@163.com>
Tue, 23 Sep 2014 19:30:04 +0000 (15:30 -0400)
committerUnknwon <joe2010xtmf@163.com>
Tue, 23 Sep 2014 19:30:04 +0000 (15:30 -0400)
13 files changed:
conf/locale/locale_en-US.ini
conf/locale/locale_zh-CN.ini
models/repo.go
models/user.go
public/ng/css/gogs.css
public/ng/css/ui.css
public/ng/less/gogs/base.less
public/ng/less/gogs/repository.less
public/ng/less/ui/label.less
routers/repo/commit.go
templates/admin/user/list.tmpl
templates/repo/commits.tmpl
templates/repo/commits_table.tmpl

index b241e45dd7d04943c91ee92fe7b0d59c3e0211d4..15d8028c4ffd97b6b8ac457c3cbbfa098b8f33f4 100644 (file)
@@ -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
index 2957cf9085a21acee5dc585737cfc39b234396a3..e479f5cdf73fb8a384a68f1a146c3f1cf772a4ee 100644 (file)
@@ -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 = 管理协作者
index ccfaae2ca22bd6f3115df39f26033825498ff5f8..c0a581b9a25b2d66ba96fd3d483ffafefcf3cdb1 100644 (file)
@@ -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)"`
index 46e1b1554bf9afbfaa2ebb01774fba93c6eb4aa2..c09a77265f7adffdaddc6e38c2436ce006e1890d 100644 (file)
@@ -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 {
index d11ae959dc2c6f08f07808bb6c124e3cc7406b7c..662a737f145106522efa80d740b7cae2f201db0e 100644 (file)
@@ -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;
index 5dc3cc0408724042a639086fcb02d7dbbdd93124..bd2eb4c93cfdb703e05b75e9149e6329ab6a7e35 100644 (file)
@@ -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;
 }
index 47d8b1b65c747cb9d9c29c73d1969cc98fee2819..4319a56ee522df2443864fc5c4a123c7a4f2a154 100644 (file)
@@ -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;
index d982491365dab35707b2badf4a4e4881d95db579..7d6cdd0a5d8f8bcd68c731ca45281441e1a344d0 100644 (file)
@@ -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;
 .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
index a2a8a67905797429815fe7678c47ab6c7a7effea..21a4c82d3d32396882b40f5d2c277c2b21316033 100644 (file)
 .label-gray {
   background-color: @labelGrayColor;
 }
-
 .label-green {
-  background-color: @labelGreenColor;
+    background-color: @labelGreenColor;
+    &:hover {
+        background-color: @btnHoverGreenColor;
+        color: #FFF;
+    }
 }
-
 .label-orange {
   background-color: @labelOrangeColor;
 }
index 218cae7bed8f12dac36236855858b316dd68c968..c23fdfe7c614570315a3974167eab7b3580b0daf 100644 (file)
@@ -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
index 1092539ecf86971766f0ceebf87e973bb26622d0..a09863ae6194585159545a4d8aa1097f0f4c52a1 100644 (file)
@@ -45,8 +45,8 @@
                                                        </table>
                                                        {{if or .LastPageNum .NextPageNum}}
                                                        <ul class="pagination">
-                                                           {{if .LastPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{AppSubUrl}}/admin/users?p={{.LastPageNum}}">&laquo; Prev.</a></li>{{end}}
-                                                           {{if .NextPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{AppSubUrl}}/admin/users?p={{.NextPageNum}}">&raquo; Next</a></li>{{end}}
+                                                           {{if .LastPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{AppSubUrl}}/admin/users?p={{.LastPageNum}}">&laquo; {{.i18n.Tr "admin.prev"}}</a></li>{{end}}
+                                                           {{if .NextPageNum}}<li><a class="btn btn-medium btn-gray btn-radius" href="{{AppSubUrl}}/admin/users?p={{.NextPageNum}}">&raquo; {{.i18n.Tr "admin.next"}}</a></li>{{end}}
                                                        </ul>
                                                        {{end}}
                                                </div>
index e7518e983529ea031fac5b2088f4a27887fdd7c7..2f68f1e01c88cd96221ef7fac4be2b2899994a81 100644 (file)
@@ -1,8 +1,9 @@
-{{template "base/head" .}}
-{{template "base/navbar" .}}
-{{template "repo/nav" .}}
-{{template "repo/toolbar" .}}
-<div id="body" class="container">
-  {{template "repo/commits_table" .}}
+{{template "ng/base/head" .}}
+{{template "ng/base/header" .}}
+<div id="repo-wrapper">
+    {{template "repo/header" .}}
+       <div class="container clear">
+               {{template "repo/commits_table" .}}
+       </div>
 </div>
-{{template "base/footer" .}}
+{{template "ng/base/footer" .}}
index cb2ed5d0cb74517229f4b352b6064b3b1a240694..032299b10267a9bef2102686edb3921ed8a9b386 100644 (file)
@@ -1,23 +1,19 @@
-<div id="commits">
-    <div class="panel panel-default commit-box info-box">
-        <div class="panel-heading info-head">
-            <form class="search pull-right col-md-3" action="{{.RepoLink}}/commits/{{.BranchName}}/search" method="get" id="commits-search-form">
-                <div class="input-group">
-                    <input class="form-control search" type="search" placeholder="search commit" name="q" value="{{.Keyword}}" />
-                    <div class="input-group-btn">
-                        <button type="submit" class="btn btn-default">Find</button>
-                    </div>
-                </div>
+<div id="commits-list">
+    <div class="panel panel-radius">
+        <div class="panel-header">
+            <form class="search pull-right" action="{{.RepoLink}}/commits/{{.BranchName}}/search" method="get" id="commits-search-form">
+                <input class="ipt ipt-radius" type="search" name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" />
+                <button class="btn btn-black btn-small btn-radius">{{.i18n.Tr "repo.commits.find"}}</button>
             </form>
-            <h4>{{.CommitCount}} Commits</h4>
+            <h4>{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}</h4>
         </div>
-        <table class="panel-footer table commit-list table table-striped">
+        <table class="panel-body table commit-list table-striped">
             <thead>
                 <tr>
-                    <th class="author">Author</th>
+                    <th class="author">{{.i18n.Tr "repo.commits.author"}}</th>
                     <th class="sha">SHA1</th>
-                    <th class="message">Message</th>
-                    <th class="date">Date</th>
+                    <th class="message">{{.i18n.Tr "repo.commits.message"}}</th>
+                    <th class="date">{{.i18n.Tr "repo.commits.date"}}</th>
                 </tr>
             </thead>
             <tbody>
@@ -26,8 +22,8 @@
             {{$r := List .Commits}}
             {{range $r}}
             <tr>
-                <td class="author"><img class="avatar" src="{{AvatarLink .Author.Email}}" alt=""/><a href="{{AppSubUrl}}/user/email2user?email={{.Author.Email}}">{{.Author.Name}}</a></td>
-                <td class="sha"><a rel="nofollow" class="label label-success" href="{{AppSubUrl}}/{{$username}}/{{$reponame}}/commit/{{.Id}} ">{{SubStr .Id.String 0 10}} </a></td>
+                <td class="author"><img class="avatar-20" src="{{AvatarLink .Author.Email}}" alt=""/>&nbsp;&nbsp;&nbsp;{{if .UserName}}<a href="{{AppSubUrl}}/{{.UserName}}">{{.Author.Name}}</a>{{else}}{{.Author.Name}}{{end}}</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="message">{{.Summary}} </td>
                 <td class="date">{{TimeSince .Author.When $.Lang}}</td>
             </tr>
             </tbody>
         </table>
     </div>
-    {{if not .IsSearchPage}}<ul class="pagination" id="commits-pager">
-        {{if .LastPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.LastPageNum}}" rel="nofollow">&laquo; Newer</a></li>{{end}}
-        {{if .NextPageNum}}<li><a href="{{.RepoLink}}/commits/{{.BranchName}}{{if .FileName}}/{{.FileName}}{{end}}?p={{.NextPageNum}}" rel="nofollow">&raquo; Older</a></li>{{end}}
-    </ul>{{end}}
+    {{if not .IsSearchPage}}
+    <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">&laquo; {{.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">&raquo; {{.i18n.Tr "repo.commits.older"}}</a></li>{{end}}
+    </ul>
+    {{end}}
 </div>