zitgit 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -1,13 +1,32 @@
1
1
  (function() {
2
- var ChangeCommit, SetHeight, UpdateDiffsWidth;
2
+ var ChangeBranch, ChangeCommit, CommitArrows, LoadStatus, RefreshContent, RefreshStatus, SelectDiff, SelectRow, SetHeight, SwitchBranch, TableArrows, UpdateDiffsWidth;
3
3
 
4
4
  ChangeCommit = function($commit) {
5
5
  var $target_commit;
6
6
 
7
7
  $target_commit = $commit.clone();
8
8
  $('.commits-table tr.selected').removeClass('selected');
9
+ $('.status').removeClass('selected');
9
10
  $commit.parents('tr').addClass('selected');
10
11
  $('.show_commit').html($target_commit);
12
+ $('.show_commit .diffs li').niceScroll({
13
+ cursorcolor: '#ccc',
14
+ cursorwidth: 14
15
+ });
16
+ return UpdateDiffsWidth();
17
+ };
18
+
19
+ LoadStatus = function() {
20
+ var $status_content;
21
+
22
+ $('.commits-table tr.selected').removeClass('selected');
23
+ $('.status').addClass('selected');
24
+ $status_content = $('.status .status_content').clone();
25
+ $('.show_commit').html($status_content);
26
+ $('.show_commit .diffs li').niceScroll({
27
+ cursorcolor: '#ccc',
28
+ cursorwidth: 14
29
+ });
11
30
  return UpdateDiffsWidth();
12
31
  };
13
32
 
@@ -26,31 +45,178 @@
26
45
  });
27
46
  };
28
47
 
29
- $(function() {
48
+ SelectDiff = function($diff) {
49
+ var index;
50
+
51
+ $('.show_commit .diff-names .selected').removeClass('selected');
52
+ $diff.addClass('selected');
53
+ if ($diff.hasClass('all')) {
54
+ return $('.show_commit .diffs li').removeClass('hidden');
55
+ } else {
56
+ index = $diff.index() - 1;
57
+ $('.show_commit .diffs li').addClass('hidden');
58
+ return $('.show_commit .diffs li:eq(' + index + ')').removeClass('hidden');
59
+ }
60
+ };
61
+
62
+ ChangeBranch = function($link) {
63
+ var timeout;
64
+
65
+ timeout = setTimeout(function() {
66
+ $('.loader').show();
67
+ return $('.main').hide();
68
+ }, 1500);
69
+ return $.get($link.attr('href'), function(data) {
70
+ var list_class;
71
+
72
+ clearTimeout(timeout);
73
+ $('.loader').hide();
74
+ $('.current_branch').text('');
75
+ if ($link.parents('.ref_label').length) {
76
+ list_class = $link.parents('.ref_label').attr('data-dropdown-name');
77
+ $('.dropdown.' + list_class + '').parent('.has-dropdown').find('.current_branch').text($link.text());
78
+ } else {
79
+ $link.parents('.has-dropdown').find('.current_branch').text($link.text());
80
+ }
81
+ $('.commits-table').replaceWith(data);
82
+ $('.main').show();
83
+ return ChangeCommit($('.commits-table tbody tr:first .commit'));
84
+ });
85
+ };
86
+
87
+ SwitchBranch = function() {
30
88
  $('.top-bar .dropdown li a').on('click', function(e) {
31
- var $link, timeout;
89
+ e.preventDefault();
90
+ return ChangeBranch($(this));
91
+ });
92
+ return $('body').on('click', '.ref_label a', function(e) {
93
+ e.preventDefault();
94
+ return ChangeBranch($(this));
95
+ });
96
+ };
97
+
98
+ RefreshStatus = function() {
99
+ return $.get('/status/', function(data) {
100
+ return $('.status').replaceWith(data);
101
+ });
102
+ };
103
+
104
+ RefreshContent = function() {
105
+ RefreshStatus();
106
+ return $('.current_branch').each(function(index) {
107
+ var branch_name;
108
+
109
+ if ($(this).text() !== '') {
110
+ branch_name = $(this).text();
111
+ $(this).parent('.has-dropdown').find('.dropdown li a').each(function(index) {
112
+ if ($(this).text() === branch_name) {
113
+ ChangeBranch($(this));
114
+ return false;
115
+ }
116
+ });
117
+ return false;
118
+ }
119
+ });
120
+ };
121
+
122
+ SelectRow = function($row) {
123
+ var current_scroll, offset;
32
124
 
125
+ if ($row.offset().top < $('.history').offset().top) {
126
+ current_scroll = $('.history').scrollTop();
127
+ $('.history').scrollTop(current_scroll + $row.offset().top - $('.history').offset().top);
128
+ }
129
+ offset = $row.offset().top - $('.history').offset().top;
130
+ if (offset + $row.outerHeight() > $('.history').outerHeight()) {
131
+ current_scroll = $('.history').scrollTop();
132
+ $('.history').scrollTop(current_scroll + offset + $row.outerHeight() - $('.history').outerHeight());
133
+ }
134
+ return ChangeCommit($row.find('.commit'));
135
+ };
136
+
137
+ TableArrows = function() {
138
+ var motions;
139
+
140
+ motions = [38, 40, 33, 34, 35, 36];
141
+ return $('.history').on('keydown', function(e) {
142
+ var $next, $next_rows;
143
+
144
+ if (motions.indexOf(e.keyCode) === -1) {
145
+ return;
146
+ }
33
147
  e.preventDefault();
34
- $link = $(this);
35
- timeout = setTimeout(function() {
36
- $('.loader').show();
37
- return $('.main').hide();
38
- }, 1500);
39
- return $.get($link.attr('href'), function(data) {
40
- clearTimeout(timeout);
41
- $('.loader').hide();
42
- $('.current_branch').text('');
43
- $link.parents('.has-dropdown').find('.current_branch').text($link.text());
44
- $('.commits-table').replaceWith(data);
45
- $('.main').show();
46
- return ChangeCommit($('.commits-table tbody tr:first .commit'));
47
- });
148
+ e.stopPropagation();
149
+ if (e.keyCode === 38) {
150
+ $next = $('.commits-table tr.selected').prev();
151
+ } else if (e.keyCode === 40) {
152
+ $next = $('.commits-table tr.selected').next();
153
+ } else if (e.keyCode === 33) {
154
+ $next_rows = $('.commits-table tr.selected').prevAll();
155
+ if ($next_rows.length >= 10) {
156
+ $next = $next_rows.eq(9);
157
+ } else {
158
+ $next = $next_rows.last();
159
+ }
160
+ } else if (e.keyCode === 34) {
161
+ $next_rows = $('.commits-table tr.selected').nextAll();
162
+ if ($next_rows.length >= 10) {
163
+ $next = $next_rows.eq(9);
164
+ } else {
165
+ $next = $next_rows.last();
166
+ }
167
+ } else if (e.keyCode === 36) {
168
+ $next = $('.commits-table tbody tr:first');
169
+ } else if (e.keyCode === 35) {
170
+ $next = $('.commits-table tr:last');
171
+ }
172
+ if ($next && $next.length > 0) {
173
+ return SelectRow($next);
174
+ }
48
175
  });
176
+ };
177
+
178
+ CommitArrows = function() {
179
+ var motions;
180
+
181
+ motions = [38, 40];
182
+ return $('.show_commit').on('keydown', function(e) {
183
+ var $next;
184
+
185
+ if (motions.indexOf(e.keyCode) === -1) {
186
+ return;
187
+ }
188
+ e.preventDefault();
189
+ e.stopPropagation();
190
+ if (e.keyCode === 38) {
191
+ $next = $('.show_commit .diff-names li.selected').prev();
192
+ } else if (e.keyCode === 40) {
193
+ $next = $('.show_commit .diff-names li.selected').next();
194
+ }
195
+ if ($next && $next.length > 0) {
196
+ return SelectDiff($next);
197
+ }
198
+ });
199
+ };
200
+
201
+ $(function() {
49
202
  $('.history').on('click', '.commits-table tr', function(e) {
50
203
  return ChangeCommit($(this).find('.commit'));
51
204
  });
52
- UpdateDiffsWidth();
205
+ $('.history').on('click', '.status-link', function(e) {
206
+ e.preventDefault();
207
+ return LoadStatus();
208
+ });
209
+ $('.refresh').on('click', function(e) {
210
+ e.preventDefault();
211
+ return RefreshContent();
212
+ });
213
+ $('.show_commit').on('click', '.diff-names li', function(e) {
214
+ return SelectDiff($(this));
215
+ });
216
+ SwitchBranch();
53
217
  SetHeight();
218
+ TableArrows();
219
+ CommitArrows();
54
220
  $(window).resize(function() {
55
221
  return SetHeight();
56
222
  });
@@ -64,10 +230,11 @@
64
230
  railalign: 'left',
65
231
  horizrailenabled: false
66
232
  });
67
- return $('.diffs li').niceScroll({
233
+ $('.show_commit .diffs li').niceScroll({
68
234
  cursorcolor: '#ccc',
69
235
  cursorwidth: 14
70
236
  });
237
+ return UpdateDiffsWidth();
71
238
  });
72
239
 
73
240
  }).call(this);
data/public/scss/app.scss CHANGED
@@ -2,8 +2,14 @@
2
2
 
3
3
  .top-bar {
4
4
  z-index: 6;
5
+ .refresh{
6
+ img{
7
+ position: relative;
8
+ top: 8px;
9
+ }
10
+ }
5
11
  }
6
- .row .history.columns{
12
+ .main .history.columns{
7
13
  padding: 0 0 0 15px;
8
14
  }
9
15
  .ref_label{
@@ -12,15 +18,30 @@
12
18
  border-radius: 12px;
13
19
  padding: 2px 4px;
14
20
  float: left;
21
+ a{
22
+ color: #000;
23
+ }
15
24
  }
16
25
  .branch_label{
17
- background: yellow;
26
+ background: #ffeeee;
27
+ border-color: #581313;
28
+ a{
29
+ color: #581313;
30
+ }
18
31
  }
19
32
  .remote_label{
20
- background: red;
33
+ background: #ffe3e3;
34
+ border-color: #b32222;
35
+ a{
36
+ color: #b32222;
37
+ }
21
38
  }
22
39
  .tag_label{
23
- background: #e77a1c;
40
+ background: #ffe6bc;
41
+ border-color: #ff9800;
42
+ a{
43
+ color: #ff9800;
44
+ }
24
45
  }
25
46
  .commits-table{
26
47
  thead{
@@ -44,11 +65,22 @@
44
65
  font-size: 12px;
45
66
  border-radius: 8px;
46
67
  padding: 0 2px;
68
+ max-width: 134px;
69
+ word-wrap: break-word;
70
+ text-align: center;
71
+ }
72
+ .sha{
73
+ font-size:10px;
47
74
  }
48
75
  }
49
76
  .author{
50
77
  width: 180px;
51
78
  }
79
+ .message{
80
+ div{
81
+ max-height: 56px;
82
+ }
83
+ }
52
84
  tbody{
53
85
  tr.selected{
54
86
  background: #c3e2ff;
@@ -75,7 +107,8 @@
75
107
  padding-top: 14px;
76
108
  list-style-type: none;
77
109
  li{
78
- margin-bottom: -8px;
110
+ margin-bottom: -4px;
111
+ padding: 0 4px;
79
112
  .new_file{
80
113
  color: green;
81
114
  }
@@ -83,10 +116,14 @@
83
116
  color: red;
84
117
  }
85
118
  }
119
+ .selected{
120
+ background: #a7d5ff;
121
+ }
86
122
  }
87
123
  .diffs{
88
124
  background: #fff;
89
125
  list-style-type: none;
126
+ font-family: monospace;
90
127
  li{
91
128
  border-bottom: solid #ddd 8px;
92
129
  overflow-x: scroll;
@@ -96,16 +133,19 @@
96
133
  }
97
134
  .diff-first-line{
98
135
  font-weight: bold;
99
- background: #A7B5FF;
100
- border-bottom: 1px solid black;
136
+ background: #eee;
137
+ border-bottom: 1px solid #777;
101
138
  }
102
139
  .diff-summ-line{
103
- background: #A7B5FF;
140
+ background: #eee;
104
141
  font-weight: bold;
105
142
  }
106
143
  .diff-added-line{
107
144
  color: #096707;
108
145
  background: #87f49f;
146
+ .trailing{
147
+ background: #036420;
148
+ }
109
149
  }
110
150
  .diff-removed-line{
111
151
  position: relative;
@@ -113,8 +153,14 @@
113
153
  right: 0;
114
154
  color: #742b2b;
115
155
  background: #ffb1cb;
156
+ .trailing{
157
+ background: #c10000;
158
+ }
116
159
  }
117
160
  }
161
+ img{
162
+ display: block;
163
+ }
118
164
  }
119
165
  .hidden{
120
166
  display: none;
@@ -126,23 +172,36 @@
126
172
  background: #ddd;
127
173
  border-radius: 16px;
128
174
  .author_info{
129
- /*width: 50%;*/
130
175
  float: left;
131
176
  font-weight: bold;
177
+ clear: left;
178
+ color: #eee;
179
+ text-shadow: 1px 1px 0px #333, 1px -1px 0px #333, -1px 1px 0px #333, -1px -1px 0px #333;
132
180
  }
133
181
  .commit_sha{
134
182
  margin-bottom:14px;
135
- margin-top: -14px;
136
183
  clear: left;
184
+ float: left;
185
+ }
186
+ .commit_date{
187
+ margin-bottom:14px;
188
+ float: right;
137
189
  }
138
190
  .stats{
139
191
  float: right;
192
+ text-align: right;
140
193
  .additions{
141
194
  color: green;
142
195
  }
143
196
  .deletions{
144
197
  color: red;
145
198
  }
199
+ .merge_commit{
200
+ font-weight: bold;
201
+ position: relative;
202
+ top: 8px;
203
+ color: #0300ff;
204
+ }
146
205
  }
147
206
  }
148
207
  }
@@ -153,3 +212,24 @@
153
212
  background: url('/images/loader.gif') no-repeat;
154
213
  display: none;
155
214
  }
215
+ .status{
216
+ margin-bottom: 8px;
217
+ padding: 4px 0;
218
+ .status_content{
219
+ display: none;
220
+ }
221
+ .status-link{
222
+ display: block;
223
+ font-weight: bold;
224
+ color: #000;
225
+ padding-left: 16px;
226
+ font-size: 20px;
227
+ }
228
+ &.selected{
229
+ background: #c3e2ff;
230
+ border-bottom: 2px solid #78c3ff;
231
+ border-top: 2px solid #78c3ff;
232
+ border-left: 1px solid #78c3ff;
233
+ border-right: 1px solid #78c3ff;
234
+ }
235
+ }
@@ -1,12 +1,22 @@
1
1
  .commit
2
- h4=commit.message
2
+ h4=strip_message(commit.message, 120)
3
3
  == slim :'commits/labels', :locals => {commit: commit}, :layout => false
4
4
  .commit_sha =commit.sha
5
+ .commit_date =commit.date.strftime("%d.%m.%Y %H:%M")
5
6
  .author_info
6
7
  div = commit.author.name
7
8
  div = commit.author.email
8
9
  .stats
9
- div.additions = "#{ commit.stats.additions } additions"
10
- div.deletions = "#{ commit.stats.deletions } deletions"
10
+ - if merge_commit?(commit)
11
+ div.merge_commit merge
12
+ -else
13
+ div.additions = "#{ commit.stats.additions } additions"
14
+ div.deletions = "#{ commit.stats.deletions } deletions"
11
15
 
12
- == slim :'diffs/list', :locals => {diffs: commit.diffs}, :layout => false
16
+ - if large_commit?(commit)
17
+ .diff-names
18
+ .large
19
+ =' commit.diffs.count
20
+ | files changed
21
+ - else
22
+ == slim(:'diffs/list', :locals => {diffs: commit.diffs}, :layout => false).force_encoding('utf-8')