Browse Source

Page: Compare 2 commits

Unknwon 5 years ago
parent
commit
b2632dec09

+ 1 - 0
README.md

@@ -32,6 +32,7 @@ The goal of this project is to make the easiest, fastest and most painless way t
32 32
 - Activity timeline
33 33
 - SSH/HTTP(S) protocol support
34 34
 - SMTP/LDAP/reverse proxy authentication support
35
+- Reverse proxy suburl support
35 36
 - Register/delete/rename account
36 37
 - Create/manage/delete organization with team management
37 38
 - Create/migrate/mirror/delete/watch/rename/transfer public/private repository

+ 1 - 0
README_ZH.md

@@ -23,6 +23,7 @@ Gogs 的目标是打造一个最简单、最快速和最轻松的方式搭建自
23 23
 - 活动时间线
24 24
 - 支持 SSH/HTTP(S) 协议
25 25
 - 支持 SMTP/LDAP/反向代理 用户认证
26
+- 支持反向代理子路径
26 27
 - 注册/删除/重命名 用户
27 28
 - 创建/管理/删除 组织以及团队管理功能
28 29
 - 创建/迁移/镜像/删除/关注/重命名/转移 公开/私有 仓库

+ 1 - 0
cmd/dump.go

@@ -60,6 +60,7 @@ func runDump(ctx *cli.Context) {
60 60
 	z.AddFile("gogs-db.sql", path.Join(workDir, "gogs-db.sql"))
61 61
 	z.AddFile("custom/conf/app.ini", path.Join(workDir, "custom/conf/app.ini"))
62 62
 	z.AddDir("log", path.Join(workDir, "log"))
63
+	// FIXME: SSH key file.
63 64
 	if err = z.Close(); err != nil {
64 65
 		os.Remove(fileName)
65 66
 		log.Fatalf("Fail to save %s: %v", fileName, err)

+ 10 - 0
conf/locale/locale_en-US.ini

@@ -337,6 +337,15 @@ settings.slack_token = Token
337 337
 settings.slack_domain = Domain
338 338
 settings.slack_channel = Channel
339 339
 
340
+diff.browse_source = Browse Source
341
+diff.parent = parent
342
+diff.commit = commit
343
+diff.data_not_available = Diff Data Not Available.
344
+diff.show_diff_stats = Show Diff Stats
345
+diff.stats_desc = <strong> %d changed files</strong> with <strong>%d additions</strong> and <strong>%d deletions</strong>
346
+diff.bin = BIN
347
+diff.view_file = View File
348
+
340 349
 [org]
341 350
 org_name_holder = Organization Name
342 351
 org_name_helper = Great organization names are short and memorable.
@@ -609,6 +618,7 @@ commit_repo = pushed to <a href="%s/%s/src/%s">%s</a> at <a href="%s/%s">%s</a>
609 618
 create_issue = opened issue <a href="%s/%s/issues/%s">%s#%s</a>
610 619
 comment_issue = commented on issue <a href="%s/%s/issues/%s">%s#%s</a>
611 620
 transfer_repo = transfered repository <code>%s</code> to <a href="/%s%s">%s</a>
621
+compare_2_commits = View comparison for these 2 commits
612 622
 
613 623
 [tool]
614 624
 ago = ago

+ 10 - 0
conf/locale/locale_zh-CN.ini

@@ -337,6 +337,15 @@ settings.slack_token = 令牌
337 337
 settings.slack_domain = 域名
338 338
 settings.slack_channel = 频道
339 339
 
340
+diff.browse_source = 浏览代码
341
+diff.parent = 父节点
342
+diff.commit = 当前提交
343
+diff.data_not_available = 暂无可用数据
344
+diff.show_diff_stats = 显示文件统计
345
+diff.stats_desc = 共有 <strong> %d 个文件被更改</strong>,包括 <strong>%d 次插入</strong> 和 <strong>%d 次删除</strong>
346
+diff.bin = 二进制
347
+diff.view_file = 查看文件
348
+
340 349
 [org]
341 350
 org_name_holder = 组织名称
342 351
 org_name_helper = 伟大的组织都有一个简短而寓意深刻的名字。
@@ -609,6 +618,7 @@ commit_repo = 推送了 <a href="%s/%s/src/%s">%s</a> 分支的代码到 <a href
609 618
 create_issue = 创建了工单 <a href="%s/%s/issues/%s">%s#%s</a>
610 619
 comment_issue = 评论了工单 <a href="%s/%s/issues/%s">%s#%s</a>
611 620
 transfer_repo = 将仓库 <code>%s</code> 转移至 <a href="/%s%s">%s</a>
621
+compare_2_commits = 查看 2 次提交的内容对比
612 622
 
613 623
 [tool]
614 624
 ago = 之前

+ 8 - 10
models/action.go

@@ -181,13 +181,19 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
181 181
 		commit = &base.PushCommits{}
182 182
 	}
183 183
 
184
-	refName := git.RefEndName(refFullName)
184
+	repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
185
+	// if not the first commit, set the compareUrl
186
+	if !strings.HasPrefix(oldCommitId, "0000000") {
187
+		commit.CompareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
188
+	}
185 189
 
186 190
 	bs, err := json.Marshal(commit)
187 191
 	if err != nil {
188 192
 		return errors.New("action.CommitRepoAction(json): " + err.Error())
189 193
 	}
190 194
 
195
+	refName := git.RefEndName(refFullName)
196
+
191 197
 	// Change repository bare status and update last updated time.
192 198
 	repo, err := GetRepositoryByName(repoUserId, repoName)
193 199
 	if err != nil {
@@ -211,7 +217,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
211 217
 		return errors.New("action.CommitRepoAction(NotifyWatchers): " + err.Error())
212 218
 
213 219
 	}
214
-	//qlog.Info("action.CommitRepoAction(end): %d/%s", repoUserId, repoName)
215 220
 
216 221
 	// New push event hook.
217 222
 	if err := repo.GetOwner(); err != nil {
@@ -237,13 +242,6 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
237 242
 		return nil
238 243
 	}
239 244
 
240
-	repoLink := fmt.Sprintf("%s%s/%s", setting.AppUrl, repoUserName, repoName)
241
-	compareUrl := ""
242
-	// if not the first commit, set the compareUrl
243
-	if !strings.HasPrefix(oldCommitId, "0000000") {
244
-		compareUrl = fmt.Sprintf("%s/compare/%s...%s", repoLink, oldCommitId, newCommitId)
245
-	}
246
-
247 245
 	pusher_email, pusher_name := "", ""
248 246
 	pusher, err := GetUserByName(userName)
249 247
 	if err == nil {
@@ -293,7 +291,7 @@ func CommitRepoAction(userId, repoUserId int64, userName, actEmail string,
293 291
 		},
294 292
 		Before:     oldCommitId,
295 293
 		After:      newCommitId,
296
-		CompareUrl: compareUrl,
294
+		CompareUrl: commit.CompareUrl,
297 295
 	}
298 296
 
299 297
 	for _, w := range ws {

+ 4 - 5
models/update.go

@@ -106,7 +106,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
106 106
 
107 107
 		if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
108 108
 			repos.Id, repoUserName, repoName, refName, commit, oldCommitId, newCommitId); err != nil {
109
-			log.GitLogger.Fatal(4, "runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
109
+			log.GitLogger.Fatal(4, "CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
110 110
 		}
111 111
 		return err
112 112
 	}
@@ -116,8 +116,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
116 116
 		return fmt.Errorf("runUpdate GetCommit of newCommitId: %v", err)
117 117
 	}
118 118
 
119
+	// Push new branch.
119 120
 	var l *list.List
120
-	// if a new branch
121 121
 	if isNew {
122 122
 		l, err = newCommit.CommitsBefore()
123 123
 		if err != nil {
@@ -134,7 +134,7 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
134 134
 		return fmt.Errorf("runUpdate.Commit repoId: %v", err)
135 135
 	}
136 136
 
137
-	// if commits push
137
+	// Push commits.
138 138
 	commits := make([]*base.PushCommit, 0)
139 139
 	var actEmail string
140 140
 	for e := l.Front(); e != nil; e = e.Next() {
@@ -153,9 +153,8 @@ func Update(refName, oldCommitId, newCommitId, userName, repoUserName, repoName
153 153
 		}
154 154
 	}
155 155
 
156
-	//commits = append(commits, []string{lastCommit.Id().String(), lastCommit.Message()})
157 156
 	if err = CommitRepoAction(userId, ru.Id, userName, actEmail,
158
-		repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits}, oldCommitId, newCommitId); err != nil {
157
+		repos.Id, repoUserName, repoName, refName, &base.PushCommits{l.Len(), commits, ""}, oldCommitId, newCommitId); err != nil {
159 158
 		return fmt.Errorf("runUpdate.models.CommitRepoAction: %s/%s:%v", repoUserName, repoName, err)
160 159
 	}
161 160
 	return nil

+ 3 - 63
modules/base/template.go

@@ -5,7 +5,6 @@
5 5
 package base
6 6
 
7 7
 import (
8
-	"bytes"
9 8
 	"container/list"
10 9
 	"encoding/json"
11 10
 	"errors"
@@ -107,7 +106,6 @@ var TemplateFuncs template.FuncMap = map[string]interface{}{
107 106
 		return a + b
108 107
 	},
109 108
 	"ActionIcon": ActionIcon,
110
-	"ActionDesc": ActionDesc,
111 109
 	"DateFormat": DateFormat,
112 110
 	"List":       List,
113 111
 	"Mail2Domain": func(mail string) string {
@@ -162,19 +160,6 @@ func ActionIcon(opType int) string {
162 160
 	}
163 161
 }
164 162
 
165
-// FIXME: Legacy
166
-const (
167
-	TPL_CREATE_REPO    = `<a href="%s/user/%s">%s</a> created repository <a href="%s">%s</a>`
168
-	TPL_COMMIT_REPO    = `<a href="%s/user/%s">%s</a> pushed to <a href="%s/src/%s">%s</a> at <a href="%s">%s</a>%s`
169
-	TPL_COMMIT_REPO_LI = `<div><img src="%s?s=16" alt="user-avatar"/> <a href="%s/commit/%s" rel="nofollow">%s</a> %s</div>`
170
-	TPL_CREATE_ISSUE   = `<a href="%s/user/%s">%s</a> opened issue <a href="%s/issues/%s">%s#%s</a>
171
-<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
172
-	TPL_TRANSFER_REPO = `<a href="%s/user/%s">%s</a> transfered repository <code>%s</code> to <a href="%s">%s</a>`
173
-	TPL_PUSH_TAG      = `<a href="%s/user/%s">%s</a> pushed tag <a href="%s/src/%s" rel="nofollow">%s</a> at <a href="%s">%s</a>`
174
-	TPL_COMMENT_ISSUE = `<a href="%s/user/%s">%s</a> commented on issue <a href="%s/issues/%s">%s#%s</a>
175
-<div><img src="%s?s=16" alt="user-avatar"/> %s</div>`
176
-)
177
-
178 163
 type PushCommit struct {
179 164
 	Sha1        string
180 165
 	Message     string
@@ -183,8 +168,9 @@ type PushCommit struct {
183 168
 }
184 169
 
185 170
 type PushCommits struct {
186
-	Len     int
187
-	Commits []*PushCommit
171
+	Len        int
172
+	Commits    []*PushCommit
173
+	CompareUrl string
188 174
 }
189 175
 
190 176
 func ActionContent2Commits(act Actioner) *PushCommits {
@@ -195,52 +181,6 @@ func ActionContent2Commits(act Actioner) *PushCommits {
195 181
 	return push
196 182
 }
197 183
 
198
-// FIXME: Legacy
199
-// ActionDesc accepts int that represents action operation type
200
-// and returns the description.
201
-func ActionDesc(act Actioner) string {
202
-	actUserName := act.GetActUserName()
203
-	email := act.GetActEmail()
204
-	repoUserName := act.GetRepoUserName()
205
-	repoName := act.GetRepoName()
206
-	repoLink := repoUserName + "/" + repoName
207
-	branch := act.GetBranch()
208
-	content := act.GetContent()
209
-	switch act.GetOpType() {
210
-	case 1: // Create repository.
211
-		return fmt.Sprintf(TPL_CREATE_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, repoName)
212
-	case 5: // Commit repository.
213
-		var push *PushCommits
214
-		if err := json.Unmarshal([]byte(content), &push); err != nil {
215
-			return err.Error()
216
-		}
217
-		buf := bytes.NewBuffer([]byte("\n"))
218
-		for _, commit := range push.Commits {
219
-			buf.WriteString(fmt.Sprintf(TPL_COMMIT_REPO_LI, AvatarLink(commit.AuthorEmail), repoLink, commit.Sha1, commit.Sha1[:7], commit.Message) + "\n")
220
-		}
221
-		if push.Len > 3 {
222
-			buf.WriteString(fmt.Sprintf(`<div><a href="{{AppRootSubUrl}}/%s/%s/commits/%s" rel="nofollow">%d other commits >></a></div>`, actUserName, repoName, branch, push.Len))
223
-		}
224
-		return fmt.Sprintf(TPL_COMMIT_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink,
225
-			buf.String())
226
-	case 6: // Create issue.
227
-		infos := strings.SplitN(content, "|", 2)
228
-		return fmt.Sprintf(TPL_CREATE_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
229
-			AvatarLink(email), infos[1])
230
-	case 8: // Transfer repository.
231
-		newRepoLink := content + "/" + repoName
232
-		return fmt.Sprintf(TPL_TRANSFER_REPO, setting.AppSubUrl, actUserName, actUserName, repoLink, newRepoLink, newRepoLink)
233
-	case 9: // Push tag.
234
-		return fmt.Sprintf(TPL_PUSH_TAG, setting.AppSubUrl, actUserName, actUserName, repoLink, branch, branch, repoLink, repoLink)
235
-	case 10: // Comment issue.
236
-		infos := strings.SplitN(content, "|", 2)
237
-		return fmt.Sprintf(TPL_COMMENT_ISSUE, setting.AppSubUrl, actUserName, actUserName, repoLink, infos[0], repoLink, infos[0],
238
-			AvatarLink(email), infos[1])
239
-	default:
240
-		return "invalid type"
241
-	}
242
-}
243
-
244 184
 func DiffTypeToStr(diffType int) string {
245 185
 	diffTypes := map[int]string{
246 186
 		1: "add", 2: "modify", 3: "del",

+ 104 - 0
public/ng/css/gogs.css

@@ -271,6 +271,10 @@ img.avatar-100 {
271 271
 .pagination li {
272 272
   display: inline;
273 273
 }
274
+.list-unstyled {
275
+  padding-left: 0;
276
+  list-style: none;
277
+}
274 278
 .markdown {
275 279
   background-color: white;
276 280
   font-size: 16px;
@@ -1487,6 +1491,106 @@ The register and sign-in page style
1487 1491
   font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
1488 1492
   font-size: 14px;
1489 1493
 }
1494
+.diff-head-box {
1495
+  margin-top: 10px;
1496
+}
1497
+.diff-head-box .panel-body {
1498
+  padding: 10px 15px 5px 10px;
1499
+}
1500
+.diff-head-box .author img {
1501
+  margin-top: -7px;
1502
+}
1503
+.diff-detail-box {
1504
+  margin: 15px 0;
1505
+  line-height: 30px;
1506
+}
1507
+.diff-detail-box ol {
1508
+  clear: both;
1509
+  padding-left: 0;
1510
+  margin-bottom: 28px;
1511
+}
1512
+.diff-detail-box ol li {
1513
+  list-style: none;
1514
+  padding-bottom: 4px;
1515
+  margin-bottom: 4px;
1516
+  border-bottom: 1px dashed #DDD;
1517
+  padding-left: 6px;
1518
+}
1519
+.diff-detail-box span.status {
1520
+  display: inline-block;
1521
+  width: 12px;
1522
+  height: 12px;
1523
+  margin-right: 8px;
1524
+  vertical-align: middle;
1525
+}
1526
+.diff-detail-box span.status.modify {
1527
+  background-color: #f0db88;
1528
+}
1529
+.diff-detail-box span.status.add {
1530
+  background-color: #b4e2b4;
1531
+}
1532
+.diff-detail-box span.status.del {
1533
+  background-color: #e9aeae;
1534
+}
1535
+.diff-detail-box span.status.rename {
1536
+  background-color: #dad8ff;
1537
+}
1538
+.diff-box .count {
1539
+  margin-right: 12px;
1540
+}
1541
+.diff-box .count .bar {
1542
+  background-color: #e75316;
1543
+  height: 12px;
1544
+  width: 40px;
1545
+  display: inline-block;
1546
+  margin: 2px 4px 0 4px;
1547
+  vertical-align: text-top;
1548
+}
1549
+.diff-box .count .bar .add {
1550
+  background-color: #77c64a;
1551
+  height: 12px;
1552
+}
1553
+.diff-box .file {
1554
+  color: #888;
1555
+}
1556
+.diff-box .panel-header {
1557
+  font-size: 14px;
1558
+}
1559
+.diff-file-box .code-diff tbody tr:hover td,
1560
+.diff-file-box .code-diff tbody tr:hover pre {
1561
+  background-color: #FFF8D2 !important;
1562
+  border-color: #F0DB88 !important;
1563
+}
1564
+.diff-file-box .file-body.file-code .lines-num-old {
1565
+  border-right: 1px solid #DDD;
1566
+}
1567
+.file-content .file-body.file-code .lines-num {
1568
+  text-align: right;
1569
+  color: #999;
1570
+  background: #fafafa;
1571
+  width: 1%;
1572
+}
1573
+.diff-file-box .code-diff tbody tr.tag-code td,
1574
+.diff-file-box .code-diff tbody tr.tag-code pre {
1575
+  background-color: #E0E0E0 !important;
1576
+  border-color: #ADADAD !important;
1577
+}
1578
+.diff-file-box .code-diff tbody tr.del-code td,
1579
+.diff-file-box .code-diff tbody tr.del-code pre {
1580
+  background-color: #ffe2dd !important;
1581
+  border-color: #e9aeae !important;
1582
+}
1583
+.diff-file-box .code-diff tbody tr.add-code td,
1584
+.diff-file-box .code-diff tbody tr.add-code pre {
1585
+  background-color: #d1ffd6 !important;
1586
+  border-color: #b4e2b4 !important;
1587
+}
1588
+.compare-head-box {
1589
+  margin-top: 10px;
1590
+}
1591
+.compare-head-box .compare {
1592
+  padding: 0 15px 15px 15px;
1593
+}
1490 1594
 #admin-wrapper,
1491 1595
 #setting-wrapper {
1492 1596
   padding-bottom: 100px;

+ 8 - 0
public/ng/css/ui.css

@@ -713,6 +713,14 @@ ul.menu-radius > li:last-child > a {
713 713
   border-bottom-left-radius: .3em;
714 714
   border-bottom-right-radius: .3em;
715 715
 }
716
+.panel.panel-info {
717
+  border-color: #85c5e5;
718
+}
719
+.panel.panel-info > .panel-header {
720
+  color: #31708f;
721
+  background-color: #d9edf7;
722
+  border-color: #85c5e5;
723
+}
716 724
 .panel.panel-warning {
717 725
   border-color: #F0C36D;
718 726
 }

+ 38 - 0
public/ng/js/gogs.js

@@ -299,6 +299,9 @@ function initCore() {
299 299
         e.preventDefault();
300 300
         $.magnificPopup.close();
301 301
     });
302
+
303
+    // Collapse.
304
+    $('.collapse').hide();
302 305
 }
303 306
 
304 307
 function initUserSetting() {
@@ -698,6 +701,37 @@ function initProfile() {
698 701
     });
699 702
 }
700 703
 
704
+function initTimeSwitch() {
705
+    // Time switch.
706
+    $(".time-since[title]").on("click", function () {
707
+        var $this = $(this);
708
+
709
+        var title = $this.attr("title");
710
+        var text = $this.text();
711
+
712
+        $this.text(title);
713
+        $this.attr("title", text);
714
+    });
715
+}
716
+
717
+function initDiff() {
718
+    $('.diff-detail-box>a').click(function () {
719
+        $($(this).data('target')).slideToggle(100);
720
+    })
721
+    
722
+    var $counter = $('.diff-counter');
723
+    if ($counter.length < 1) {
724
+        return;
725
+    }
726
+    $counter.each(function (i, item) {
727
+        var $item = $(item);
728
+        var addLine = $item.find('span[data-line].add').data("line");
729
+        var delLine = $item.find('span[data-line].del').data("line");
730
+        var addPercent = parseFloat(addLine) / (parseFloat(addLine) + parseFloat(delLine)) * 100;
731
+        $item.find(".bar .add").css("width", addPercent + "%");
732
+    });
733
+}
734
+
701 735
 $(document).ready(function () {
702 736
     Gogs.AppSubUrl = $('head').data('suburl') || '';
703 737
     initCore();
@@ -737,6 +771,10 @@ $(document).ready(function () {
737 771
     if ($('#user-profile-page').length) {
738 772
         initProfile();
739 773
     }
774
+    if ($('#diff-page').length) {
775
+        initTimeSwitch();
776
+        initDiff();
777
+    }
740 778
 
741 779
     $('#dashboard-sidebar-menu').tabs();
742 780
     $('#pull-issue-preview').markdown_preview(".issue-add-comment");

File diff suppressed because it is too large
+ 5 - 5
public/ng/js/min/gogs-min.js


+ 4 - 0
public/ng/less/gogs/base.less

@@ -291,4 +291,8 @@ clear: both;
291 291
     li {
292 292
         display: inline;
293 293
     }
294
+}
295
+.list-unstyled {
296
+    padding-left: 0;
297
+    list-style: none;
294 298
 }

+ 127 - 26
public/ng/less/gogs/repository.less

@@ -494,37 +494,138 @@
494 494
   }
495 495
 }
496 496
 .repo-user-list-block {
497
-  position: relative;
498
-  top: 5px;
497
+    position: relative;
498
+    top: 5px;
499 499
 }
500 500
 .setting-list {
501
-  width: 100%;
502
-  list-style: none;
501
+    width: 100%;
502
+    list-style: none;
503 503
 }
504 504
 #commits-list {
505
-  padding-top: 20px;
506
-  h4{
507
-    line-height: 30px;
508
-    margin-bottom: 0;
509
-  }
505
+    padding-top: 20px;
506
+    h4{
507
+        line-height: 30px;
508
+        margin-bottom: 0;
509
+    }
510 510
 }
511 511
 .commit-list {
512
-  th {
513
-    background-color: #FFF;
514
-    line-height: 28px !important;
515
-  }
516
-  .date {
517
-    width: 120px;
518
-  }
519
-  .author {
520
-    padding-left: 20px;
521
-    min-width: 180px;
522
-    img {
523
-      margin-top: -4px;
512
+    th {
513
+        background-color: #FFF;
514
+        line-height: 28px !important;
515
+    }
516
+    .date {
517
+        width: 120px;
518
+    }
519
+    .author {
520
+        padding-left: 20px;
521
+        min-width: 180px;
522
+        img {
523
+            margin-top: -4px;
524
+        }
525
+    }
526
+    .sha a {
527
+        font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
528
+        font-size: 14px;
529
+    }
530
+}
531
+.diff-head-box {
532
+    margin-top: 10px;
533
+    .panel-body {
534
+        padding: 10px 15px 5px 10px;
535
+    }
536
+    .author {
537
+        img {
538
+            margin-top: -7px;
539
+        }
540
+    }
541
+}
542
+.diff-detail-box {
543
+    margin: 15px 0;
544
+    line-height: 30px;
545
+    ol {
546
+        clear: both;
547
+        padding-left: 0;
548
+        margin-bottom: 28px;
549
+        li {
550
+            list-style: none;
551
+            padding-bottom: 4px;
552
+            margin-bottom: 4px;
553
+            border-bottom: 1px dashed #DDD;
554
+            padding-left: 6px;
555
+        }
556
+    }
557
+    span.status{
558
+        display: inline-block;
559
+        width: 12px;
560
+        height: 12px;
561
+        margin-right: 8px;
562
+        vertical-align: middle;
563
+        &.modify {
564
+            background-color: #f0db88;
565
+        }
566
+        &.add {
567
+            background-color: #b4e2b4;
568
+        }
569
+        &.del {
570
+            background-color: #e9aeae;
571
+        }
572
+        &.rename {
573
+            background-color: #dad8ff;
574
+        }
575
+    }
576
+}
577
+.diff-box {
578
+    .count {
579
+        margin-right: 12px;
580
+        .bar {
581
+            background-color: #e75316;
582
+            height: 12px;
583
+            width: 40px;
584
+            display: inline-block;
585
+            margin: 2px 4px 0 4px;
586
+            vertical-align: text-top;
587
+            .add {
588
+                background-color: #77c64a;
589
+                height: 12px;
590
+            }
591
+        }
592
+    }
593
+    .file {
594
+        color: #888;
595
+    }
596
+    .panel-header {
597
+        font-size: 14px;
598
+    }
599
+}
600
+.diff-file-box .code-diff tbody tr:hover td, .diff-file-box .code-diff tbody tr:hover pre {
601
+    background-color: #FFF8D2 !important;
602
+    border-color: #F0DB88 !important;
603
+}
604
+.diff-file-box .file-body.file-code .lines-num-old {
605
+border-right: 1px solid #DDD;
606
+}
607
+.file-content .file-body.file-code .lines-num {
608
+text-align: right;
609
+color: #999;
610
+background: #fafafa;
611
+width: 1%;
612
+}
613
+.diff-file-box .code-diff tbody tr.tag-code td, .diff-file-box .code-diff tbody tr.tag-code pre {
614
+background-color: #E0E0E0 !important;
615
+border-color: #ADADAD !important;
616
+}
617
+.diff-file-box .code-diff tbody tr.del-code td, .diff-file-box .code-diff tbody tr.del-code pre {
618
+background-color: #ffe2dd !important;
619
+border-color: #e9aeae !important;
620
+}
621
+.diff-file-box .code-diff tbody tr.add-code td, .diff-file-box .code-diff tbody tr.add-code pre {
622
+background-color: #d1ffd6 !important;
623
+border-color: #b4e2b4 !important;
624
+}
625
+
626
+.compare-head-box {
627
+    margin-top: 10px;
628
+    .compare {
629
+        padding: 0 15px 15px 15px;
524 630
     }
525
-  }
526
-  .sha a {
527
-    font-family: Consolas, Menlo, Monaco, "Lucida Console", monospace;
528
-    font-size: 14px;
529
-  }
530 631
 }

+ 8 - 0
public/ng/less/ui/panel.less

@@ -36,6 +36,14 @@
36 36
           border-bottom-right-radius: .3em;
37 37
         }
38 38
     }
39
+    &.panel-info {
40
+        border-color: #85c5e5;
41
+        > .panel-header {
42
+            color: #31708f;
43
+            background-color: #d9edf7;
44
+            border-color: #85c5e5;
45
+        }
46
+    }
39 47
     &.panel-warning {
40 48
         border-color: #F0C36D;
41 49
         > .panel-header {

+ 2 - 0
routers/repo/commit.go

@@ -159,6 +159,7 @@ func Diff(ctx *middleware.Context) {
159 159
 	ctx.Data["IsImageFile"] = isImageFile
160 160
 	ctx.Data["Title"] = commit.Summary() + " · " + base.ShortSha(commitId)
161 161
 	ctx.Data["Commit"] = commit
162
+	ctx.Data["Author"] = models.ValidateCommitWithEmail(commit)
162 163
 	ctx.Data["Diff"] = diff
163 164
 	ctx.Data["Parents"] = parents
164 165
 	ctx.Data["DiffNotAvailable"] = diff.NumFiles() == 0
@@ -212,6 +213,7 @@ func CompareDiff(ctx *middleware.Context) {
212 213
 		ctx.Handle(500, "CommitsBeforeUntil", err)
213 214
 		return
214 215
 	}
216
+	commits = models.ValidateCommitsWithEmails(commits)
215 217
 
216 218
 	ctx.Data["Commits"] = commits
217 219
 	ctx.Data["CommitCount"] = commits.Len()

+ 3 - 1
templates/repo/commits_table.tmpl

@@ -1,10 +1,12 @@
1 1
 <div id="commits-list">
2 2
     <div class="panel panel-radius">
3 3
         <div class="panel-header">
4
+            {{if not .IsDiffCompare}}
4 5
             <form class="search pull-right" action="{{.RepoLink}}/commits/{{.BranchName}}/search" method="get" id="commits-search-form">
5 6
                 <input class="ipt ipt-radius" type="search" name="q" placeholder="{{.i18n.Tr "repo.commits.search"}}" value="{{.Keyword}}" />
6 7
                 <button class="btn btn-black btn-small btn-radius">{{.i18n.Tr "repo.commits.find"}}</button>
7 8
             </form>
9
+            {{end}}
8 10
             <h4>{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}}</h4>
9 11
         </div>
10 12
         <table class="panel-body table commit-list table-striped">
@@ -31,7 +33,7 @@
31 33
             </tbody>
32 34
         </table>
33 35
     </div>
34
-    {{if not .IsSearchPage}}
36
+    {{if and (not .IsSearchPage) (not .IsDiffCompare)}}
35 37
     <ul class="pagination">
36 38
         {{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}}
37 39
         {{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}}

+ 41 - 35
templates/repo/diff.tmpl

@@ -1,49 +1,54 @@
1
-{{template "base/head" .}}
2
-{{template "base/navbar" .}}
3
-{{template "repo/nav" .}}
4
-<div id="body" class="container" data-page="repo">
5
-    <div id="source">
6
-      {{if .IsDiffCompare }}
7
-        <div class="panel panel-info diff-box diff-head-box">
8
-            <div class="panel-heading">
9
-                <a class="pull-right btn btn-primary btn-sm" rel="nofollow" href="{{.SourcePath}}">Browse Source</a>
10
-                <h4><a href="{{$.RepoLink}}/commit/{{.BeforeCommitId}}" class="label label-success">{{ShortSha .BeforeCommitId}}</a> ... <a href="{{$.RepoLink}}/commit/{{.AfterCommitId}}" class="label label-success">{{ShortSha .AfterCommitId}}</a></h4>
1
+{{template "ng/base/head" .}}
2
+{{template "ng/base/header" .}}
3
+<div id="repo-wrapper">
4
+    {{template "repo/header" .}}
5
+    <div class="container clear" id="diff-page">
6
+        {{if .IsDiffCompare }}
7
+        <div class="panel panel-info panel-radius compare-head-box">
8
+            <div class="panel-header">
9
+                <a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{.SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
10
+                <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>
11 11
             </div>
12 12
             <div class="panel-body compare">
13
-              {{template "repo/commits_table" .}}
13
+                {{template "repo/commits_table" .}}
14 14
             </div>
15 15
         </div>
16
-      {{else}}
17
-          <div class="panel panel-info diff-box diff-head-box">
18
-            <div class="panel-heading">
19
-                <a class="pull-right btn btn-primary btn-sm" rel="nofollow" href="{{.SourcePath}}">Browse Source</a>
16
+        {{else}}
17
+        <div class="panel panel-info panel-radius diff-head-box">
18
+            <div class="panel-header">
19
+                <a class="pull-right btn btn-blue btn-header btn-medium btn-radius" rel="nofollow" href="{{.SourcePath}}">{{.i18n.Tr "repo.diff.browse_source"}}</a>
20 20
                 <h4>{{.Commit.Message}}</h4>
21 21
             </div>
22 22
             <div class="panel-body">
23 23
                 <span class="pull-right">
24
-                <ul class="list-unstyled">
25
-                    {{range .Parents}}
26
-                    <li>parent <a href="{{$.RepoLink}}/commit/{{.}}"><span class="label label-default sha">{{ShortSha .}}</span></a></li>
27
-                    {{end}}
28
-                    <li>commit <span class="label label-default sha">{{ShortSha .CommitId}}</span></li>
29
-                </ul>
24
+                    <ul class="list-unstyled">
25
+                        <li class="inline">{{.i18n.Tr "repo.diff.parent"}}</li>
26
+                        {{range .Parents}}
27
+                        <li class="inline"><a href="{{$.RepoLink}}/commit/{{.}}"><span class="label label-blue">{{ShortSha .}}</span></a></li>
28
+                        {{end}}
29
+                        <li class="inline">{{.i18n.Tr "repo.diff.commit"}} <span class="label label-blue">{{ShortSha .CommitId}}</span></li>
30
+                    </ul>
30 31
                 </span>
31 32
                 <p class="author">
32
-                    <img class="avatar" src="{{AvatarLink .Commit.Author.Email}}" alt=""/>
33
-                    <a class="name" href="{{AppSubUrl}}/user/email2user?email={{.Commit.Author.Email}}"><strong>{{.Commit.Author.Name}}</strong></a>
34
-                    <span class="time">{{TimeSince .Commit.Author.When $.Lang}}</span>
33
+                    <img class="avatar-30" src="{{AvatarLink .Commit.Author.Email}}" />
34
+                    {{if .Author}}
35
+                    <a href="{{AppSubUrl}}/{{.Author}}"><strong>{{.Commit.Author.Name}}</strong></a>
36
+                    {{else}}
37
+                    <strong>{{.Commit.Author.Name}}</strong>
38
+                    {{end}}
39
+                    <span class="text-grey" id="authored-time">{{TimeSince .Commit.Author.When $.Lang}}</span> 
35 40
                 </p>
36
-          </div>
41
+            </div>
37 42
         </div>
38
-      {{end}}
43
+        {{end}}
39 44
         {{if .DiffNotAvailable}}
40
-        <h4>Diff Data Not Available.</h4>
45
+        <h4>{{.i18n.Tr "repo.diff.data_not_available"}}</h4>
41 46
         {{else}}
42 47
         <div class="diff-detail-box diff-box">
43
-            <a class="pull-right btn btn-default" data-toggle="collapse" data-target="#diff-files">Show Diff Stats</a>
48
+            <a class="pull-right btn btn-gray btn-header btn-radius text-black" data-target="#diff-files">{{.i18n.Tr "repo.diff.show_diff_stats"}}</a>
44 49
             <p class="showing">
45 50
                 <i class="fa fa-retweet"></i>
46
-                <strong> {{.Diff.NumFiles}} changed files</strong> with <strong>{{.Diff.TotalAddition}} additions</strong> and <strong>{{.Diff.TotalDeletion}} deletions</strong>.
51
+                {{.i18n.Tr "repo.diff.stats_desc" .Diff.NumFiles .Diff.TotalAddition .Diff.TotalDeletion | Str2html}}
47 52
             </p>
48 53
             <ol class="detail-files collapse" id="diff-files">
49 54
                 {{range .Diff.Files}}
@@ -57,7 +62,7 @@
57 62
                         </span>
58 63
                         <span class="del" data-line="{{.Deletion}}">{{.Deletion}}</span>
59 64
                         {{else}}
60
-                        <span>BIN</span>
65
+                        <span>{{$.i18n.Tr "repo.diff.bin"}}</span>
61 66
                         {{end}}
62 67
                     </div>
63 68
                     <!-- todo finish all file status, now modify, add, delete and rename -->
@@ -69,8 +74,8 @@
69 74
         </div>
70 75
 
71 76
         {{range .Diff.Files}}
72
-        <div class="panel panel-default diff-file-box diff-box file-content" id="diff-{{.Index}}">
73
-            <div class="panel-heading">
77
+        <div class="panel diff-file-box diff-box file-content" id="diff-{{.Index}}">
78
+            <div class="panel-header">
74 79
                 <div class="diff-counter count pull-left">
75 80
                     {{if not .IsBin}}
76 81
                     <span class="add" data-line="{{.Addition}}">+ {{.Addition}}</span>
@@ -80,10 +85,10 @@
80 85
                     </span>
81 86
                     <span class="del" data-line="{{.Deletion}}">- {{.Deletion}}</span>
82 87
                     {{else}}
83
-                    BIN
88
+                    {{$.i18n.Tr "repo.diff.bin"}}
84 89
                     {{end}}
85 90
                 </div>
86
-                <a class="btn btn-default btn-sm pull-right" rel="nofollow" href="{{$.SourcePath}}/{{.Name}}">View File</a>
91
+                <a class="btn btn-gray btn-header btn-radius text-black pull-right" rel="nofollow" href="{{$.SourcePath}}/{{.Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
87 92
                 <span class="file">{{.Name}}</span>
88 93
             </div>
89 94
             {{$isImage := (call $.IsImageFile .Name)}}
@@ -115,8 +120,9 @@
115 120
                 {{end}}
116 121
             </div>
117 122
         </div>
123
+        <br> 
118 124
         {{end}}
119 125
         {{end}}
120 126
     </div>
121 127
 </div>
122
-{{template "base/footer" .}}
128
+{{template "ng/base/footer" .}}

+ 1 - 0
templates/user/dashboard/feeds.tmpl

@@ -28,6 +28,7 @@
28 28
                 {{range $push.Commits}}
29 29
                 <li><img class="avatar-16" src="{{AvatarLink .AuthorEmail}}?s=16"> <a href="{{AppSubUrl}}/{{$repoLink}}/commit/{{.Sha1}}">{{ShortSha .Sha1}}</a> <span class="text-truncate grid-4-5">{{.Message}}</span></li>
30 30
                 {{end}}
31
+                {{if $push.CompareUrl}}<li><a href="{{$push.CompareUrl}}">{{$.i18n.Tr "action.compare_2_commits"}} »</a></li>{{end}}
31 32
             </ul>
32 33
         </div>
33 34
         {{else if eq .GetOpType 6}}